forked from ansible/ansible
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix nxos_snmp_traps issues (ansible#39444)
* fix snmp_traps code * add IT cases * fix shippable * fix shippable without ignore
- Loading branch information
Showing
8 changed files
with
216 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
testcase: "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dependencies: | ||
- prepare_nxos_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
84 changes: 84 additions & 0 deletions
84
test/integration/targets/nxos_snmp_traps/tests/common/sanity.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |