-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
593 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
testcase: "[^_].*" | ||
test_items: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Collect all CLI test cases | ||
ansible.builtin.find: | ||
paths: "{{ role_path }}/tests/cli" | ||
patterns: "{{ testcase }}.yaml" | ||
use_regex: true | ||
register: test_cases | ||
delegate_to: localhost | ||
|
||
- name: Set test_items | ||
ansible.builtin.set_fact: | ||
test_items: "{{ test_cases.files | map(attribute='path') | list }}" | ||
delegate_to: localhost | ||
|
||
- name: Run test case (connection=ansible.netcommon.network_cli) | ||
ansible.builtin.include_tasks: "{{ test_case_to_run }}" | ||
vars: | ||
ansible_connection: ansible.netcommon.network_cli | ||
with_items: "{{ test_items }}" | ||
loop_control: | ||
loop_var: test_case_to_run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Main task for vrf_global module | ||
ansible.builtin.include_tasks: cli.yaml | ||
tags: | ||
- network_cli |
11 changes: 11 additions & 0 deletions
11
tests/integration/targets/ios_vrf_global/tests/cli/_parsed.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
vrf definition test | ||
vnet tag 34 | ||
description This is test VRF | ||
ipv4 multicast multitopology | ||
ipv6 multicast multitopology | ||
rd 10.2.3.4:300 | ||
vpn id 3:4 | ||
route-target export 23.1.3.4:400 | ||
route-target import 123.3.4.5:700 | ||
! | ||
end |
21 changes: 21 additions & 0 deletions
21
tests/integration/targets/ios_vrf_global/tests/cli/_populate_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Merge provided configuration with device configuration | ||
register: result | ||
cisco.ios.ios_vrf_global: | ||
config: | ||
- name: VRF2 | ||
description: This is a test VRF for merged state | ||
ipv4: | ||
multicast: | ||
multitopology: true | ||
ipv6: | ||
multicast: | ||
multitopology: true | ||
rd: "2:3" | ||
route_target: | ||
export: "23.1.3.4:400" | ||
import_config: "10.1.3.4:400" | ||
vpn: | ||
id: "2:45" | ||
vnet: | ||
tag: 200 |
5 changes: 5 additions & 0 deletions
5
tests/integration/targets/ios_vrf_global/tests/cli/_remove_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Remove VRF global configurations | ||
register: result | ||
cisco.ios.ios_vrf_global: | ||
state: purged |
36 changes: 36 additions & 0 deletions
36
tests/integration/targets/ios_vrf_global/tests/cli/deleted.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: Start Deleted integration state for ios_vrf_global ansible_connection={{ ansible_connection }} | ||
|
||
- ansible.builtin.include_tasks: _remove_config.yaml | ||
- ansible.builtin.include_tasks: _populate_config.yaml | ||
|
||
- block: | ||
- name: Delete given vrf configuration | ||
register: result | ||
cisco.ios.ios_vrf_global: &id001 | ||
config: | ||
state: deleted | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.commands|length == 1 | ||
- result.changed == true | ||
- "'no vrf definition test' not in result.commands" | ||
|
||
- name: Assert that after dicts are correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- deleted['after'] == result['after'] | ||
|
||
- name: Delete provided BGP global (idempotent) | ||
register: result | ||
cisco.ios.ios_vrf_global: *id001 | ||
|
||
- name: Assert that the previous task was idempotent | ||
ansible.builtin.assert: | ||
that: | ||
- result.changed == false | ||
|
||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
50 changes: 50 additions & 0 deletions
50
tests/integration/targets/ios_vrf_global/tests/cli/empty_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START ios_vrf_global empty_config.yaml integration tests on connection={{ ansible_connection }} | ||
|
||
- name: Merged with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.ios.ios_vrf_global: | ||
config: | ||
state: merged | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of config parameter must not be empty for state merged' | ||
|
||
- name: Replaced with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.ios.ios_vrf_global: | ||
config: | ||
state: replaced | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of config parameter must not be empty for state replaced' | ||
|
||
- name: Rendered with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.ios.ios_vrf_global: | ||
config: | ||
state: rendered | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of config parameter must not be empty for state rendered' | ||
|
||
- name: Parsed with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.ios.ios_vrf_global: | ||
running_config: | ||
state: parsed | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of running_config parameter must not be empty for state parsed' | ||
|
||
- ansible.builtin.debug: | ||
msg: END ios_vrf_global empty_config integration tests on connection={{ ansible_connection }} |
15 changes: 15 additions & 0 deletions
15
tests/integration/targets/ios_vrf_global/tests/cli/gathered.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START ios_vrf_global gathered integration tests on connection={{ ansible_connection }} | ||
|
||
- ansible.builtin.include_tasks: _remove_config.yaml | ||
- ansible.builtin.include_tasks: _populate_config.yaml | ||
|
||
- block: | ||
- name: Gather the provided configuration with the existing running configuration | ||
register: result | ||
cisco.ios.ios_vrf_global: | ||
state: gathered | ||
|
||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
53 changes: 53 additions & 0 deletions
53
tests/integration/targets/ios_vrf_global/tests/cli/merged.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START Merged ios_vrf_global state for integration tests on connection={{ ansible_connection }} | ||
|
||
- ansible.builtin.include_tasks: _remove_config.yaml | ||
|
||
- block: | ||
- name: Merge provided configuration with device configuration | ||
register: result | ||
cisco.ios.ios_vrf_global: &id001 | ||
config: | ||
- name: VRF2 | ||
description: This is a test VRF for merged state | ||
ipv4: | ||
multicast: | ||
multitopology: true | ||
ipv6: | ||
multicast: | ||
multitopology: true | ||
rd: "2:3" | ||
route_target: | ||
export: 23.1.3.4:400 | ||
import_config: 10.1.3.4:400 | ||
vpn: | ||
id: "2:45" | ||
vnet: | ||
tag: 200 | ||
state: merged | ||
|
||
- name: Assert that correct set of commands were generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}" | ||
|
||
- name: Assert that before dicts are correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- merged['before'] == {} | ||
|
||
- name: Assert that after dict is correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- merged['after'] == result['after'] | ||
|
||
- name: Merge provided configuration with device configuration (idempotent) | ||
register: result | ||
cisco.ios.ios_vrf_global: *id001 | ||
- name: Assert that the previous task was idempotent | ||
ansible.builtin.assert: | ||
that: | ||
- result['changed'] == false | ||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
58 changes: 58 additions & 0 deletions
58
tests/integration/targets/ios_vrf_global/tests/cli/overridden.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START ios_vrf_global overridden integration tests on connection={{ ansible_connection }} | ||
|
||
- ansible.builtin.include_tasks: _populate_config.yaml | ||
|
||
- ansible.builtin.include_tasks: _remove_config.yaml | ||
|
||
- block: | ||
- name: Override the provided configuration with the existing running configuration | ||
cisco.ios.ios_vrf_global: &overridden | ||
config: | ||
- name: VRF6 | ||
description: VRF6 description | ||
ipv4: | ||
multicast: | ||
multitopology: true | ||
ipv6: | ||
multicast: | ||
multitopology: true | ||
rd: "6:7" | ||
route_target: | ||
export: "3.1.3.4:400" | ||
import_config: "1.12.3.4:200" | ||
vpn: | ||
id: "4:5" | ||
vnet: | ||
tag: 500 | ||
state: overridden | ||
register: result | ||
|
||
- name: Assert that correct set of commands were generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}" | ||
|
||
- name: Assert that after dict is correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" | ||
|
||
- name: Idempotency check | ||
cisco.ios.ios_vrf_global: *overridden | ||
register: result | ||
|
||
- name: Assert that no changes were made | ||
ansible.builtin.assert: | ||
that: | ||
- result['changed'] == false | ||
- result.commands|length == 0 | ||
|
||
- name: Assert that before dict is correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" | ||
|
||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
13 changes: 13 additions & 0 deletions
13
tests/integration/targets/ios_vrf_global/tests/cli/parsed.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START ios_vrf_global parsed integration tests on connection={{ ansible_connection }} | ||
|
||
- name: Parse the commands for provided configuration | ||
register: result | ||
cisco.ios.ios_vrf_global: | ||
running_config: "{{ lookup('file', '_parsed.cfg') }}" | ||
state: parsed | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.changed == false |
29 changes: 29 additions & 0 deletions
29
tests/integration/targets/ios_vrf_global/tests/cli/purged.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: Start Deleted integration state for ios_vrf_global ansible_connection={{ ansible_connection }} | ||
|
||
- ansible.builtin.include_tasks: _remove_config.yaml | ||
- ansible.builtin.include_tasks: _populate_config.yaml | ||
|
||
- block: | ||
- name: Purge provided VRF global | ||
register: result | ||
cisco.ios.ios_vrf_global: &id001 | ||
state: purged | ||
|
||
- name: Assert that correct set of commands were generated | ||
ansible.builtin.assert: | ||
that: | ||
- "'no VRF definition VRF2' in result.commands" | ||
- result.commands|length == 1 | ||
|
||
- name: Purge provided VRF global (idempotent) | ||
register: result | ||
cisco.ios.ios_vrf_global: *id001 | ||
- name: Assert that the previous task was idempotent | ||
ansible.builtin.assert: | ||
that: | ||
- result.changed == false | ||
|
||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
Oops, something went wrong.