ansible/test/integration/targets/nxos_lag_interfaces/tests/cli/replaced.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

78 lines
1.7 KiB
YAML

---
- debug:
msg: "Start nxos_lag_interfaces replaced 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_config:
lines:
- no interface port-channel 10
- no interface port-channel 11
ignore_errors: yes
- name: setup2
nxos_lag_interfaces: &remove_lags
state: deleted
- block:
- name: setup3
nxos_config:
lines:
- "channel-group 10"
parents: "{{ item }}"
ignore_errors: yes
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: Replaced
nxos_lag_interfaces: &replaced
config:
- name: port-channel11
members:
- member: "{{ test_int2 }}"
mode: active
state: replaced
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:
- "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0"
- name: Idempotence - Replaced
nxos_lag_interfaces: *replaced
register: result
- assert:
that:
- "result.changed == false"
always:
- name: teardown1
nxos_lag_interfaces: *remove_lags
ignore_errors: yes
- name: disable feature lacp
nxos_feature:
feature: lacp
state: disabled