mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-18 15:09:09 -07:00
Fix nxos portchannel force option (#27190)
* Add integration tests * Fix force option * Enable nxos_portchannel test * Satisfy ansibot demands
This commit is contained in:
parent
fb2b3de5e4
commit
07b097af7c
10 changed files with 183 additions and 12 deletions
|
@ -204,6 +204,15 @@
|
|||
failed_modules: "{{ failed_modules }} + [ 'nxos_rollback' ]"
|
||||
test_failed: true
|
||||
|
||||
- block:
|
||||
- include_role:
|
||||
name: nxos_portchannel
|
||||
when: "limit_to in ['*', 'nxos_portchannel']"
|
||||
rescue:
|
||||
- set_fact:
|
||||
failed_modules: "{{ failed_modules }} + [ 'nxos_portchannel' ]"
|
||||
test_failed: true
|
||||
|
||||
- block:
|
||||
- include_role:
|
||||
name: nxos_logging
|
||||
|
@ -211,7 +220,6 @@
|
|||
rescue:
|
||||
- set_fact: test_failed=true
|
||||
|
||||
|
||||
###########
|
||||
- debug: var=failed_modules
|
||||
when: test_failed
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/nxos_portchannel/meta/main.yml
Normal file
2
test/integration/targets/nxos_portchannel/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
15
test/integration/targets/nxos_portchannel/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_portchannel/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
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_portchannel/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_portchannel/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 }}"
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- set_fact: connection="{{ cli }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
|
@ -0,0 +1,99 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_portchannel sanity test"
|
||||
|
||||
- set_fact: testint1="{{ nxos_int1 }}"
|
||||
- set_fact: testint2="{{ nxos_int2 }}"
|
||||
|
||||
- name: "Enable feature LACP"
|
||||
nxos_feature:
|
||||
feature: lacp
|
||||
state: enabled
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Put interface {{testint1}} into default state"
|
||||
nxos_config: &intdefault1
|
||||
lines:
|
||||
- "default interface {{ testint1 }}"
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Put interface {{testint2}} into default state"
|
||||
nxos_config: &intdefault2
|
||||
lines:
|
||||
- "default interface {{ testint2 }}"
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Remove possibly configured port-channel 99
|
||||
nxos_portchannel: &delpc
|
||||
group: 99
|
||||
members: ["{{ testint1 }}", "{{ testint2 }}"]
|
||||
force: 'true'
|
||||
state: absent
|
||||
timeout: 60
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- block:
|
||||
- name: Configure port-channel mode active
|
||||
nxos_portchannel: &configpc
|
||||
group: 99
|
||||
members: ["{{ testint1 }}", "{{ testint2 }}"]
|
||||
mode: active
|
||||
force: 'true'
|
||||
state: present
|
||||
timeout: 60
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Check Idempotence
|
||||
nxos_portchannel: *configpc
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Configure port-channel mode passive
|
||||
nxos_portchannel: &configpcpassive
|
||||
group: 99
|
||||
members: ["{{ testint1 }}", "{{ testint2 }}"]
|
||||
mode: passive
|
||||
force: 'true'
|
||||
state: present
|
||||
timeout: 60
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: Check Idempotence
|
||||
nxos_portchannel: *configpcpassive
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: Configure port-channel
|
||||
nxos_portchannel: *delpc
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
rescue:
|
||||
- name: "Disable feature LACP"
|
||||
nxos_feature:
|
||||
feature: lacp
|
||||
state: disabled
|
||||
timeout: 60
|
||||
provider: "{{ connection }}"
|
||||
|
||||
always:
|
||||
- name: Delete port-channel
|
||||
nxos_portchannel: *delpc
|
||||
register: result
|
||||
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_portchannel sanity test"
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- set_fact: connection="{{ nxapi }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
Loading…
Add table
Add a link
Reference in a new issue