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
This commit is contained in:
David Newswanger 2018-04-06 08:16:07 -04:00 committed by GitHub
parent 49aac5f8c7
commit 712d30f46c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 442 additions and 0 deletions

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_eos_tests

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: eapi.yaml, tags: ['eapi'] }

View file

@ -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 }}"

View file

@ -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

View file

@ -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'"

View file

@ -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 }}"

View file

@ -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

View file

@ -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'"