diff --git a/tests/integration/targets/nxos_vrf_address_family/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_vrf_address_family/tests/common/_populate_config.yaml index 94917e7b2..081e71cf0 100644 --- a/tests/integration/targets/nxos_vrf_address_family/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_vrf_address_family/tests/common/_populate_config.yaml @@ -16,3 +16,7 @@ lines: - vrf context temp match: none + +- name: Wait for 5 seconds + ansible.builtin.wait_for: + timeout: 5 diff --git a/tests/integration/targets/nxos_vrf_address_family/tests/common/overridden.yaml b/tests/integration/targets/nxos_vrf_address_family/tests/common/overridden.yaml new file mode 100644 index 000000000..945bf0d15 --- /dev/null +++ b/tests/integration/targets/nxos_vrf_address_family/tests/common/overridden.yaml @@ -0,0 +1,76 @@ +--- +- ansible.builtin.debug: + msg: START nxos_vrf_address_family overridden integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Override the provided configuration with the existing running configuration + cisco.nxos.nxos_vrf_address_family: &overridden + config: + - name: VRF1 + address_families: + - afi: ipv6 + 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 + - name: temp + address_families: + - afi: ipv4 + safi: unicast + route_target: + - import: 65512:200 + maximum: + max_routes: 1000 + export: + - map: "26" + - vrf: + allow_vpn: true + map_import: "46" + 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 before dicts are correctly generated + ansible.builtin.assert: + that: + - "{{ overridden['before'] == result['before'] }}" + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" + + - name: Idempotency check + cisco.nxos.nxos_vrf_address_family: *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 diff --git a/tests/integration/targets/nxos_vrf_address_family/vars/main.yaml b/tests/integration/targets/nxos_vrf_address_family/vars/main.yaml index be0d3b161..bcd04a6db 100644 --- a/tests/integration/targets/nxos_vrf_address_family/vars/main.yaml +++ b/tests/integration/targets/nxos_vrf_address_family/vars/main.yaml @@ -189,3 +189,67 @@ replaced: - import: 65512:200 safi: unicast name: temp +overridden: + after: + - address_families: + - afi: ipv4 + safi: unicast + - afi: ipv6 + export: + - map: "22" + - vrf: + allow_vpn: true + map_import: "44" + - vrf: + allow_vpn: true + maximum: + max_route_options: + threshold: + reinstall_threshold: 80 + threshold_value: 60 + max_routes: 500 + route_target: + - export: 65512:200 + safi: unicast + name: VRF1 + - address_families: + - afi: ipv4 + export: + - map: "26" + - vrf: + allow_vpn: true + map_import: "46" + maximum: + max_routes: 1000 + route_target: + - import: 65512:200 + safi: unicast + name: temp + before: + - address_families: + - afi: ipv4 + route_target: + - import: 64512:200 + safi: unicast + - afi: ipv6 + route_target: + - import: 554832:500 + safi: unicast + name: VRF1 + commands: + - vrf context VRF1 + - address-family ipv4 unicast + - no route-target import 64512:200 + - address-family ipv6 unicast + - maximum routes 500 60 reinstall 80 + - no route-target import 554832:500 + - route-target export 65512:200 + - export map 22 + - export vrf default map 44 allow-vpn + - export vrf allow-vpn + - vrf context temp + - address-family ipv4 unicast + - maximum routes 1000 + - route-target import 65512:200 + - export map 26 + - export vrf default map 46 allow-vpn