mirror of https://github.com/ansible/ansible.git
* added iosxr_smoke tests
* finalized netconf tests
* cleaning up files
(cherry picked from commit 38fa1d0b15
)
pull/38423/head
parent
4aafa90c89
commit
cbeadb2c9a
@ -0,0 +1,3 @@
|
||||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_iosxr_tests
|
@ -0,0 +1,24 @@
|
||||
---
|
||||
- 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 case (connection=network_cli)
|
||||
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
# Only one of the Testcase would be run to check if `connection: local`
|
||||
# is established. Full suite is run with `connection:network_cli` or `connection:netconf`
|
||||
- name: run test case (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_first_found: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
@ -0,0 +1,24 @@
|
||||
---
|
||||
- name: collect all netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
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=netconf)
|
||||
include: "{{ test_case_to_run }} ansible_connection=netconf"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
# Only one of the Testcase would be run to check if `connection: local`
|
||||
# is established. Full suite is run with `connection:network_cli` or `connection:netconf`
|
||||
- name: run test case (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_first_found: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
@ -0,0 +1,100 @@
|
||||
---
|
||||
- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Sublevel / Block
|
||||
- name: setup
|
||||
iosxr_config:
|
||||
commands:
|
||||
- 10 permit ipv4 host 1.1.1.1 any log
|
||||
- 20 permit ipv4 host 2.2.2.2 any log
|
||||
- 30 permit ipv4 host 3.3.3.3 any log
|
||||
parents: ['ipv4 access-list test']
|
||||
before: ['no ipv4 access-list test']
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using block resplace
|
||||
iosxr_config:
|
||||
commands:
|
||||
- 10 permit ipv4 host 1.1.1.1 any log
|
||||
- 20 permit ipv4 host 2.2.2.2 any log
|
||||
- 30 permit ipv4 host 3.3.3.3 any log
|
||||
- 40 permit ipv4 host 4.4.4.4 any log
|
||||
parents: ['ipv4 access-list test']
|
||||
replace: block
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ipv4 access-list test' in result.commands"
|
||||
- "'10 permit ipv4 host 1.1.1.1 any log' in result.commands"
|
||||
- "'20 permit ipv4 host 2.2.2.2 any log' in result.commands"
|
||||
- "'30 permit ipv4 host 3.3.3.3 any log' in result.commands"
|
||||
- "'40 permit ipv4 host 4.4.4.4 any log' in result.commands"
|
||||
|
||||
- name: check sub level command using block replace
|
||||
iosxr_config:
|
||||
commands:
|
||||
- 10 permit ipv4 host 1.1.1.1 any log
|
||||
- 20 permit ipv4 host 2.2.2.2 any log
|
||||
- 30 permit ipv4 host 3.3.3.3 any log
|
||||
- 40 permit ipv4 host 4.4.4.4 any log
|
||||
parents: ['ipv4 access-list test']
|
||||
replace: block
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
iosxr_config:
|
||||
commands: ['no ipv4 access-list test']
|
||||
match: none
|
||||
|
||||
# diff exact, strict, line
|
||||
- name: setup
|
||||
iosxr_config:
|
||||
commands:
|
||||
- 'hostname {{ inventory_hostname_short }}'
|
||||
register: result
|
||||
|
||||
- name: set hostname
|
||||
iosxr_config:
|
||||
commands:
|
||||
- hostname testhost
|
||||
match: strict
|
||||
register: result
|
||||
|
||||
- iosxr_command:
|
||||
commands:
|
||||
- show configuration running-config hostname
|
||||
register: configured_hostname
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'testhost' in configured_hostname.stdout[0]"
|
||||
|
||||
- name: set hostname
|
||||
iosxr_config:
|
||||
commands:
|
||||
- hostname testhost2
|
||||
match: exact
|
||||
register: result
|
||||
|
||||
- iosxr_command:
|
||||
commands:
|
||||
- show configuration running-config hostname
|
||||
register: configured_hostname
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'testhost2' in configured_hostname.stdout[0]"
|
||||
|
||||
- name: teardown
|
||||
iosxr_config:
|
||||
commands:
|
||||
- 'hostname {{ inventory_hostname_short }}'
|
||||
register: result
|
||||
|
||||
- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,37 @@
|
||||
---
|
||||
- debug: msg="START iosxr cli/common_utils.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Functions used by iosxr: conditional, remove_default_spec
|
||||
|
||||
# hit conditional() and remove_default_spec()
|
||||
- name: Check intent arguments
|
||||
iosxr_interface:
|
||||
name: GigabitEthernet0/0/0/1
|
||||
state: up
|
||||
tx_rate: ge(0)
|
||||
rx_rate: ge(0)
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == false"
|
||||
|
||||
- name: Check intent arguments (failed condition)
|
||||
iosxr_interface:
|
||||
name: GigabitEthernet0/0/0/1
|
||||
state: down
|
||||
tx_rate: gt(0)
|
||||
rx_rate: lt(0)
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "'state eq(down)' in result.failed_conditions"
|
||||
- "'tx_rate gt(0)' in result.failed_conditions"
|
||||
- "'rx_rate lt(0)' in result.failed_conditions"
|
||||
|
||||
- debug: msg="END iosxr cli/common_utils.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,53 @@
|
||||
---
|
||||
- debug: msg="START iosxr netconf/common_netconf.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# hit general code
|
||||
- name: setup - remove login
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
provider: "{{ netconf }}"
|
||||
state: absent
|
||||
|
||||
- name: Set login
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
text: |
|
||||
this is my login banner
|
||||
that has a multiline
|
||||
string
|
||||
provider: "{{ netconf }}"
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'this is my login banner' in result.xml"
|
||||
- "'that has a multiline' in result.xml"
|
||||
|
||||
# hit etree_findall()
|
||||
- name: remove host logging
|
||||
iosxr_logging:
|
||||
dest: host
|
||||
name: 172.16.0.1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: set up syslog host logging
|
||||
iosxr_logging: &addhostlog
|
||||
dest: host
|
||||
name: 172.16.0.1
|
||||
level: errors
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"172.16.0.1" in result.xml[0]'
|
||||
|
||||
- debug: msg="END iosxr netconf/common_netconf.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,39 @@
|
||||
- debug: msg="START iosxr netconf/misc_tests.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
|
||||
# hit module_utils.network.iosxr -> get_oper()
|
||||
- name: Setup (interface is up)
|
||||
iosxr_interface:
|
||||
name: GigabitEthernet0/0/0/1
|
||||
description: test_interface_1
|
||||
enabled: True
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Check intent arguments
|
||||
iosxr_interface:
|
||||
name: GigabitEthernet0/0/0/1
|
||||
state: up
|
||||
delay: 10
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == false"
|
||||
|
||||
- name: Check intent arguments (failed condition)
|
||||
iosxr_interface:
|
||||
name: GigabitEthernet0/0/0/1
|
||||
state: down
|
||||
provider: "{{ netconf }}"
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "'state eq(down)' in result.failed_conditions"
|
||||
|
||||
- debug: msg="END iosxr netconf/misc_tests.yaml on connection={{ ansible_connection }}"
|
Loading…
Reference in New Issue