-
Notifications
You must be signed in to change notification settings - Fork 109
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
17 changed files
with
419 additions
and
15 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
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
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/nxos_vrf_address_family/defaults/main.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,2 @@ | ||
--- | ||
testcase: "[^_].*" |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/nxos_vrf_address_family/meta/main.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,3 @@ | ||
--- | ||
dependencies: | ||
- prepare_nxos_tests |
21 changes: 21 additions & 0 deletions
21
tests/integration/targets/nxos_vrf_address_family/tasks/cli.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: Collect all CLI test cases | ||
ansible.builtin.find: | ||
paths: "{{ role_path }}/tests/common" | ||
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 |
5 changes: 5 additions & 0 deletions
5
tests/integration/targets/nxos_vrf_address_family/tasks/main.yml
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 |
10 changes: 10 additions & 0 deletions
10
tests/integration/targets/nxos_vrf_address_family/tests/common/_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,10 @@ | ||
vrf context VRF1 | ||
address-family ipv4 unicast | ||
route-target import 64512:200 | ||
route-target export 64512:200 | ||
export map 22 | ||
export vrf default map 44 allow-vpn | ||
export vrf allow-vpn | ||
maximum routes 900 22 reinstall 44 | ||
address-family ipv6 unicast | ||
route-target import 554832:500 |
18 changes: 18 additions & 0 deletions
18
tests/integration/targets/nxos_vrf_address_family/tests/common/_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,18 @@ | ||
--- | ||
- name: Merge provided vrf configuration with device configuration | ||
cisco.nxos.nxos_config: | ||
lines: | ||
- vrf context VRF1 | ||
- address-family ipv4 unicast | ||
- route-target import 64512:200 | ||
- address-family ipv6 unicast | ||
- route-target import 554832:500 | ||
match: none | ||
retries: 3 | ||
delay: 20 | ||
|
||
- name: Merge another vrf | ||
cisco.nxos.nxos_config: | ||
lines: | ||
- vrf context temp | ||
match: none |
24 changes: 24 additions & 0 deletions
24
tests/integration/targets/nxos_vrf_address_family/tests/common/_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,24 @@ | ||
--- | ||
- name: Remove VRF global configurations | ||
cisco.nxos.nxos_config: | ||
lines: | ||
- no vrf context VRF1 | ||
ignore_errors: true | ||
register: testvrf | ||
|
||
- name: Wait for 20 seconds if VRF removal was successful | ||
ansible.builtin.wait_for: | ||
timeout: 20 | ||
when: not testvrf.failed | ||
|
||
- name: Remove VRF global configurations | ||
cisco.nxos.nxos_config: | ||
lines: | ||
- no vrf context temp | ||
ignore_errors: true | ||
register: temp | ||
|
||
- name: Wait for 20 seconds if VRF removal was successful | ||
ansible.builtin.wait_for: | ||
timeout: 20 | ||
when: not temp.failed |
72 changes: 72 additions & 0 deletions
72
tests/integration/targets/nxos_vrf_address_family/tests/common/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,72 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: Start Deleted integration state for nxos_vrf_address_family ansible_connection={{ ansible_connection }} | ||
|
||
- ansible.builtin.include_tasks: _remove_config.yaml | ||
|
||
- block: | ||
- name: Merge config to be deleted with the existing running configuration | ||
cisco.nxos.nxos_config: | ||
lines: | ||
- route-target import 64512:200 | ||
- route-target export 64512:200 | ||
- export map 22 | ||
- export vrf default map 44 allow-vpn | ||
- export vrf allow-vpn | ||
- maximum routes 900 22 reinstall 44 | ||
parents: | ||
- vrf context VRF1 | ||
- address-family ipv4 unicast | ||
retries: 2 | ||
delay: 10 | ||
|
||
- name: Delete given vrf address family configuration | ||
register: result | ||
cisco.nxos.nxos_vrf_address_family: &id001 | ||
config: | ||
- name: VRF1 | ||
address_families: | ||
- afi: ipv4 | ||
safi: unicast | ||
route_target: | ||
- import: 64512:200 | ||
export: | ||
- map: "22" | ||
maximum: | ||
max_routes: 900 | ||
max_route_options: | ||
threshold: | ||
threshold_value: 22 | ||
reinstall_threshold: 44 | ||
state: deleted | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.changed == true | ||
|
||
- name: Assert that correct set of commands were generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}" | ||
|
||
- name: Assert that before dicts are correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ general['after'] | symmetric_difference(res_before['before']) | length == 0 }}" | ||
|
||
- name: Assert that after dicts are correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- deleted['after'] == res_after['after'] | ||
|
||
- name: Delete provided VRF global (idempotent) | ||
register: result | ||
cisco.nxos.nxos_vrf_address_family: *id001 | ||
|
||
- name: Assert that the previous task was idempotent | ||
ansible.builtin.assert: | ||
that: | ||
- result.changed == false | ||
|
||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
68 changes: 68 additions & 0 deletions
68
tests/integration/targets/nxos_vrf_address_family/tests/common/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,68 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START nxos_vrf_address_family 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.nxos.nxos_vrf_address_family: | ||
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.nxos.nxos_vrf_address_family: | ||
config: | ||
state: replaced | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of config parameter must not be empty for state replaced' | ||
|
||
- name: Overridden with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.nxos.nxos_vrf_address_family: | ||
config: | ||
state: overridden | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of config parameter must not be empty for state overridden' | ||
|
||
- name: Rendered with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.nxos.nxos_vrf_address_family: | ||
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.nxos.nxos_vrf_address_family: | ||
running_config: | ||
state: parsed | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.msg == 'value of running_config parameter must not be empty for state parsed' | ||
|
||
- name: Purged with empty configuration should give appropriate error message | ||
register: result | ||
ignore_errors: true | ||
cisco.nxos.nxos_vrf_address_family: | ||
config: | ||
state: purged | ||
|
||
- ansible.builtin.debug: | ||
msg: END nxos_vrf_address_family empty_config integration tests on connection={{ ansible_connection }} |
22 changes: 22 additions & 0 deletions
22
tests/integration/targets/nxos_vrf_address_family/tests/common/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,22 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START nxos_vrf_address_family 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.nxos.nxos_vrf_address_family: | ||
config: | ||
state: gathered | ||
|
||
- name: Assert gathered state | ||
ansible.builtin.assert: | ||
that: | ||
- result.changed == false | ||
- gathered == result['gathered'] | ||
|
||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
70 changes: 70 additions & 0 deletions
70
tests/integration/targets/nxos_vrf_address_family/tests/common/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,70 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START Merged nxos_vrf_address_family 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.nxos.nxos_vrf_address_family: &id001 | ||
config: | ||
- name: VRF1 | ||
address_families: | ||
- afi: ipv4 | ||
safi: unicast | ||
route_target: | ||
- export: "65512:200" | ||
maximum: | ||
max_routes: 500 | ||
max_route_options: | ||
threshold: | ||
threshold_value: 60 | ||
reinstall_threshold: 80 | ||
export: | ||
- map: "22" | ||
- vrf: | ||
allow_vpn: true | ||
map_import: "44" | ||
- vrf: | ||
allow_vpn: true | ||
- afi: ipv6 | ||
safi: unicast | ||
maximum: | ||
max_routes: 1000 | ||
route_target: | ||
- import: "65512:200" | ||
import: | ||
- map: "22" | ||
- vrf: | ||
advertise_vpn: true | ||
map_import: "44" | ||
- vrf: | ||
advertise_vpn: true | ||
state: merged | ||
|
||
- name: Assert that correct set of commands were generated | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ result['commands'] | symmetric_difference(merged['commands']) | length == 0 }}" | ||
|
||
- name: Assert that before dicts are correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- result['before'] == {} | ||
|
||
- name: Assert that after dict is correctly generated | ||
ansible.builtin.assert: | ||
that: | ||
- result['after'] == merged['after'] | ||
|
||
- name: Merge provided configuration with device configuration (idempotent) | ||
register: result | ||
cisco.nxos.nxos_vrf_address_family: *id001 | ||
|
||
- name: Assert that the previous task was idempotent | ||
ansible.builtin.assert: | ||
that: | ||
- result['changed'] == false | ||
always: | ||
- ansible.builtin.include_tasks: _remove_config.yaml |
14 changes: 14 additions & 0 deletions
14
tests/integration/targets/nxos_vrf_address_family/tests/common/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,14 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: START nxos_vrf_address_family parsed integration tests on connection={{ ansible_connection }} | ||
|
||
- name: Parse the commands for provided configuration | ||
register: result | ||
cisco.nxos.nxos_vrf_address_family: | ||
running_config: "{{ lookup('file', '_parsed.cfg') }}" | ||
state: parsed | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.changed == false | ||
- parsed == result['parsed'] |
Oops, something went wrong.