diff options
author | saichint <saichint@cisco.com> | 2018-05-03 18:06:33 +0200 |
---|---|---|
committer | Trishna Guha <trishnaguha17@gmail.com> | 2018-05-03 18:06:33 +0200 |
commit | f99bae1776cdc87e0a3f190b76c41d77fb7dd94b (patch) | |
tree | 70aa20a198f27b2bafc24e128c54f4750b13e5af /test/integration/targets/nxos_snmp_host | |
parent | fix nxos_snmp_traps issues (#39444) (diff) | |
download | ansible-f99bae1776cdc87e0a3f190b76c41d77fb7dd94b.tar.xz ansible-f99bae1776cdc87e0a3f190b76c41d77fb7dd94b.zip |
Fix for nxos_snmp_host issues (#39642)
* fix snmp_host issues
* source files
* fix shippable
* remove defaults to match arg spec
Diffstat (limited to 'test/integration/targets/nxos_snmp_host')
-rw-r--r-- | test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml | 129 | ||||
-rw-r--r-- | test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml (renamed from test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_trap.yaml) | 70 | ||||
-rw-r--r-- | test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml | 72 | ||||
-rw-r--r-- | test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml | 77 |
4 files changed, 335 insertions, 13 deletions
diff --git a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml new file mode 100644 index 0000000000..e7de1ef55f --- /dev/null +++ b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml @@ -0,0 +1,129 @@ +--- +- set_fact: snmp_type="trap" +- set_fact: snmp_version="v1" + +- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" +- debug: msg="Using provider={{ connection.transport }}" + when: ansible_connection == "local" + +# Select interface for test +- set_fact: intname="{{ nxos_int1 }}" + when: not (platform is 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) }}" + udp: 222 + 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) }}" + udp: 222 + 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" + + - block: + - name: Add another vrf to filter + nxos_snmp_host: &config1 + snmp_host: 3.3.3.3 + vrf_filter: default + udp: 222 + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *config1 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + + - name: remove some configuration + nxos_snmp_host: &rem1 + snmp_host: 3.3.3.3 + udp: 222 + src_intf: "{{ intname|default(omit) }}" + vrf: management + vrf_filter: management + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem1 + register: result + + - assert: *false + + - block: + - name: remove some more configuration + nxos_snmp_host: &rem2 + snmp_host: 3.3.3.3 + udp: 222 + vrf_filter: default + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem2 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + + + - name: Cleanup + nxos_snmp_host: *remove + register: result + + - assert: *true + + - name: Cleanup Idempotence + nxos_snmp_host: *remove + register: result + + - assert: *false + + always: + - name: Cleanup + nxos_snmp_host: *remove + + - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" diff --git a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_trap.yaml b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml index 16c1843574..7c7e100077 100644 --- a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_trap.yaml +++ b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml @@ -1,8 +1,8 @@ --- -- set_fact: snmp_type="trap" +- set_fact: snmp_type="inform" - set_fact: snmp_version="v2c" -- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test" +- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" - debug: msg="Using provider={{ connection.transport }}" when: ansible_connection == "local" @@ -19,6 +19,7 @@ vrf: management vrf_filter: management src_intf: "{{ intname|default(omit) }}" + udp: 222 state: absent provider: "{{ connection }}" ignore_errors: yes @@ -34,6 +35,7 @@ vrf: management vrf_filter: management src_intf: "{{ intname|default(omit) }}" + udp: 222 state: present provider: "{{ connection }}" register: result @@ -50,7 +52,63 @@ that: - "result.changed == false" - always: + - block: + - name: Add another vrf to filter + nxos_snmp_host: &config1 + snmp_host: 3.3.3.3 + vrf_filter: default + udp: 222 + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *config1 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + + - name: remove some configuration + nxos_snmp_host: &rem1 + snmp_host: 3.3.3.3 + udp: 222 + src_intf: "{{ intname|default(omit) }}" + vrf: management + vrf_filter: management + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem1 + register: result + + - assert: *false + + - block: + - name: remove some more configuration + nxos_snmp_host: &rem2 + snmp_host: 3.3.3.3 + udp: 222 + vrf_filter: default + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem2 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + - name: Cleanup nxos_snmp_host: *remove register: result @@ -63,4 +121,8 @@ - assert: *false - - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test" + always: + - name: Cleanup + nxos_snmp_host: *remove + + - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" diff --git a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml index 84b41a2222..9a481e5770 100644 --- a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml +++ b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml @@ -3,7 +3,7 @@ - set_fact: snmp_version="v3" - set_fact: snmp_auth="noauth" -- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test" +- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" - debug: msg="Using provider={{ connection.transport }}" when: ansible_connection == "local" @@ -11,13 +11,17 @@ - set_fact: intname="{{ nxos_int1 }}" when: not (platform is match("N5K")) +- set_fact: run="true" +- set_fact: run="false" + when: platform is match('N35') + - 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 }}" + v3: "{{ snmp_auth }}" vrf: management vrf_filter: management src_intf: "{{ intname|default(omit) }}" @@ -53,9 +57,60 @@ that: - "result.changed == false" - when: not (platform is match('N35')) + - block: + - name: Add another vrf to filter + nxos_snmp_host: &config1 + snmp_host: 3.3.3.3 + vrf_filter: default + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *config1 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + + - name: remove some configuration + nxos_snmp_host: &rem1 + snmp_host: 3.3.3.3 + src_intf: "{{ intname|default(omit) }}" + vrf: management + vrf_filter: management + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem1 + register: result + + - assert: *false + + - block: + - name: remove some more configuration + nxos_snmp_host: &rem2 + snmp_host: 3.3.3.3 + vrf_filter: default + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem2 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) - always: - name: Cleanup nxos_snmp_host: *remove register: result @@ -68,4 +123,11 @@ - assert: *false - - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test" + when: run + + always: + - name: Cleanup + nxos_snmp_host: *remove + register: result + + - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" diff --git a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml index 0d92d3b94d..2262a6637f 100644 --- a/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml +++ b/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml @@ -1,21 +1,27 @@ --- - set_fact: snmp_type="trap" - set_fact: snmp_version="v3" -- set_fact: snmp_auth="noauth" +- set_fact: snmp_auth="priv" -- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test" +- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" - debug: msg="Using provider={{ connection.transport }}" when: ansible_connection == "local" +# Select interface for test +- set_fact: intname="{{ nxos_int1 }}" + when: not (platform is match("N5K")) + - name: Setup - Remove snmp_host if configured nxos_snmp_host: &remove snmp_host: 3.3.3.3 community: TESTING + udp: 222 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 @@ -26,11 +32,13 @@ nxos_snmp_host: &config snmp_host: 3.3.3.3 community: TESTING + udp: 222 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 @@ -47,7 +55,63 @@ that: - "result.changed == false" - always: + - block: + - name: Add another vrf to filter + nxos_snmp_host: &config1 + snmp_host: 3.3.3.3 + udp: 222 + vrf_filter: default + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *config1 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + + - name: remove some configuration + nxos_snmp_host: &rem1 + snmp_host: 3.3.3.3 + udp: 222 + src_intf: "{{ intname|default(omit) }}" + vrf: management + vrf_filter: management + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem1 + register: result + + - assert: *false + + - block: + - name: remove some more configuration + nxos_snmp_host: &rem2 + snmp_host: 3.3.3.3 + udp: 222 + vrf_filter: default + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Idempotence Check + nxos_snmp_host: *rem2 + register: result + + - assert: *false + when: not (platform is match('N35|N5K')) + - name: Cleanup nxos_snmp_host: *remove register: result @@ -60,4 +124,9 @@ - assert: *false - - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }}sanity test" + always: + - name: Cleanup + nxos_snmp_host: *remove + register: result + + - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test" |