Skip to content

Commit

Permalink
Fix cleanup issues in integration tests (#233)
Browse files Browse the repository at this point in the history
Fix  cleanup issues in integration tests

Signed-off-by: GomathiselviS [email protected]
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 <[email protected]>
  • Loading branch information
GomathiselviS authored Jul 20, 2021
1 parent c54f878 commit 3ff8f97
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 208 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/remove_expected_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- Remove expected_config var from cleanup in integration tests.
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
black ; python_version > '3.5'
coverage==4.5.4
cffi==1.14.5
flake8
mock ; python_version < '3.5'
pexpect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) == []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
25 changes: 0 additions & 25 deletions tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) == []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
Original file line number Diff line number Diff line change
Expand Up @@ -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)
== []
30 changes: 0 additions & 30 deletions tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
- assert:
that:
- ansible_facts.network_resources.lag_interfaces == []

- include_tasks: _reset_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@
- result.failed == true
- result.msg is defined
- '"Cannot change mode" in result.module_stderr'

- include_tasks: _reset_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@
that:
- ansible_facts.network_resources.lag_interfaces|symmetric_difference(config)|length
== 0

- include_tasks: _reset_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@
that:
- ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length
== 0

- include_tasks: _reset_config.yaml

0 comments on commit 3ff8f97

Please sign in to comment.