summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Newswanger <gamma.dave@gmail.com>2018-04-06 08:16:07 -0400
committerGitHub <noreply@github.com>2018-04-06 08:16:07 -0400
commit712d30f46ca3126e1f4f1a83993614c029877aaa (patch)
treee74c444d5aa988d212dc6b483fc4718e1fd75b64
parent49aac5f8c7abfa54d3f4ca2e5a06a67e193c54ad (diff)
downloadansible-712d30f46ca3126e1f4f1a83993614c029877aaa.tar.gz
Add eos_smoke integration tests (#36957)
* added eos_smoke tests * removed left over file * added note to uncomment broken eapi test when #36919 is fixed * uncommented fixed test, added unbecome test * skip become tests when connection=local
-rw-r--r--test/integration/targets/eos_smoke/defaults/main.yaml2
-rw-r--r--test/integration/targets/eos_smoke/meta/main.yml2
-rw-r--r--test/integration/targets/eos_smoke/tasks/cli.yaml22
-rw-r--r--test/integration/targets/eos_smoke/tasks/eapi.yaml16
-rw-r--r--test/integration/targets/eos_smoke/tasks/main.yaml3
-rw-r--r--test/integration/targets/eos_smoke/tests/cli/common_config.yaml108
-rw-r--r--test/integration/targets/eos_smoke/tests/cli/common_utils.yaml72
-rw-r--r--test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml26
-rw-r--r--test/integration/targets/eos_smoke/tests/eapi/common_config.yaml99
-rw-r--r--test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml66
-rw-r--r--test/integration/targets/eos_smoke/tests/eapi/misc_tests.yaml26
11 files changed, 442 insertions, 0 deletions
diff --git a/test/integration/targets/eos_smoke/defaults/main.yaml b/test/integration/targets/eos_smoke/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/eos_smoke/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/eos_smoke/meta/main.yml b/test/integration/targets/eos_smoke/meta/main.yml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_smoke/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_smoke/tasks/cli.yaml b/test/integration/targets/eos_smoke/tasks/cli.yaml
new file mode 100644
index 0000000000..a6f7ae0351
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tasks/cli.yaml
@@ -0,0 +1,22 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test cases (connection=network_cli)
+ include: "{{ test_case_to_run }} ansible_connection=network_cli"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+- name: run test case (connection=local)
+ include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
+ with_first_found: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/eos_smoke/tasks/eapi.yaml b/test/integration/targets/eos_smoke/tasks/eapi.yaml
new file mode 100644
index 0000000000..bda1df677a
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tasks/eapi.yaml
@@ -0,0 +1,16 @@
+---
+- name: collect all eapi test cases
+ find:
+ paths: "{{ role_path }}/tests/eapi"
+ patterns: "{{ testcase }}.yaml"
+ delegate_to: localhost
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case (connection=local)
+ include: "{{ test_case_to_run }} ansible_connection=local"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/eos_smoke/tasks/main.yaml b/test/integration/targets/eos_smoke/tasks/main.yaml
new file mode 100644
index 0000000000..970e74171e
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: eapi.yaml, tags: ['eapi'] }
diff --git a/test/integration/targets/eos_smoke/tests/cli/common_config.yaml b/test/integration/targets/eos_smoke/tests/cli/common_config.yaml
new file mode 100644
index 0000000000..ca631e2b00
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tests/cli/common_config.yaml
@@ -0,0 +1,108 @@
+---
+# eos_config -> NetworkConfig, dumps
+
+- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}"
+
+- name: setup
+ eos_config:
+ lines: hostname {{ inventory_hostname_short }}
+ match: none
+ provider: "{{ cli }}"
+ become: yes
+
+- name: get current running-config
+ eos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ become: yes
+ register: config
+
+- name: configure hostname
+ eos_config:
+ lines: hostname foo
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ cli }}"
+ become: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: get current running-config
+ eos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ become: yes
+ register: config
+
+- name: teardown
+ eos_config:
+ lines: hostname {{ inventory_hostname_short }}
+ match: none
+ provider: "{{ cli }}"
+ become: yes
+
+# hit block and diffs
+
+- name: setup
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: strict
+ provider: "{{ cli }}"
+ become: yes
+
+- name: configure sub level command using block resplace
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ replace: block
+ after: exit
+ provider: "{{ cli }}"
+ match: line
+ become: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ip host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ip host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ip host 4.4.4.4 any log' in result.updates"
+
+- name: check sub level command using block replace
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ replace: block
+ after: exit
+ provider: "{{ cli }}"
+ match: exact
+ become: yes
+ register: result
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+ become: yes
+
+- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml b/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml
new file mode 100644
index 0000000000..4f0242b607
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml
@@ -0,0 +1,72 @@
+---
+# eos_static_route -> remove_default_spec, validate_ip_address, validate_prefix
+# eos_interface -> conditional
+# eos_command -> ComplexList
+
+- debug: msg="START cli/common_utils.yaml on connection={{ ansible_connection }}"
+
+# hit remove_default_spec() validate_ip_address() validate_prefix() ComplexList
+- name: setup - remove config used in test
+ eos_config:
+ lines:
+ - no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
+ provider: "{{ cli }}"
+ become: yes
+
+- name: configure static route
+ eos_static_route:
+ address: 192.168.3.0/24
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ cli }}"
+ become: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands"
+
+- name: configure static route
+ eos_static_route:
+ address: 192.168.3.0/250
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ cli }}"
+ become: yes
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- name: teardown
+ eos_config:
+ lines:
+ - no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
+ provider: "{{ cli }}"
+ become: yes
+
+- debug: msg="END cli/common_utils.yaml on connection={{ ansible_connection }}"
+
+
+# hit conditional()
+- name: Set test interface
+ set_fact:
+ test_interface_1: ethernet1
+
+- name: Check intent arguments
+ eos_interface:
+ name: "{{ test_interface_1 }}"
+ state: up
+ tx_rate: ge(0)
+ rx_rate: ge(0)
+ authorize: yes
+ provider: "{{ cli }}"
+ become: yes
+ register: result
diff --git a/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml b/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml
new file mode 100644
index 0000000000..3d8297e3b9
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml
@@ -0,0 +1,26 @@
+---
+- debug: msg="START cli/misc_tests.yaml on connection={{ ansible_connection }}"
+
+
+# test become and unbecome
+- block:
+ - name: command that does require become (should fail)
+ eos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ become: no
+ ignore_errors: yes
+ register: result
+
+ - assert:
+ that:
+ - 'result.failed == true'
+ - '"privileged mode required" in result.module_stderr'
+
+ - name: command that doesn't require become
+ eos_command:
+ commands: show uptime
+ provider: "{{ cli }}"
+ become: no
+
+ when: "ansible_connection != 'local'"
diff --git a/test/integration/targets/eos_smoke/tests/eapi/common_config.yaml b/test/integration/targets/eos_smoke/tests/eapi/common_config.yaml
new file mode 100644
index 0000000000..da80c00409
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tests/eapi/common_config.yaml
@@ -0,0 +1,99 @@
+---
+# eos_config -> NetworkConfig, dumps
+
+- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}"
+
+- name: setup
+ eos_config:
+ lines: hostname {{ inventory_hostname_short }}
+ match: none
+ provider: "{{ eapi }}"
+
+- name: get current running-config
+ eos_command:
+ commands: show running-config
+ provider: "{{ eapi }}"
+ register: config
+
+- name: configure hostname
+ eos_config:
+ lines: hostname foo
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: get current running-config
+ eos_command:
+ commands: show running-config
+ provider: "{{ eapi }}"
+ register: config
+
+- name: teardown
+ eos_config:
+ lines: hostname {{ inventory_hostname_short }}
+ match: none
+ provider: "{{ eapi }}"
+
+# hit block and diffs
+
+- name: setup
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: strict
+ provider: "{{ eapi }}"
+
+- name: configure sub level command using block resplace
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ replace: block
+ after: exit
+ provider: "{{ eapi }}"
+ match: line
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ip host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ip host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ip host 4.4.4.4 any log' in result.updates"
+
+- name: check sub level command using block replace
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ replace: block
+ after: exit
+ provider: "{{ eapi }}"
+ match: exact
+ register: result
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml b/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml
new file mode 100644
index 0000000000..7d916adc06
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml
@@ -0,0 +1,66 @@
+---
+# eos_static_route -> remove_default_spec, validate_ip_address, validate_prefix
+# eos_interface -> conditional
+# eos_command -> ComplexList
+
+- debug: msg="START cli/common_utils.yaml on connection={{ ansible_connection }}"
+
+# hit remove_default_spec() validate_ip_address() validate_prefix() ComplexList
+- name: setup - remove config used in test
+ eos_config:
+ lines:
+ - no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
+ provider: "{{ eapi }}"
+
+- name: configure static route
+ eos_static_route:
+ address: 192.168.3.0/24
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands"
+
+- name: configure static route
+ eos_static_route:
+ address: 192.168.3.0/250
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ eapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- name: teardown
+ eos_config:
+ lines:
+ - no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
+ provider: "{{ eapi }}"
+
+- debug: msg="END cli/common_utils.yaml on connection={{ ansible_connection }}"
+
+# hit conditional()
+- name: Set test interface
+ set_fact:
+ test_interface_1: ethernet1
+
+- name: Check intent arguments
+ eos_interface:
+ name: "{{ test_interface_1 }}"
+ state: up
+ tx_rate: ge(0)
+ rx_rate: ge(0)
+ authorize: yes
+ provider: "{{ eapi }}"
+ register: result
diff --git a/test/integration/targets/eos_smoke/tests/eapi/misc_tests.yaml b/test/integration/targets/eos_smoke/tests/eapi/misc_tests.yaml
new file mode 100644
index 0000000000..9d089f7afc
--- /dev/null
+++ b/test/integration/targets/eos_smoke/tests/eapi/misc_tests.yaml
@@ -0,0 +1,26 @@
+---
+- debug: msg="START cli/misc_tests.yaml on connection={{ ansible_connection }}"
+
+
+# test become and unbecome
+- block:
+ - name: command that does require become (should fail)
+ eos_command:
+ commands: show running-config
+ provider: "{{ eapi }}"
+ become: no
+ ignore_errors: yes
+ register: result
+
+ - assert:
+ that:
+ - 'result.failed == true'
+ - '"privileged mode required" in result.module_stderr'
+
+ - name: command that doesn't require become
+ eos_command:
+ commands: show uptime
+ provider: "{{ eapi }}"
+ become: no
+
+ when: "ansible_connection != 'local'"