mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 12:33:59 -07:00
Fix snmp bugs on Nexus 3500 platform (#32773)
* Add n35 platform support * Fix regex bug and add snmp_location it tests * Enable nxos_snmp_location tests
This commit is contained in:
parent
d97080174e
commit
de8d00b401
11 changed files with 144 additions and 7 deletions
|
@ -472,6 +472,16 @@
|
|||
- set_fact:
|
||||
failed_modules: "{{ failed_modules }} + [ 'nxos_snmp_community' ]"
|
||||
test_failed: true
|
||||
|
||||
- block:
|
||||
- include_role:
|
||||
name: nxos_snmp_location
|
||||
when: "limit_to in ['*', 'nxos_snmp_location']"
|
||||
rescue:
|
||||
- set_fact:
|
||||
failed_modules: "{{ failed_modules }} + [ 'nxos_snmp_location' ]"
|
||||
test_failed: true
|
||||
|
||||
###########
|
||||
- debug: var=failed_modules
|
||||
when: test_failed
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
15
test/integration/targets/nxos_snmp_location/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_snmp_location/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,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_snmp_location/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_snmp_location/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,47 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snmp_location sanity test"
|
||||
|
||||
- name: Setup - Remove snmp_location if configured
|
||||
nxos_snmp_location: &remove
|
||||
location: Test
|
||||
state: absent
|
||||
timeout: 60
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- block:
|
||||
|
||||
- name: Configure snmp host
|
||||
nxos_snmp_location: &config
|
||||
location: Test
|
||||
state: present
|
||||
timeout: 60
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Idempotence Check
|
||||
nxos_snmp_location: *config
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
always:
|
||||
- name: Cleanup
|
||||
nxos_snmp_location: *remove
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: Cleanup Idempotence
|
||||
nxos_snmp_location: *remove
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snmp_location 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