fix nxos_snmp_traps issues (#39444)

* fix snmp_traps code

* add IT cases

* fix shippable

* fix shippable without ignore
This commit is contained in:
saichint 2018-05-03 09:04:25 -07:00 committed by Trishna Guha
commit 99748cbfa4
8 changed files with 215 additions and 83 deletions

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View file

@ -0,0 +1,33 @@
---
- name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
connection: local
register: test_cases
- name: collect cli test cases
find:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
connection: local
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 cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli connection={}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local connection={{ cli }}"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View 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'] }

View file

@ -0,0 +1,27 @@
---
- name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
connection: local
register: test_cases
- name: collect nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
connection: local
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 cases (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,84 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_snmp_traps sanity test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- name: Setup - Remove snmp_traps if configured
nxos_snmp_traps: &remove
group: all
state: disabled
provider: "{{ connection }}"
- block:
- name: Configure one snmp trap group
nxos_snmp_traps: &config
group: bridge
state: enabled
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: Idempotence Check
nxos_snmp_traps: *config
register: result
- assert: &false
that:
- "result.changed == false"
- name: Remove snmp trap group
nxos_snmp_traps: &rem1
group: bridge
state: disabled
provider: "{{ connection }}"
register: result
- assert: *true
- name: Idempotence Check
nxos_snmp_traps: *rem1
register: result
- assert: *false
- name: Configure all snmp trap groups
nxos_snmp_traps: &config1
group: all
state: enabled
provider: "{{ connection }}"
register: result
- assert: *true
- block:
# On I2, link command does not work properly
# On D1, callhome command does not work properly
# skip for these older platforms
- name: Idempotence Check
nxos_snmp_traps: *config1
register: result
when: imagetag is not search("I2|D1")
- assert: *false
when: imagetag is not search("I2|D1")
- name: Cleanup
nxos_snmp_traps: *remove
register: result
- assert: *true
- name: Cleanup Idempotence
nxos_snmp_traps: *remove
register: result
- assert: *false
always:
- name: Cleanup
nxos_snmp_traps: *remove
- debug: msg="END connection={{ ansible_connection }} nxos_snmp_traps sanity test"