ansible/test/integration/targets/nxos_lag_interfaces/tests/cli/deleted.yaml
Chris Van Heuveln 008a95073d nxos_lag_interfaces: fix regression tests (#64119)
This is a change to the regression tests only. These tests were failing because of leftover device settings from previous tests:

- existing `channel-group` configurations on non-test interfaces were included in the before/after counts
  - fixed by using the `nxos_lag_interfaces` module with `state: deleted` to remove `channel-group` configur
ations from all interfaces

- existing `L2` `port-channel` interfaces with the same ID as the test `channel-group` ID may prevent configuring `channel-group` on the test ethernet interface
  - fixed by removing `port-channel` interfaces with the same ID; e.g.

```
  interface port-channel98
    switchport
    switchport mode trunk

  nx-1(config-if)# interface Ethernet1/19
  nx-1(config-if)# channel-group 98
command failed: port not compatible [switching port]
```

Fixes passed on `N6K,N7K,N9K,N3K` (internal TBs: `dt-n9k5-1,n6k-77,n7k-99,n7k-j,n3k-173,evergreen-nx-1,greensboro-nx-1,hamilton-nx-1,camden-nx-1`)
2019-11-06 15:45:19 +05:30

66 lines
1.4 KiB
YAML

---
- debug:
msg: "Start nxos_lag_interfaces deleted integration tests connection={{ ansible_connection }}"
- set_fact: test_int1="{{ nxos_int1 }}"
- set_fact: test_int2="{{ nxos_int2 }}"
- name: enable feature lacp
nxos_feature:
feature: lacp
- name: Setup1
nxos_lag_interfaces: &remove_lags
state: deleted
- block:
- name: Setup2
nxos_config:
lines:
- "channel-group 10"
parents: "{{ item }}"
loop:
- "interface {{ test_int1 }}"
- "interface {{ test_int2 }}"
- name: Gather LAG interfaces facts
nxos_facts: &facts
gather_subset:
- '!all'
- '!min'
gather_network_resources: lag_interfaces
- name: deleted
nxos_lag_interfaces: &deleted
state: deleted
register: result
- assert:
that:
- "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0"
- name: Gather LAG interfaces post facts
nxos_facts: *facts
- assert:
that:
- "result.after|length == 0"
- "result.changed == true"
- name: Idempotence - deleted
nxos_lag_interfaces: *deleted
register: result
- assert:
that:
- "result.changed == false"
always:
- name: Teardown
nxos_lag_interfaces: *remove_lags
ignore_errors: yes
- name: disable feature lacp
nxos_feature:
feature: lacp
state: disabled