Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Network Tests into ansible/ansible #18233

Merged
merged 12 commits into from
Oct 28, 2016
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Integration test layer, constructed using playbooks.
Some tests may require cloud credentials, others will not, and destructive tests are separated from non-destructive so a subset
can be run on development machines.

Tests for network modules can be found in https://github.com/ansible/test-network-modules/

learn more
----------

Expand Down
13 changes: 13 additions & 0 deletions test/integration/asa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- hosts: asa
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: asa_command, when: "limit_to in ['*', 'asa_command']" }
- { role: asa_config, when: "limit_to in ['*', 'asa_config']" }
- { role: asa_acl, when: "limit_to in ['*', 'asa_acl']" }
13 changes: 13 additions & 0 deletions test/integration/dellos10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- hosts: dellos10
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: dellos10_command, when: "limit_to in ['*', 'dellos10_command']" }
- { role: dellos10_config, when: "limit_to in ['*', 'dellos10_config']" }
- { role: dellos10_facts, when: "limit_to in ['*', 'dellos10_facts']" }
13 changes: 13 additions & 0 deletions test/integration/dellos6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- hosts: dellos6
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: dellos6_command, when: "limit_to in ['*', 'dellos6_command']" }
- { role: dellos6_config, when: "limit_to in ['*', 'dellos6_config']" }
- { role: dellos6_facts, when: "limit_to in ['*', 'dellos6_facts']" }
13 changes: 13 additions & 0 deletions test/integration/dellos9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- hosts: dellos9
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: dellos9_command, when: "limit_to in ['*', 'dellos9_command']" }
- { role: dellos9_config, when: "limit_to in ['*', 'dellos9_config']" }
- { role: dellos9_facts, when: "limit_to in ['*', 'dellos9_facts']" }
15 changes: 15 additions & 0 deletions test/integration/eos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- hosts: eos
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: eos_command, when: "limit_to in ['*', 'eos_command']" }
- { role: eos_config, when: "limit_to in ['*', 'eos_config']" }
- { role: eos_template, when: "limit_to in ['*', 'eos_template']" }
- { role: eos_facts, when: "limit_to in ['*', 'eos_facts']" }
- { role: eos_eapi, debug: yes, when: "limit_to in ['*', 'eos_eapi']" }
8 changes: 8 additions & 0 deletions test/integration/group_vars/asa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
cli:
host: "{{ inventory_hostname }}"
username: "{{ asa_cli_user | default('cisco') }}"
password: "{{ asa_cli_pass | default('cisco') }}"
transport: cli
authorize: yes
auth_pass: "{{ asa_auth_pass | default('cisco') }}"
6 changes: 6 additions & 0 deletions test/integration/group_vars/dellos10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cli:
host: "{{ ansible_host }}"
username: "{{ dellos10_cli_user | default('admin') }}"
password: "{{ dellos10_cli_pass | default('admin') }}"
transport: cli
8 changes: 8 additions & 0 deletions test/integration/group_vars/dellos6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
cli:
host: "{{ ansible_host }}"
username: "{{ dellos_cli_user | default('admin') }}"
password: "{{ dellos_cli_pass | default('admin') }}"
authorize: true
auth_pass: "{{ dellos_cli_auth_pass | default('calvin') }}"
transport: cli
8 changes: 8 additions & 0 deletions test/integration/group_vars/dellos9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
cli:
host: "{{ ansible_host }}"
username: "{{ dellos9_cli_user | default('admin') }}"
password: "{{ dellos9_cli_pass | default('admin') }}"
authorize: true
auth_pass: "{{ dellos9_cli_en_pass | default('calvin') }}"
transport: cli
15 changes: 15 additions & 0 deletions test/integration/group_vars/eos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
cli:
host: "{{ ansible_host }}"
username: "{{ eos_cli_user | default('admin') }}"
password: "{{ eos_cli_pass | default('admin') }}"
transport: cli
authorize: yes

eapi:
host: "{{ ansible_host }}"
username: "{{ eos_eapi_user | default('admin') }}"
password: "{{ eos_eapi_pass | default('admin') }}"
transport: eapi
use_ssl: no
authorize: yes
6 changes: 6 additions & 0 deletions test/integration/group_vars/ios.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cli:
host: "{{ inventory_hostname }}"
username: "{{ ios_cli_user | default('cisco') }}"
password: "{{ ios_cli_pass | default('cisco') }}"
transport: cli
6 changes: 6 additions & 0 deletions test/integration/group_vars/iosxr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cli:
host: "{{ inventory_hostname }}"
username: "{{ iosxr_cli_user | default('root') }}"
password: "{{ iosxr_cli_pass | default('root') }}"
transport: cli
12 changes: 12 additions & 0 deletions test/integration/group_vars/junos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
netconf:
host: "{{ ansible_ssh_host }}"
username: "{{ junos_cli_user | default('ansible') }}"
password: "{{ junos_cli_pass | default('Ansible') }}"
transport: netconf

cli:
host: "{{ ansible_ssh_host }}"
username: "{{ junos_cli_user | default('ansible') }}"
password: "{{ junos_cli_pass | default('Ansible') }}"
transport: cli
13 changes: 13 additions & 0 deletions test/integration/group_vars/nxos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
cli:
host: "{{ inventory_hostname }}"
username: "{{ nxos_cli_user | default('admin') }}"
password: "{{ nxos_cli_pass | default('admin') }}"
transport: cli

nxapi:
host: "{{ inventory_hostname }}"
username: "{{ nxos_nxapi_user | default('admin') }}"
password: "{{ nxos_nxapi_pass | default('admin') }}"
transport: nxapi
use_ssl: no
6 changes: 6 additions & 0 deletions test/integration/group_vars/vyos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cli:
host: "{{ ansible_ssh_host }}"
username: vyos
password: vyos
transport: cli
14 changes: 14 additions & 0 deletions test/integration/ios.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- hosts: ios
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: ios_command, when: "limit_to in ['*', 'ios_command']" }
- { role: ios_config, when: "limit_to in ['*', 'ios_config']" }
- { role: ios_facts, when: "limit_to in ['*', 'ios_facts']" }
- { role: ios_template, when: "limit_to in ['*', 'ios_template']" }
14 changes: 14 additions & 0 deletions test/integration/iosxr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- hosts: iosxr
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: iosxr_command, when: "limit_to in ['*', 'iosxr_command']" }
- { role: iosxr_config, when: "limit_to in ['*', 'iosxr_config']" }
- { role: iosxr_facts, when: "limit_to in ['*', 'iosxr_facts']" }
- { role: iosxr_template, when: "limit_to in ['*', 'iosxr_template']" }
14 changes: 14 additions & 0 deletions test/integration/junos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- hosts: junos
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: junos_command, when: "limit_to in ['*', 'junos_command']" }
- { role: junos_config, when: "limit_to in ['*', 'junos_config']" }
- { role: junos_netconf, when: "limit_to in ['*', 'junos_netconf']" }
- { role: junos_template, when: "limit_to in ['*', 'junos_template']" }
10 changes: 10 additions & 0 deletions test/integration/network-all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- { include: asa.yaml }
- { include: eos.yaml }
- { include: ios.yaml }
- { include: iosxr.yaml }
- { include: nxos.yaml }
- { include: junos.yaml }
- { include: dellos10.yaml }
- { include: dellos9.yaml }
- { include: dellos6.yaml }
15 changes: 15 additions & 0 deletions test/integration/nxos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- hosts: nxos
gather_facts: no
connection: local

vars:
limit_to: "*"
debug: false

roles:
- { role: nxos_command, when: "limit_to in ['*', 'nxos_command']" }
- { role: nxos_config, when: "limit_to in ['*', 'nxos_config']" }
- { role: nxos_facts, when: "limit_to in ['*', 'nxos_facts']" }
- { role: nxos_template, when: "limit_to in ['*', 'nxos_template']" }
- { role: nxos_nxapi, when: "limit_to in ['*', 'nxos_nxapi']" }
3 changes: 3 additions & 0 deletions test/integration/targets/asa_acl/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []
16 changes: 16 additions & 0 deletions test/integration/targets/asa_acl/tasks/cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- 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
3 changes: 3 additions & 0 deletions test/integration/targets/asa_acl/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }

41 changes: 41 additions & 0 deletions test/integration/targets/asa_acl/tests/cli/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- debug: msg="START cli/basic.yaml"

- name: setup
asa_config:
commands:
- clear configure access-list ACL-BASIC
provider: "{{ cli }}"
ignore_errors: yes

- name: Basic ACL
asa_acl:
provider: "{{ cli }}"
lines:
- access-list ACL-BASIC extended permit tcp any any eq www
- access-list ACL-BASIC extended permit tcp any any eq https
register: result

- assert:
that:
- "result.changed == true"

- name: Basic ACL idempotency
asa_acl:
provider: "{{ cli }}"
lines:
- access-list ACL-BASIC extended permit tcp any any eq www
- access-list ACL-BASIC extended permit tcp any any eq https
register: result

- assert:
that:
- "result.changed == false"

- name: teardown
asa_config:
commands:
- clear configure access-list ACL-BASIC
provider: "{{ cli }}"

- debug: msg="END cli/basic.yaml"
43 changes: 43 additions & 0 deletions test/integration/targets/asa_acl/tests/cli/full_name_match.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- debug: msg="START cli/full_name_match.yaml"

- name: setup
asa_config:
commands:
- clear configure access-list ACL-BASIC
- clear configure access-list ACL-BASIC2
provider: "{{ cli }}"
ignore_errors: yes

- name: Basic ACL
asa_acl:
provider: "{{ cli }}"
lines:
- access-list ACL-BASIC2 extended permit tcp any any eq www
- access-list ACL-BASIC2 extended permit tcp any any eq https
register: result

- assert:
that:
- "result.changed == true"

- name: Should not match for ACL-BASIC2
asa_acl:
provider: "{{ cli }}"
lines:
- access-list ACL-BASIC extended permit tcp any any eq www
- access-list ACL-BASIC extended permit tcp any any eq https
register: result

- assert:
that:
- "result.changed == true"

- name: teardown
asa_config:
commands:
- clear configure access-list ACL-BASIC
- clear configure access-list ACL-BASIC2
provider: "{{ cli }}"

- debug: msg="END cli/full_name_match.yaml"