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

Add ios smoke tests #35972

Merged
merged 4 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/integration/targets/ios_smoke/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []
2 changes: 2 additions & 0 deletions test/integration/targets/ios_smoke/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- prepare_ios_tests
22 changes: 22 additions & 0 deletions test/integration/targets/ios_smoke/tasks/cli.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
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"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
2 changes: 2 additions & 0 deletions test/integration/targets/ios_smoke/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- { include: cli.yaml, tags: ['cli'] }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface Loopback999
description this is a test
no shutdown

212 changes: 212 additions & 0 deletions test/integration/targets/ios_smoke/tests/cli/common_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# ios_linkagg -> CustomNetworkConfig
# ios_config -> dumps, NetworkConfig

- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}"

# Hit NetworkConfig
- name: set hostname
ios_config:
lines: ['hostname ios-smoke']
match: none
provider: "{{ cli }}"

- name: hit diff_ignore_lines
ios_config:
lines: ['hostname ios-smoke-diff']
diff_ignore_lines:
- hostname ios-smoke
save_when: modified
provider: "{{ cli }}"

- name: return hostname
ios_config:
lines: ['hostname {{ shorter_hostname }}']
match: none
provider: "{{ cli }}"

- name: hit items with parents
ios_config:
lines: ['permit ip any any log']
parents: ['ip access-list extended test']
provider: "{{ cli }}"
match: exact
register: result

- name: teardown
ios_config:
lines:
- 'no ip access-list extended test'
match: none
provider: "{{ cli }}"

- name: setup test NetworkConfig.difference, replace=block
ios_config:
lines:
- permit ip host 1.1.1.1 any log
- permit ip host 2.2.2.2 any log
- permit ip host 3.3.3.3 any log
parents: ['ip access-list extended test']
before: ['no ip access-list extended test']
after: ['exit']
provider: "{{ cli }}"
match: none

- name: test NetworkConfig.difference, replace=block
ios_config:
lines:
- permit ip host 1.1.1.1 any log
- permit ip host 2.2.2.2 any log
- permit ip host 3.3.3.3 any log
- permit ip host 4.4.4.4 any log
parents: ['ip access-list extended test']
replace: block
after: ['exit']
provider: "{{ cli }}"
register: result

- assert:
that:
- "result.changed == true"
- "'ip access-list extended test' in result.updates"
- "'permit ip host 1.1.1.1 any log' in result.updates"
- "'permit ip host 2.2.2.2 any log' in result.updates"
- "'permit ip host 3.3.3.3 any log' in result.updates"
- "'permit ip host 4.4.4.4 any log' in result.updates"

- name: teardown- NetworkConfig.difference, replace=block
ios_config:
lines:
- no ip access-list extended test
match: none
provider: "{{ cli }}"

# CustomNetworkConfig
# currently gets skipped because switch_type != 'L2'
- set_fact: switch_type="{{ switch_type }}"

- block:

- name: setup - remove config used in test(part1)
ios_config:
lines:
- no interface port-channel 20
provider: "{{ cli }}"
ignore_errors: yes

- name: setup - remove config used in test(part2)
ios_config:
lines:
- no interface port-channel 5
provider: "{{ cli }}"
ignore_errors: yes

- name: setup - remove config used in test(part3)
ios_config:
lines:
- no channel-group 20 mode active
provider: "{{ cli }}"
parents: "{{ item }}"
loop:
- interface GigabitEthernet0/1
- interface GigabitEthernet0/2

- name: create linkagg
ios_linkagg: &create
group: 20
state: present
provider: "{{ cli }}"
register: result

- assert:
that:
- "result.changed == true"
- "'interface port-channel 20' in result.commands"

- name: set link aggregation group to members
ios_linkagg: &configure_member
group: 20
mode: active
members:
- GigabitEthernet0/1
- GigabitEthernet0/2
provider: "{{ cli }}"
register: result

- assert:
that:
- "result.changed == true"
- "'interface GigabitEthernet0/1' in result.commands"
- "'channel-group 20 mode active' in result.commands"
- "'interface GigabitEthernet0/2' in result.commands"
- "'channel-group 20 mode active' in result.commands"

- name: remove link aggregation group from member
ios_linkagg: &remove_member
group: 20
mode: active
members:
- GigabitEthernet0/2
provider: "{{ cli }}"
register: result

- assert:
that:
- "result.changed == true"
- "'interface GigabitEthernet0/1' in result.commands"
- "'no channel-group 20 mode active' in result.commands"

- name: remove linkagg
ios_linkagg: &remove
group: 20
state: absent
provider: "{{ cli }}"
register: result

- assert:
that:
- "result.changed == true"
- "'no interface port-channel 20' in result.commands"

- name: create aggregate of linkagg definitions
ios_linkagg: &create_agg
aggregate:
- { group: 5 }
- { group: 20, mode: active, members: ['GigabitEthernet0/1'] }
provider: "{{ cli }}"
register: result

- assert:
that:
- "result.changed == true"
- "'interface port-channel 5' in result.commands"
- "'interface port-channel 20' in result.commands"
- "'interface GigabitEthernet0/1' in result.commands"
- "'channel-group 20 mode active' in result.commands"

- name: teardown(part1)
ios_config:
lines:
- no interface port-channel 20
provider: "{{ cli }}"
ignore_errors: yes

- name: teardown(part2)
ios_config:
lines:
- no interface port-channel 5
provider: "{{ cli }}"
ignore_errors: yes

- name: teardown(part3)
ios_config:
lines:
- no channel-group 20 mode active
provider: "{{ cli }}"
parents: "{{ item }}"
loop:
- interface GigabitEthernet0/1
- interface GigabitEthernet0/2

when: switch_type == 'L2'

- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}"