Migrate Network Tests into ansible/ansible (#18233)

* Docs Networking tests

* Copy networking tests from test-network-modules

* Networking transport settings - group_vars

* Network playbooks

* Debug should be off by default

* Update nxos.yaml

* Remove items from top level

* Use dependencies, not pre-tasks

* Remove trailing blank lines

* Remove backup files

* newlines
This commit is contained in:
John R Barker 2016-10-28 19:50:29 +01:00 committed by GitHub
commit e0cc7b3415
489 changed files with 13144 additions and 2 deletions

View file

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

View file

@ -0,0 +1,17 @@
---
- name: collect all cli test cases
find:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

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

View file

@ -0,0 +1,42 @@
---
- debug: msg="START cli/sublevel.yaml"
- name: setup test
dellos6_config:
lines:
- 'no ip access-list test'
provider: "{{ cli }}"
match: none
- name: configure sub level command
dellos6_config:
lines: ['1000 permit every log']
parents: ['ip access-list test']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'1000 permit every log' in result.updates"
- name: configure sub level command idempotent check
dellos6_config:
lines: ['1000 permit every log']
parents: ['ip access-list test']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
dellos6_config:
lines:
- 'no ip access-list test'
provider: "{{ cli }}"
match: none
- debug: msg="END cli/sublevel.yaml"

View file

@ -0,0 +1,62 @@
---
- debug: msg="START cli/sublevel_block.yaml"
- name: setup
dellos6_config:
lines:
- permit ip 1.1.1.1 0.0.0.0 any log
- permit ip 2.2.2.2 0.0.0.0 any log
- permit ip 3.3.3.3 0.0.0.0 any log
parents: ['ip access-list test']
before: ['no ip access-list test']
after: ['exit']
provider: "{{ cli }}"
match: none
- name: configure sub level command using block resplace
dellos6_config:
lines:
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
parents: ['ip access-list test']
replace: block
after: ['exit']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'1000 permit ip 1.1.1.1 0.0.0.0 any log' in result.updates"
- "'1010 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
- "'1020 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
- "'1030 permit ip 4.4.4.4 0.0.0.0 any log' in result.updates"
- name: check sub level command using block replace
dellos6_config:
lines:
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
parents: ['ip access-list test']
replace: block
after: ['exit']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
dellos6_config:
lines:
- no ip access-list test
match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_block.yaml"

View file

@ -0,0 +1,66 @@
---
- debug: msg="START cli/sublevel_exact.yaml"
- name: setup
dellos6_config:
lines:
- permit ip 1.1.1.1 0.0.0.0 any log
- permit ip 2.2.2.2 0.0.0.0 any log
- permit ip 3.3.3.3 0.0.0.0 any log
- permit ip 4.4.4.4 0.0.0.0 any log
- permit ip 5.5.5.5 0.0.0.0 any log
parents: ['ip access-list test']
before: ['no ip access-list test']
after: ['exit']
provider: "{{ cli }}"
match: none
- name: configure sub level command using exact match
dellos6_config:
lines:
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
parents: ['ip access-list test']
after: ['exit']
match: exact
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'1000 permit ip 1.1.1.1 0.0.0.0 any log' in result.updates"
- "'1010 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
- "'1020 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
- "'1030 permit ip 4.4.4.4 0.0.0.0 any log' in result.updates"
- "'1040 permit ip 5.5.5.5 0.0.0.0 any log' not in result.updates"
- name: check sub level command using exact match
dellos6_config:
lines:
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
- 1040 permit ip 5.5.5.5 0.0.0.0 any log
parents: ['ip access-list test']
after: ['exit']
match: exact
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
dellos6_config:
lines:
- no ip access-list test
provider: "{{ cli }}"
match: none
- debug: msg="END cli/sublevel_exact.yaml"

View file

@ -0,0 +1,63 @@
---
- debug: msg="START cli/sublevel_strict.yaml"
- name: setup
dellos6_config:
lines:
- permit ip 1.1.1.1 0.0.0.0 any log
- permit ip 2.2.2.2 0.0.0.0 any log
- permit ip 3.3.3.3 0.0.0.0 any log
- permit ip 4.4.4.4 0.0.0.0 any log
- permit ip 5.5.5.5 0.0.0.0 any log
parents: ['ip access-list test']
before: ['no ip access-list test']
after: ['exit']
provider: "{{ cli }}"
match: none
- name: configure sub level command using strict match
dellos6_config:
lines:
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
parents: ['ip access-list test']
match: strict
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: check sub level command using strict match
dellos6_config:
lines:
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
- 1010 permit ip 3.3.3.3 0.0.0.0 any log
- 1020 permit ip 2.2.2.2 0.0.0.0 any log
parents: ['ip access-list test']
after: ['exit']
match: strict
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'1000 permit ip 1.1.1.1 0.0.0.0 any log' not in result.updates"
- "'1020 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
- "'1010 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
- "'1030 permit ip 4.4.4.4 0.0.0.0 any log' not in result.updates"
- "'1040 permit ip 5.5.5.5 0.0.0.0 any log' not in result.updates"
- name: teardown
dellos6_config:
lines:
- no ip access-list test
provider: "{{ cli }}"
match: none
- debug: msg="END cli/sublevel_strict.yaml"

View file

@ -0,0 +1,37 @@
---
- debug: msg="START cli/toplevel.yaml"
- name: setup
dellos6_config:
lines: ['hostname {{ inventory_hostname }}']
provider: "{{ cli }}"
match: none
- name: configure top level command
dellos6_config:
lines: ['hostname foo']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- name: configure top level command idempotent check
dellos6_config:
lines: ['hostname "foo"']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
dellos6_config:
lines: ['hostname {{ inventory_hostname }}']
provider: "{{ cli }}"
match: none
- debug: msg="END cli/toplevel.yaml"

View file

@ -0,0 +1,44 @@
---
- debug: msg="START cli/toplevel_after.yaml"
- name: setup
dellos6_config:
lines:
- "snmp-server contact ansible"
- "hostname {{ inventory_hostname }}"
provider: "{{ cli }}"
match: none
- name: configure top level command with before
dellos6_config:
lines: ['hostname foo']
after: ['snmp-server contact bar']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- "'snmp-server contact bar' in result.updates"
- name: configure top level command with before idempotent check
dellos6_config:
lines: ['hostname "foo"']
after: ['snmp-server contact foo']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
dellos6_config:
lines:
- "no snmp-server contact"
- "hostname {{ inventory_hostname }}"
provider: "{{ cli }}"
match: none
- debug: msg="END cli/toplevel_after.yaml"

View file

@ -0,0 +1,44 @@
---
- debug: msg="START cli/toplevel_before.yaml"
- name: setup
dellos6_config:
lines:
- "snmp-server contact ansible"
- "hostname {{ inventory_hostname }}"
provider: "{{ cli }}"
match: none
- name: configure top level command with before
dellos6_config:
lines: ['hostname foo']
before: ['snmp-server contact bar']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- "'snmp-server contact bar' in result.updates"
- name: configure top level command with before idempotent check
dellos6_config:
lines: ['hostname "foo"']
before: ['snmp-server contact foo']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
dellos6_config:
lines:
- "no snmp-server contact"
- "hostname {{ inventory_hostname }}"
provider: "{{ cli }}"
match: none
- debug: msg="END cli/toplevel_before.yaml"

View file

@ -0,0 +1,39 @@
---
- debug: msg="START cli/toplevel_nonidempotent.yaml"
- name: setup
dellos6_config:
lines: ['hostname {{ inventory_hostname }}']
provider: "{{ cli }}"
match: none
- name: configure top level command
dellos6_config:
lines: ['hostname foo']
provider: "{{ cli }}"
match: strict
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- name: configure top level command idempotent check
dellos6_config:
lines: ['hostname foo']
provider: "{{ cli }}"
match: strict
register: result
- assert:
that:
- "result.changed == true"
- name: teardown
dellos6_config:
lines: ['hostname {{ inventory_hostname }}']
provider: "{{ cli }}"
match: none
- debug: msg="END cli/toplevel_nonidempotent.yaml"