1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

iosxr tests: Initial work for 2.3 (#20883)

Ensure a loopback device exists for testing
Remove provider:
Default is to run task on Network, device, use delegate_to: localhost for local tasks.
This commit is contained in:
John R Barker 2017-01-31 19:10:14 +00:00 committed by GitHub
parent e6f92bc3a9
commit 553b6151ad
38 changed files with 30 additions and 70 deletions

View file

@ -1,7 +1,6 @@
--- ---
- hosts: iosxr - hosts: iosxr
gather_facts: no gather_facts: no
connection: local
vars: vars:
limit_to: "*" limit_to: "*"

View file

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

View file

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

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -8,7 +8,6 @@
- show interfaces GigabitEthernet 0/0 - show interfaces GigabitEthernet 0/0
wait_for: wait_for:
- "result[0] contains 'Description: Foo'" - "result[0] contains 'Description: Foo'"
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -9,7 +9,6 @@
wait_for: wait_for:
- "result[0] contains 6.0.0" - "result[0] contains 6.0.0"
- "result[1] contains GigabitEthernet0/0/0/1" - "result[1] contains GigabitEthernet0/0/0/1"
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -4,7 +4,6 @@
- name: run invalid command - name: run invalid command
iosxr_command: iosxr_command:
commands: ['show foo'] commands: ['show foo']
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes
@ -17,7 +16,6 @@
commands: commands:
- show version - show version
- show foo - show foo
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -4,7 +4,6 @@
- name: get output for single command - name: get output for single command
iosxr_command: iosxr_command:
commands: ['show version'] commands: ['show version']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -17,7 +16,6 @@
commands: commands:
- show version - show version
- show interfaces - show interfaces
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -7,7 +7,6 @@
- show version - show version
wait_for: wait_for:
- "result[0] contains bad_value_string" - "result[0] contains bad_value_string"
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

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

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -9,7 +9,6 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: collect any backup files - name: collect any backup files
find: find:
@ -28,7 +27,6 @@
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
backup: yes backup: yes
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -9,13 +9,11 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
# Defend against https://github.com/ansible/ansible-modules-core/issues/5146 # Defend against https://github.com/ansible/ansible-modules-core/issues/5146
- name: Commit message too long - name: Commit message too long
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
comment: "this is a really long message aaaaabbbbbbcdde end-of-message" comment: "this is a really long message aaaaabbbbbbcdde end-of-message"
register: result register: result
ignore_errors: true ignore_errors: true

View file

@ -9,12 +9,10 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with comment - name: configure device with comment
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
comment: "this is sensible commit message" comment: "this is sensible commit message"
register: result register: result
@ -26,7 +24,6 @@
- name: check device with config - name: check device with config
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -9,12 +9,10 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +24,6 @@
- name: check device with config - name: check device with config
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -6,7 +6,6 @@
- name: configure with invalid src - name: configure with invalid src
iosxr_config: iosxr_config:
src: basic/foobar.j2 src: basic/foobar.j2
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -9,12 +9,10 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
match: none match: none
register: result register: result
@ -27,7 +25,6 @@
- name: check device with config - name: check device with config
iosxr_config: iosxr_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -4,7 +4,6 @@
- name: setup - name: setup
iosxr_config: iosxr_config:
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
provider: "{{ cli }}"
match: none match: none
ignore_errors: yes ignore_errors: yes
@ -12,7 +11,6 @@
iosxr_config: iosxr_config:
commands: ['10 permit ipv4 any any log'] commands: ['10 permit ipv4 any any log']
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -25,7 +23,6 @@
iosxr_config: iosxr_config:
commands: ['10 permit ipv4 any any log'] commands: ['10 permit ipv4 any any log']
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -35,7 +32,6 @@
- name: teardown - name: teardown
iosxr_config: iosxr_config:
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/sublevel.yaml" - debug: msg="END cli/sublevel.yaml"

View file

@ -10,7 +10,6 @@
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit'] after: ['exit']
provider: "{{ cli }}"
match: none match: none
- name: configure sub level command using block resplace - name: configure sub level command using block resplace
@ -23,7 +22,6 @@
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
replace: block replace: block
after: ['exit'] after: ['exit']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -45,7 +43,6 @@
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
replace: block replace: block
after: ['exit'] after: ['exit']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -55,7 +52,6 @@
- name: teardown - name: teardown
iosxr_config: iosxr_config:
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/sublevel_block.yaml" - debug: msg="END cli/sublevel_block.yaml"

View file

@ -13,7 +13,6 @@
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit'] after: ['exit']
match: none match: none
provider: "{{ cli }}"
- name: configure sub level command using exact match - name: configure sub level command using exact match
iosxr_config: iosxr_config:
@ -25,7 +24,6 @@
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
after: ['exit'] after: ['exit']
match: exact match: exact
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -49,7 +47,6 @@
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
after: ['exit'] after: ['exit']
match: exact match: exact
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -59,7 +56,6 @@
- name: teardown - name: teardown
iosxr_config: iosxr_config:
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/sublevel_exact.yaml" - debug: msg="END cli/sublevel_exact.yaml"

View file

@ -13,7 +13,6 @@
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit'] after: ['exit']
match: none match: none
provider: "{{ cli }}"
- name: configure sub level command using strict match - name: configure sub level command using strict match
iosxr_config: iosxr_config:
@ -27,7 +26,6 @@
after: ['exit'] after: ['exit']
match: strict match: strict
replace: block replace: block
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -50,7 +48,6 @@
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
after: ['exit'] after: ['exit']
match: strict match: strict
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -61,6 +58,5 @@
iosxr_config: iosxr_config:
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_strict.yaml" - debug: msg="END cli/sublevel_strict.yaml"

View file

@ -4,13 +4,11 @@
- name: setup - name: setup
iosxr_config: iosxr_config:
commands: ['hostname {{ inventory_hostname_short }}'] commands: ['hostname {{ inventory_hostname_short }}']
provider: "{{ cli }}"
match: none match: none
- name: configure top level command - name: configure top level command
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -21,7 +19,6 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -31,7 +28,6 @@
- name: teardown - name: teardown
iosxr_config: iosxr_config:
commands: ['hostname {{ inventory_hostname_short }}'] commands: ['hostname {{ inventory_hostname_short }}']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel.yaml" - debug: msg="END cli/toplevel.yaml"

View file

@ -6,14 +6,12 @@
commands: commands:
- "no cdp" - "no cdp"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ inventory_hostname_short }}"
provider: "{{ cli }}"
match: none match: none
- name: configure top level command with before - name: configure top level command with before
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
after: ['cdp'] after: ['cdp']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +24,6 @@
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
after: ['no cdp'] after: ['no cdp']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -38,7 +35,6 @@
commands: commands:
- "no cdp" - "no cdp"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ inventory_hostname_short }}"
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel_after.yaml" - debug: msg="END cli/toplevel_after.yaml"

View file

@ -6,14 +6,12 @@
commands: commands:
- "no cdp" - "no cdp"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ inventory_hostname_short }}"
provider: "{{ cli }}"
match: none match: none
- name: configure top level command with before - name: configure top level command with before
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
before: ['cdp'] before: ['cdp']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +24,6 @@
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
before: ['cdp'] before: ['cdp']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -38,7 +35,6 @@
commands: commands:
- "no cdp" - "no cdp"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ inventory_hostname_short }}"
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel_before.yaml" - debug: msg="END cli/toplevel_before.yaml"

View file

@ -4,13 +4,11 @@
- name: setup - name: setup
iosxr_config: iosxr_config:
commands: ['hostname {{ inventory_hostname_short }}'] commands: ['hostname {{ inventory_hostname_short }}']
provider: "{{ cli }}"
match: none match: none
- name: configure top level command - name: configure top level command
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
provider: "{{ cli }}"
match: strict match: strict
register: result register: result
@ -22,7 +20,6 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
iosxr_config: iosxr_config:
commands: ['hostname foo'] commands: ['hostname foo']
provider: "{{ cli }}"
match: strict match: strict
register: result register: result
@ -33,7 +30,6 @@
- name: teardown - name: teardown
iosxr_config: iosxr_config:
commands: ['hostname {{ inventory_hostname_short }}'] commands: ['hostname {{ inventory_hostname_short }}']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel_nonidempotent.yaml" - debug: msg="END cli/toplevel_nonidempotent.yaml"

View file

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

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -4,7 +4,6 @@
- name: test getting all facts - name: test getting all facts
iosxr_facts: iosxr_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- all - all
register: result register: result

View file

@ -4,7 +4,6 @@
- name: test getting default facts - name: test getting default facts
iosxr_facts: iosxr_facts:
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -4,7 +4,6 @@
- name: test invalid subset (foobar) - name: test invalid subset (foobar)
iosxr_facts: iosxr_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- "foobar" - "foobar"
register: result register: result
@ -26,7 +25,6 @@
- name: test subset specified multiple times - name: test subset specified multiple times
iosxr_facts: iosxr_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- "!hardware" - "!hardware"
- "hardware" - "hardware"

View file

@ -4,7 +4,6 @@
- name: test not hardware - name: test not hardware
iosxr_facts: iosxr_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- "!hardware" - "!hardware"
register: result register: result

View file

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

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -6,7 +6,6 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: collect any backup files - name: collect any backup files
@ -26,7 +25,6 @@
iosxr_template: iosxr_template:
src: basic/config.j2 src: basic/config.j2
backup: yes backup: yes
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -50,6 +48,5 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/backup.yaml" - debug: msg="END cli/backup.yaml"

View file

@ -6,12 +6,10 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
iosxr_template: iosxr_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -22,7 +20,6 @@
- name: check device with config - name: check device with config
iosxr_template: iosxr_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -35,6 +32,5 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/basic.yaml" - debug: msg="END cli/basic.yaml"

View file

@ -6,12 +6,10 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
iosxr_template: iosxr_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
force: yes force: yes
register: result register: result
@ -23,7 +21,6 @@
- name: check device with config - name: check device with config
iosxr_template: iosxr_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
force: yes force: yes
register: result register: result
@ -37,6 +34,5 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/force.yaml" - debug: msg="END cli/force.yaml"

View file

@ -0,0 +1,12 @@
---
- name: Ensure we have loopback 888 for testing
iosxr_config:
src: config.j2
# Some AWS hostnames can be longer than those allowed by the system we are testing
# Truncate the hostname
# http://jinja.pocoo.org/docs/2.9/templates/#truncate
- set_fact:
shorter_hostname: '{{ inventory_hostname_short| truncate(10, True, "") }}'

View file

@ -0,0 +1,4 @@
interface Loopback888
description test for ansible
shutdown