mirror of https://github.com/ansible/ansible.git
Fix nxos_snmp_host bug (#32916)
* Fix nxos_snmp_host bug * Enable nxos_snmp_host testspull/32957/head
parent
3f3c526026
commit
208208ab8f
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
testcase: "*"
|
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
- name: collect common cli test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/common"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: collect cli test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/cli"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: cli_cases
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
test_cases:
|
||||||
|
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }} connection={{ cli }}"
|
||||||
|
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'] }
|
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
- name: collect common nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/common"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: collect nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/nxapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: nxapi_cases
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
test_cases:
|
||||||
|
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }} connection={{ nxapi }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
- set_fact: snmp_type="trap"
|
||||||
|
- set_fact: snmp_version="v2c"
|
||||||
|
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
when: not (platform | match("N5K"))
|
||||||
|
|
||||||
|
- name: Setup - Remove snmp_host if configured
|
||||||
|
nxos_snmp_host: &remove
|
||||||
|
snmp_host: 3.3.3.3
|
||||||
|
community: TESTING
|
||||||
|
version: "{{ snmp_version }}"
|
||||||
|
snmp_type: "{{ snmp_type }}"
|
||||||
|
vrf: management
|
||||||
|
vrf_filter: management
|
||||||
|
src_intf: "{{ intname|default(omit) }}"
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
|
|
||||||
|
- name: Configure snmp host
|
||||||
|
nxos_snmp_host: &config
|
||||||
|
snmp_host: 3.3.3.3
|
||||||
|
community: TESTING
|
||||||
|
version: "{{ snmp_version }}"
|
||||||
|
snmp_type: "{{ snmp_type }}"
|
||||||
|
vrf: management
|
||||||
|
vrf_filter: management
|
||||||
|
src_intf: "{{ intname|default(omit) }}"
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: Idempotence Check
|
||||||
|
nxos_snmp_host: *config
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup
|
||||||
|
nxos_snmp_host: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: Cleanup Idempotence
|
||||||
|
nxos_snmp_host: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test"
|
@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
- set_fact: snmp_type="inform"
|
||||||
|
- set_fact: snmp_version="v3"
|
||||||
|
- set_fact: snmp_auth="noauth"
|
||||||
|
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
when: not (platform | match("N5K"))
|
||||||
|
|
||||||
|
- name: Setup - Remove snmp_host if configured
|
||||||
|
nxos_snmp_host: &remove
|
||||||
|
snmp_host: 3.3.3.3
|
||||||
|
community: TESTING
|
||||||
|
v3: "{{ snmp_auth|default(omit) }}"
|
||||||
|
version: "{{ snmp_version }}"
|
||||||
|
snmp_type: "{{ snmp_type }}"
|
||||||
|
vrf: management
|
||||||
|
vrf_filter: management
|
||||||
|
src_intf: "{{ intname|default(omit) }}"
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
|
|
||||||
|
- name: Configure snmp host
|
||||||
|
nxos_snmp_host: &config
|
||||||
|
snmp_host: 3.3.3.3
|
||||||
|
community: TESTING
|
||||||
|
v3: "{{ snmp_auth|default(omit) }}"
|
||||||
|
version: "{{ snmp_version }}"
|
||||||
|
snmp_type: "{{ snmp_type }}"
|
||||||
|
vrf: management
|
||||||
|
vrf_filter: management
|
||||||
|
src_intf: "{{ intname|default(omit) }}"
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: Idempotence Check
|
||||||
|
nxos_snmp_host: *config
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
when: not (platform | match('N35'))
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup
|
||||||
|
nxos_snmp_host: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: Cleanup Idempotence
|
||||||
|
nxos_snmp_host: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test"
|
@ -0,0 +1,61 @@
|
|||||||
|
---
|
||||||
|
- set_fact: snmp_type="trap"
|
||||||
|
- set_fact: snmp_version="v3"
|
||||||
|
- set_fact: snmp_auth="noauth"
|
||||||
|
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test"
|
||||||
|
|
||||||
|
- name: Setup - Remove snmp_host if configured
|
||||||
|
nxos_snmp_host: &remove
|
||||||
|
snmp_host: 3.3.3.3
|
||||||
|
community: TESTING
|
||||||
|
v3: "{{ snmp_auth|default(omit) }}"
|
||||||
|
version: "{{ snmp_version }}"
|
||||||
|
snmp_type: "{{ snmp_type }}"
|
||||||
|
vrf: management
|
||||||
|
vrf_filter: management
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
|
|
||||||
|
- name: Configure snmp host
|
||||||
|
nxos_snmp_host: &config
|
||||||
|
snmp_host: 3.3.3.3
|
||||||
|
community: TESTING
|
||||||
|
v3: "{{ snmp_auth|default(omit) }}"
|
||||||
|
version: "{{ snmp_version }}"
|
||||||
|
snmp_type: "{{ snmp_type }}"
|
||||||
|
vrf: management
|
||||||
|
vrf_filter: management
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: Idempotence Check
|
||||||
|
nxos_snmp_host: *config
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup
|
||||||
|
nxos_snmp_host: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: Cleanup Idempotence
|
||||||
|
nxos_snmp_host: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test"
|
Loading…
Reference in New Issue