mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-30 04:49:09 -07:00
Fix nxos_vpc issues (#28188)
* fix for nxos_vpc issues * fix unit tests * clean documentation
This commit is contained in:
parent
1d13624eae
commit
d69440c4ef
11 changed files with 157 additions and 10 deletions
|
@ -168,6 +168,15 @@
|
|||
failed_modules: "{{ failed_modules }} + [ 'nxos_vrrp' ]"
|
||||
test_failed: true
|
||||
|
||||
- block:
|
||||
- include_role:
|
||||
name: nxos_vpc
|
||||
when: "limit_to in ['*', 'nxos_vpc']"
|
||||
rescue:
|
||||
- set_fact:
|
||||
failed_modules: "{{ failed_modules }} + [ 'nxos_vpc' ]"
|
||||
test_failed: true
|
||||
|
||||
- block:
|
||||
- include_role:
|
||||
name: nxos_vtp_domain
|
||||
|
|
2
test/integration/targets/nxos_vpc/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_vpc/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/nxos_vpc/meta/main.yml
Normal file
2
test/integration/targets/nxos_vpc/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
15
test/integration/targets/nxos_vpc/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_vpc/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
7
test/integration/targets/nxos_vpc/tasks/main.yaml
Normal file
7
test/integration/targets/nxos_vpc/tasks/main.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# Use block to ensure that both cli and nxapi tests
|
||||
# will run even if there are failures or errors.
|
||||
- block:
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
always:
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_vpc/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_vpc/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: collect all nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/nxapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: enable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- feature nxapi
|
||||
- nxapi http port 80
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- no feature nxapi
|
||||
provider: "{{ cli }}"
|
4
test/integration/targets/nxos_vpc/tests/cli/sanity.yaml
Normal file
4
test/integration/targets/nxos_vpc/tests/cli/sanity.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- set_fact: connection="{{ cli }}"
|
||||
|
||||
- import_tasks: targets/nxos_vpc/tests/common/sanity.yaml
|
81
test/integration/targets/nxos_vpc/tests/common/sanity.yaml
Normal file
81
test/integration/targets/nxos_vpc/tests/common/sanity.yaml
Normal file
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vpc sanity test"
|
||||
|
||||
- block:
|
||||
- name: enable feature vpc
|
||||
nxos_feature:
|
||||
feature: vpc
|
||||
state: enabled
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: Ensure ntc VRF exists on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: Configure vpc
|
||||
nxos_vpc: &conf_vpc
|
||||
state: present
|
||||
domain: 100
|
||||
role_priority: 500
|
||||
system_priority: 2000
|
||||
pkl_dest: 192.168.100.4
|
||||
pkl_src: 10.1.100.20
|
||||
pkl_vrf: ntc
|
||||
peer_gw: true
|
||||
delay_restore: 5
|
||||
auto_recovery: true
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: "Conf Idempotence"
|
||||
nxos_vpc: *conf_vpc
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: remove vpc
|
||||
nxos_vpc: &rem_vpc
|
||||
state: absent
|
||||
domain: 100
|
||||
role_priority: 32667
|
||||
system_priority: 2000
|
||||
pkl_dest: 192.168.100.4
|
||||
pkl_src: 10.1.100.20
|
||||
pkl_vrf: ntc
|
||||
peer_gw: true
|
||||
delay_restore: 5
|
||||
auto_recovery: false
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Remove Idempotence"
|
||||
nxos_vpc: *rem_vpc
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
always:
|
||||
- name: remove vrf
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
state: absent
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: disable feature vpc
|
||||
nxos_feature:
|
||||
feature: vpc
|
||||
state: disabled
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vpc sanity test"
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- set_fact: connection="{{ nxapi }}"
|
||||
|
||||
- import_tasks: targets/nxos_vpc/tests/common/sanity.yaml
|
Loading…
Add table
Add a link
Reference in a new issue