From 3ff8f9735fd9bd83b5eeedc3c7a9fd4bc5b6da84 Mon Sep 17 00:00:00 2001 From: GomathiselviS Date: Tue, 20 Jul 2021 11:37:14 -0400 Subject: [PATCH] Fix cleanup issues in integration tests (#233) Fix cleanup issues in integration tests Signed-off-by: GomathiselviS gomathiselvi@gmail.com SUMMARY Fixes #234 The number of management interfaces differs across different target hosts. There is no point checking for the facts against a defined var, in cleanup tasks. The port channel configurations are not removed at the end of eos_lag interfaces test suite. This PR takes care of the cleanup. ISSUE TYPE Bugfix Pull Request Docs Pull Request Feature Pull Request New Module Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Rohit Thakur --- .../fragments/remove_expected_config.yml | 3 ++ test-requirements.txt | 1 + .../tests/common/_reset_config.yaml | 22 -------------- .../tests/common/deleted.yaml | 8 ----- .../tests/common/merged.yaml | 24 --------------- .../tests/common/overridden.yaml | 8 ----- .../tests/common/replaced.yaml | 9 ------ .../eos_l2_interfaces/tests/common/rtt.yaml | 25 ---------------- .../tests/common/_reset_config.yaml | 29 ------------------ .../tests/common/deleted.yaml | 8 ----- .../tests/common/merged.yaml | 29 ------------------ .../tests/common/overridden.yaml | 8 ----- .../tests/common/replaced.yaml | 8 ----- .../eos_l3_interfaces/tests/common/rtt.yaml | 30 ------------------- .../eos_lag_interfaces/tests/cli/deleted.yaml | 2 ++ .../eos_lag_interfaces/tests/cli/merged.yaml | 2 ++ .../tests/cli/overridden.yaml | 2 ++ .../tests/cli/replaced.yaml | 2 ++ 18 files changed, 12 insertions(+), 208 deletions(-) create mode 100644 changelogs/fragments/remove_expected_config.yml diff --git a/changelogs/fragments/remove_expected_config.yml b/changelogs/fragments/remove_expected_config.yml new file mode 100644 index 000000000..c6b308145 --- /dev/null +++ b/changelogs/fragments/remove_expected_config.yml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove expected_config var from cleanup in integration tests. diff --git a/test-requirements.txt b/test-requirements.txt index 5a390d307..896866767 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,6 @@ black ; python_version > '3.5' coverage==4.5.4 +cffi==1.14.5 flake8 mock ; python_version < '3.5' pexpect diff --git a/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml b/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml index 023c4cb78..60920ccdb 100644 --- a/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml +++ b/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml @@ -12,25 +12,3 @@ - " no switchport access vlan" - " switchport trunk native vlan 20" - " switchport mode trunk" - -- become: true - arista.eos.eos_facts: - gather_network_resources: l2_interfaces - -- set_fact: - expected_config: - - - name: Ethernet1 - access: - vlan: 20 - - - mode: trunk - name: Ethernet2 - trunk: - native_vlan: 20 - - - name: Management1 - -- assert: - that: - - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == [] diff --git a/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml b/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml index 936a4f5c9..63b1a215c 100644 --- a/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml @@ -32,11 +32,3 @@ that: - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == [] - -- set_fact: - expected_config: "{{ config }} + [{'name': 'Management1'}]" - -- assert: - that: - - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml b/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml index 50fc8a29f..da8bd03e0 100644 --- a/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml @@ -37,27 +37,3 @@ that: - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == [] - -- set_fact: - expected_config: - - - name: Ethernet1 - mode: trunk - access: - vlan: 20 - trunk: - native_vlan: 10 - - - name: Ethernet2 - mode: trunk - access: - vlan: 30 - trunk: - native_vlan: 20 - - - name: Management1 - -- assert: - that: - - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml b/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml index 1fa59e118..b5be4c1d9 100644 --- a/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml @@ -33,11 +33,3 @@ that: - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == [] - -- set_fact: - expected_config: "{{ config }} + [{'name': 'Ethernet1'}, {'name': 'Management1'}]" - -- assert: - that: - - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml b/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml index a866f305e..2cd81ed99 100644 --- a/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml @@ -35,12 +35,3 @@ that: - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == [] - -- set_fact: - expected_config: "{{ config }} + [{'mode': 'trunk', 'name': 'Ethernet2', 'trunk':\ - \ {'native_vlan': 20}}, {'name': 'Management1'}]" - -- assert: - that: - - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml b/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml index 6819f5b18..cac02d65d 100644 --- a/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml @@ -38,31 +38,6 @@ config: '{{ config2 }}' state: merged - -- set_fact: - expected_config: - - - name: Ethernet1 - mode: trunk - access: - vlan: 20 - trunk: - native_vlan: 10 - - - name: Ethernet2 - mode: trunk - access: - vlan: 30 - trunk: - native_vlan: 20 - - - name: Management1 - -- assert: - that: - - result.after|symmetric_difference(expected_config) - == [] - - name: Revert back to base config using facts round trip become: true register: revert diff --git a/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml b/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml index 957790055..ed2e17bb7 100644 --- a/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml +++ b/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml @@ -3,32 +3,3 @@ become: true arista.eos.eos_config: src: reset.cfg - -- become: true - arista.eos.eos_facts: - gather_network_resources: l3_interfaces - -- set_fact: - expected_config: - - - name: Ethernet1 - ipv4: - - - address: 192.0.2.12/24 - - - address: 203.0.113.27/31 - secondary: true - - - name: Ethernet2 - ipv6: - - - address: 2001:db8::1/64 - - - name: Management1 - ipv4: - - - address: dhcp - -- assert: - that: - - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == [] diff --git a/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml b/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml index 2e3c4a29c..5702e802a 100644 --- a/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml @@ -39,11 +39,3 @@ - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == [] become: true - -- set_fact: - expected_config: '{{ config + other_config }}' - -- assert: - that: - - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml b/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml index 034de19d8..f07602655 100644 --- a/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml @@ -39,32 +39,3 @@ - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == [] become: true - -- set_fact: - expected_config: - - - name: Ethernet1 - ipv4: - - - address: 198.51.100.14/24 - - - address: 203.0.113.27/31 - secondary: true - - - name: Ethernet2 - ipv4: - - - address: 203.0.113.227/31 - ipv6: - - - address: 2001:db8::1/64 - - - name: Management1 - ipv4: - - - address: dhcp - -- assert: - that: - - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml b/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml index 71358a31e..4d757af48 100644 --- a/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml @@ -45,11 +45,3 @@ - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == [] become: true - -- set_fact: - expected_config: '{{ config }}' - -- assert: - that: - - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml b/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml index 85d0dd5f6..fffc91ad1 100644 --- a/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml @@ -48,11 +48,3 @@ - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == [] become: true - -- set_fact: - expected_config: '{{ config + other_config }}' - -- assert: - that: - - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) - == [] diff --git a/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml b/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml index a97c5f828..d283148fc 100644 --- a/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml @@ -40,36 +40,6 @@ config: '{{ config2 }}' state: merged - -- set_fact: - expected_config: - - - name: Ethernet1 - ipv4: - - - address: 198.51.100.14/24 - - - address: 203.0.113.27/31 - secondary: true - - - name: Ethernet2 - ipv4: - - - address: 203.0.113.227/31 - ipv6: - - - address: 2001:db8::1/64 - - - name: Management1 - ipv4: - - - address: dhcp - -- assert: - that: - - result.after|symmetric_difference(expected_config) - == [] - - name: Revert back to base config using facts round trip become: true register: revert diff --git a/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml index 863f560bb..3fa710a9a 100644 --- a/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml @@ -29,3 +29,5 @@ - assert: that: - ansible_facts.network_resources.lag_interfaces == [] + +- include_tasks: _reset_config.yaml diff --git a/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml b/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml index 389c8069c..7e2b33424 100644 --- a/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml @@ -72,3 +72,5 @@ - result.failed == true - result.msg is defined - '"Cannot change mode" in result.module_stderr' + +- include_tasks: _reset_config.yaml diff --git a/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml index f7ca1ed26..149d7d1bc 100644 --- a/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml @@ -39,3 +39,5 @@ that: - ansible_facts.network_resources.lag_interfaces|symmetric_difference(config)|length == 0 + +- include_tasks: _reset_config.yaml diff --git a/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml index cc52accb4..083c19fc8 100644 --- a/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml @@ -49,3 +49,5 @@ that: - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0 + +- include_tasks: _reset_config.yaml