From 7e58661335ddb566c4afd0831484eed7e336e314 Mon Sep 17 00:00:00 2001 From: Kedar K <4506537+kedarX@users.noreply.github.com> Date: Fri, 15 Sep 2017 23:52:03 +0530 Subject: [PATCH] Test Role: Adds nxos_pim_rp_address integration test role (#29958) * Adds nxos_pim_rp_address integration test role for group_list, prefix_list and route_map (cli and nxapi) * * Adds explicit removal of static RP configs to match cli behaviour * * Removes config deletion using nxos_config module (for 2.4 only) * * Attempt short and long delete config command * Add a platform check for N3K for bidir --- .../nxos_pim_rp_address/defaults/main.yaml | 2 + .../targets/nxos_pim_rp_address/meta/main.yml | 2 + .../nxos_pim_rp_address/tasks/cli.yaml | 25 ++++ .../nxos_pim_rp_address/tasks/main.yaml | 3 + .../nxos_pim_rp_address/tasks/nxapi.yaml | 38 +++++ .../tests/common/configure.yaml | 130 ++++++++++++++++++ 6 files changed, 200 insertions(+) create mode 100644 test/integration/targets/nxos_pim_rp_address/defaults/main.yaml create mode 100644 test/integration/targets/nxos_pim_rp_address/meta/main.yml create mode 100644 test/integration/targets/nxos_pim_rp_address/tasks/cli.yaml create mode 100644 test/integration/targets/nxos_pim_rp_address/tasks/main.yaml create mode 100644 test/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml create mode 100644 test/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml diff --git a/test/integration/targets/nxos_pim_rp_address/defaults/main.yaml b/test/integration/targets/nxos_pim_rp_address/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_pim_rp_address/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_pim_rp_address/meta/main.yml b/test/integration/targets/nxos_pim_rp_address/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_pim_rp_address/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_pim_rp_address/tasks/cli.yaml b/test/integration/targets/nxos_pim_rp_address/tasks/cli.yaml new file mode 100644 index 0000000000..0ab3f8f908 --- /dev/null +++ b/test/integration/targets/nxos_pim_rp_address/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_pim_rp_address/tasks/main.yaml b/test/integration/targets/nxos_pim_rp_address/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_pim_rp_address/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml b/test/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml new file mode 100644 index 0000000000..e071f293a2 --- /dev/null +++ b/test/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml @@ -0,0 +1,38 @@ +--- +- 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: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }} connection={{ nxapi }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml b/test/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml new file mode 100644 index 0000000000..30158a94da --- /dev/null +++ b/test/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml @@ -0,0 +1,130 @@ +--- +- debug: msg="START {{ connection.transport }} nxos_pim_rp_address sanity" + +- set_fact: bidir="false" + when: platform | search('N3K') + +- set_fact: bidircfg='bidir' +- set_fact: bidircfg='' + when: platform | search('N3K') + +- block: + - name: "Disable feature PIM" + nxos_feature: &disable_feature + feature: pim + state: disabled + provider: "{{ connection }}" + + - name: "Enable feature PIM" + nxos_feature: &enable_feature + feature: pim + state: enabled + provider: "{{ connection }}" + + - name: Configure rp_address + group_list + nxos_pim_rp_address: &configgl + rp_address: "10.1.1.20" + group_list: "224.0.0.0/8" + bidir: "{{bidir|default('true')}}" + state: present + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: Check idempotence rp_address + group_list + nxos_pim_rp_address: *configgl + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: Remove rp_address + group_list using long config + #FIXME: Config deletion shall be fixed in 2.5 for platform dependencies. + + # Note: For 2.4 - Use platform specific config delete command as shown below. + # Possible options: Identify and use the command that is supported + # by your platform under test. + + # no ip pim rp-address bidir + # no ip pim rp-address + # no ip pim rp-address + + nxos_config: + lines: "no ip pim rp-address 10.1.1.20 group-list 224.0.0.0/8 {{ bidircfg }}" + provider: "{{ connection }}" + ignore_errors: yes + + - name: Remove rp_address + group_list using short config + nxos_config: + lines: no ip pim rp-address 10.1.1.20 + provider: "{{ connection }}" + ignore_errors: yes + + - name: Configure rp_address + prefix_list + nxos_pim_rp_address: &configpl + rp_address: "10.1.1.20" + prefix_list: "pim_prefix_list" + bidir: "{{bidir|default('true')}}" + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Check idempotence rp_address + prefix_list + nxos_pim_rp_address: *configpl + register: result + + - assert: *false + + - name: Remove rp_address + prefix_list using long config + nxos_config: + lines: "no ip pim rp-address 10.1.1.20 prefix-list pim_prefix_list {{ bidircfg }}" + provider: "{{ connection }}" + ignore_errors: yes + + - name: Remove rp_address + prefix_list using short config + nxos_config: + lines: no ip pim rp-address 10.1.1.20 + provider: "{{ connection }}" + ignore_errors: yes + + - name: Configure rp_address + route_map + nxos_pim_rp_address: &configrm + rp_address: "10.1.1.20" + route_map: "pim_routemap" + bidir: "{{bidir|default('true')}}" + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Check idempotence rp_address + route_map + nxos_pim_rp_address: *configrm + register: result + + - assert: *false + + - name: Remove rp_address + route_map using long config + nxos_config: + lines: "no ip pim rp-address 10.1.1.20 route-map pim_routemap {{ bidircfg }}" + provider: "{{ connection }}" + ignore_errors: yes + + - name: Remove rp_address + route_map using short config + nxos_config: + lines: no ip pim rp-address 10.1.1.20 + provider: "{{ connection }}" + ignore_errors: yes + + + always: + - name: "Disable feature PIM" + nxos_feature: *disable_feature + +- debug: msg="END {{ connection.transport }} nxos_pim_rp_address sanity"