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

Fix vrf_interfaces test cases #924

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
ansible.builtin.assert:
that:
- not result.changed
- "{{ gathered['config'] | symmetric_difference(result['gathered']) |length == 0 }}"
- >
{{
result['gathered']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(gathered['config'])
| length == 0
}}
always:
- ansible.builtin.include_tasks: _remove_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@
- name: Assert that before dicts are correctly generated
ansible.builtin.assert:
that:
- "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
- >
{{
result['before']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(merged['before'])
| length == 0
}}

- name: Assert that after dict is correctly generated
ansible.builtin.assert:
that:
- "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
- >
{{
result['after']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(merged['after'])
| length == 0
}}

- name: Merge provided configuration with device configuration (idempotent)
register: result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@
- name: Assert that before dicts are correctly generated
ansible.builtin.assert:
that:
- overridden['before'] == result['before']
- >
{{
result['before']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(overridden['before'])
| length == 0
}}

- name: Assert that after dict is correctly generated
ansible.builtin.assert:
that:
- overridden['after'] == result['after']
- >
{{
result['after']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(overridden['after'])
| length == 0
}}

- name: Override provided configuration with device configuration (idempotent)
register: result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@
- name: Assert that before dicts are correctly generated
ansible.builtin.assert:
that:
- replaced['before'] == result['before']
- >
{{
result['before']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(replaced['before'])
| length == 0
}}

- name: Assert that after dict is correctly generated
ansible.builtin.assert:
that:
- replaced['after'] == result['after']
- >
{{
result['after']
| selectattr('name', 'in', 'Ethernet1/2,Ethernet1/6')
| symmetric_difference(replaced['after'])
| length == 0
}}

- name: Replace provided VRF interfaces configuration (idempotent)
register: result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- ansible.builtin.assert:
that:
- result.changed == true
- result.commands|symmetric_difference(overridden.commands) == []
- result.commands|symmetric_difference(rtt.commands_no_revert) == []

- name: Revert back to base configuration using facts round trip
register: revert
Expand Down
30 changes: 12 additions & 18 deletions tests/integration/targets/nxos_vrf_interfaces/vars/main.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
gathered:
config:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
- name: "Ethernet1/3"
- name: "Ethernet1/4"
vrf_name: "test"
- name: "Ethernet1/6"
vrf_name: "test2"

merged:
commands:
Expand All @@ -13,15 +13,11 @@ merged:
- interface Ethernet1/6
- vrf member test2
before:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
- name: "Ethernet1/3"
- name: "Ethernet1/6"
after:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
vrf_name: "test"
- name: "Ethernet1/3"
- name: "Ethernet1/6"
vrf_name: "test2"

Expand All @@ -32,24 +28,21 @@ overridden:
- interface Ethernet1/6
- vrf member VRF9
before:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
vrf_name: "vrf_B"
- name: "Ethernet1/3"
vrf_name: "test"
- name: "Ethernet1/6"
vrf_name: "test2"
after:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
vrf_name: "VRF8"
- name: "Ethernet1/3"
- name: "Ethernet1/6"
vrf_name: "VRF9"

parsed:
after:
- name: "Ethernet1/2"
vrf_name: "VRF1"
- name: "GigabitEthernet1/6"
- name: "Ethernet1/6"
vrf_name: "TEST_VRF"

replaced:
Expand All @@ -59,17 +52,13 @@ replaced:
- interface Ethernet1/6
- vrf member TEST_VRF3
before:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
vrf_name: "test"
- name: "Ethernet1/3"
- name: "Ethernet1/6"
vrf_name: "test2"
after:
- name: "Ethernet1/1"
- name: "Ethernet1/2"
vrf_name: "TEST_VRF2"
- name: "Ethernet1/3"
- name: "Ethernet1/6"
vrf_name: "TEST_VRF3"

Expand All @@ -93,7 +82,12 @@ deleted:

rtt:
commands:
- interface "Ethernet1/6"
- interface Ethernet1/6
- vrf member test
- interface Ethernet1/2
- no vrf member test2
commands_no_revert:
- interface Ethernet1/2
- vrf member test2
- interface Ethernet1/6
- no vrf member test
Loading