diff --git a/test/integration/targets/nxos_bgp_af/tasks/cli.yaml b/test/integration/targets/nxos_bgp_af/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_bgp_af/tasks/cli.yaml +++ b/test/integration/targets/nxos_bgp_af/tasks/cli.yaml @@ -1,15 +1,25 @@ --- -- name: collect all cli test cases +- 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: test_cases + 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 }}" + 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_bgp_af/tasks/nxapi.yaml b/test/integration/targets/nxos_bgp_af/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_bgp_af/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_bgp_af/tasks/nxapi.yaml @@ -1,9 +1,19 @@ --- -- name: collect all nxapi test cases +- 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: test_cases + 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 }}" @@ -16,7 +26,7 @@ provider: "{{ cli }}" - name: run test case - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} connection={{ nxapi }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_bgp_af/tests/cli/sanity.yaml b/test/integration/targets/nxos_bgp_af/tests/common/sanity.yaml similarity index 85% rename from test/integration/targets/nxos_bgp_af/tests/cli/sanity.yaml rename to test/integration/targets/nxos_bgp_af/tests/common/sanity.yaml index 25627d94ba..16b4e960e7 100644 --- a/test/integration/targets/nxos_bgp_af/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_bgp_af/tests/common/sanity.yaml @@ -1,28 +1,28 @@ --- -- debug: msg="START TRANSPORT:CLI nxos_bgp_af sanity test" +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_bgp_af sanity test" - set_fact: advertise_l2vpn_evpn="true" when: platform | search('N9K') - name: "Enable feature BGP" - nxos_feature: + nxos_feature: feature: bgp state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: "Enable feature nv overlay" nxos_feature: feature: nv overlay state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: "Setup" nxos_bgp: &remove asn: 65535 state: absent - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - block: @@ -30,7 +30,7 @@ nxos_config: lines: - nv overlay evpn - provider: "{{ cli }}" + provider: "{{ connection }}" when: platform | search('N9K') - name: "Configure BGP_AF defaults" @@ -41,7 +41,7 @@ safi: unicast advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" state: present - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: &true @@ -67,7 +67,7 @@ register: result - assert: *false - + - name: "Configure BGP_AF non defaults" nxos_bgp_af: &configure_non_default asn: 65535 @@ -97,9 +97,9 @@ table_map: RouteMap table_map_filter: true state: present - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - + - assert: *true - name: "Check Idempotence" @@ -113,13 +113,13 @@ register: result - assert: *true - + - name: "Check Idempotence" nxos_bgp: *remove register: result - assert: *false - + rescue: - name: "Cleanup BGP" nxos_bgp: *remove @@ -130,20 +130,20 @@ nxos_feature: &disable_bgp feature: bgp state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" - name: "Disable feature nv overlay" nxos_feature: &disable_nvoverlay feature: nv overlay state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: "Remove nv overlay evpn" nxos_config: lines: - no nv overlay evpn - provider: "{{ cli }}" + provider: "{{ connection }}" when: platform | search('N9K') - - debug: msg="END TRANSPORT:CLI nxos_bgp_af sanity test" + - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_bgp_af sanity test" diff --git a/test/integration/targets/nxos_bgp_af/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_bgp_af/tests/nxapi/sanity.yaml deleted file mode 100644 index d712fbc758..0000000000 --- a/test/integration/targets/nxos_bgp_af/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,149 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_bgp_af sanity test" - -- set_fact: advertise_l2vpn_evpn="true" - when: platform | search('N9K') - -- name: "Enable feature BGP" - nxos_feature: - feature: bgp - state: enabled - provider: "{{ nxapi }}" - ignore_errors: yes - -- name: "Enable feature nv overlay" - nxos_feature: - feature: nv overlay - state: enabled - provider: "{{ nxapi }}" - ignore_errors: yes - -- name: "Setup" - nxos_bgp: &remove - asn: 65535 - state: absent - provider: "{{ nxapi }}" - ignore_errors: yes - -- block: - - name: "Enable nv overlay evpn" - nxos_config: - lines: - - nv overlay evpn - provider: "{{ nxapi }}" - when: platform | search('N9K') - - - name: "Configure BGP_AF defaults" - nxos_bgp_af: &configure_default - asn: 65535 - vrf: TESTING - afi: ipv4 - safi: unicast - advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" - state: present - provider: "{{ nxapi }}" - register: result - - - assert: &true - that: - - "result.changed == true" - - - name: "Check Idempotence" - nxos_bgp_af: *configure_default - register: result - - - assert: &false - that: - - "result.changed == false" - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp: *remove - register: result - - - assert: *false - - - name: "Configure BGP_AF non defaults" - nxos_bgp_af: &configure_non_default - asn: 65535 - vrf: TESTING - afi: ipv4 - safi: unicast - additional_paths_install: true - additional_paths_receive: true - additional_paths_selection: RouteMap - additional_paths_send: true - advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" - client_to_client: false - dampen_igp_metric: 200 - dampening_half_time: 1 - dampening_max_suppress_time: 4 - dampening_reuse_time: 2 - dampening_suppress_time: 3 - default_information_originate: true - default_metric: 50 - distance_ebgp: 30 - distance_ibgp: 60 - distance_local: 90 - maximum_paths: 9 - maximum_paths_ibgp: 9 - next_hop_route_map: RouteMap - suppress_inactive: true - table_map: RouteMap - table_map_filter: true - state: present - provider: "{{ nxapi }}" - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp_af: *configure_non_default - register: result - - - assert: *false - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp: *remove - register: result - - - assert: *false - - rescue: - - name: "Cleanup BGP" - nxos_bgp: *remove - ignore_errors: yes - - always: - - name: "Disable feature bgp" - nxos_feature: &disable_bgp - feature: bgp - state: disabled - provider: "{{ nxapi }}" - - - name: "Disable feature nv overlay" - nxos_feature: &disable_nvoverlay - feature: nv overlay - state: disabled - provider: "{{ nxapi }}" - ignore_errors: yes - - - name: "Remove nv overlay evpn" - nxos_config: - lines: - - no nv overlay evpn - provider: "{{ cli }}" - when: platform | search('N9K') - - - debug: msg="END TRANSPORT:NXAPI nxos_bgp_af sanity test" diff --git a/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml b/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml +++ b/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml @@ -1,15 +1,25 @@ --- -- name: collect all cli test cases +- 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: test_cases + 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 }}" + 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_bgp_neighbor/tasks/nxapi.yaml b/test/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml @@ -1,9 +1,19 @@ --- -- name: collect all nxapi test cases +- 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: test_cases + 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 }}" @@ -16,7 +26,7 @@ provider: "{{ cli }}" - name: run test case - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} connection={{ nxapi }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_bgp_neighbor/tests/cli/sanity.yaml b/test/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml similarity index 88% rename from test/integration/targets/nxos_bgp_neighbor/tests/cli/sanity.yaml rename to test/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml index 40a5045b5b..f61147f86d 100644 --- a/test/integration/targets/nxos_bgp_neighbor/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START TRANSPORT:CLI nxos_bgp_neighbor sanity test" +- debug: msg="START TRANSPORT:{{ connection.transport}} nxos_bgp_neighbor sanity test" - set_fact: intname="{{ nxos_int1 }}" @@ -13,19 +13,19 @@ nxos_feature: feature: bgp state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: "Setup" nxos_bgp: &remove asn: 65535 state: absent - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - block: - name: "Configure BGP neighbor defaults" - nxos_bgp_neighbor: &configure_default + nxos_bgp_neighbor: &configure_default asn: 65535 neighbor: 3.3.3.3 local_as: 20 @@ -33,7 +33,7 @@ description: "just a description" update_source: "{{ intname.capitalize() }}" state: present - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: &true @@ -79,7 +79,7 @@ timers_holdtime: 270 update_source: loopback151 state: present - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -103,7 +103,7 @@ remote_as: 30 pwd: '386c0565965f89de' pwd_type: 3des - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -127,7 +127,7 @@ remote_as: 30 pwd: '386c0565965f89de' pwd_type: cisco_type_7 - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -150,7 +150,7 @@ neighbor: 3.3.3.3 remote_as: 30 transport_passive_only: true - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -172,7 +172,7 @@ neighbor: 3.3.3.3 remote_as: 30 transport_passive_only: false - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -198,6 +198,6 @@ nxos_feature: &disable_bgp feature: bgp state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" -- debug: msg="END TRANSPORT:CLI nxos_bgp_neighbor sanity test" +- debug: msg="END TRANSPORT:{{ connection.transport}} nxos_bgp_neighbor sanity test" diff --git a/test/integration/targets/nxos_bgp_neighbor/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_bgp_neighbor/tests/nxapi/sanity.yaml deleted file mode 100644 index ae2070f634..0000000000 --- a/test/integration/targets/nxos_bgp_neighbor/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,203 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_bgp_neighbor sanity test" - -- set_fact: intname="{{ nxos_int1 }}" - -- set_fact: log_neighbor_changes="enable" - when: (titanium is defined) and not ((titanium | search('true'))) - -- set_fact: remove_private_as="all" - when: (titanium is defined) and not ((titanium | search('true'))) - -- name: "Enable feature BGP" - nxos_feature: - feature: bgp - state: enabled - provider: "{{ nxapi }}" - ignore_errors: yes - -- name: "Setup" - nxos_bgp: &remove - asn: 65535 - state: absent - provider: "{{ nxapi }}" - ignore_errors: yes - -- block: - - name: "Configure BGP neighbor defaults" - nxos_bgp_neighbor: &configure_default - asn: 65535 - neighbor: 3.3.3.3 - local_as: 20 - remote_as: 30 - description: "just a description" - update_source: "{{ intname.capitalize() }}" - state: present - provider: "{{ nxapi }}" - register: result - - - assert: &true - that: - - "result.changed == true" - - - name: "Check Idempotence" - nxos_bgp_neighbor: *configure_default - register: result - - - assert: &false - that: - - "result.changed == false" - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp: *remove - register: result - - - assert: *false - - - name: "Configure BGP neighbor non-defaults" - nxos_bgp_neighbor: &configure_non_default - asn: 65535 - neighbor: 3.3.3.3 - description: "tested by ansible" - connected_check: true - capability_negotiation: true - dynamic_capability: true - ebgp_multihop: 2 - log_neighbor_changes: "{{log_neighbor_changes|default(omit)}}" - low_memory_exempt: true - remote_as: 12.1 - remove_private_as: "{{remove_private_as|default(omit)}}" - shutdown: true - suppress_4_byte_as: true - timers_keepalive: 90 - timers_holdtime: 270 - update_source: loopback151 - state: present - provider: "{{ nxapi }}" - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp_neighbor: *configure_non_default - register: result - - - assert: *false - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Configure BGP neighbor 3des password" - nxos_bgp_neighbor: &configure_3des_password - asn: 65535 - neighbor: 3.3.3.3 - remote_as: 30 - pwd: '386c0565965f89de' - pwd_type: 3des - provider: "{{ nxapi }}" - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp_neighbor: *configure_3des_password - register: result - - - assert: *false - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Configure BGP neighbor type 7 password" - nxos_bgp_neighbor: &configure_type7_password - asn: 65535 - neighbor: 3.3.3.3 - remote_as: 30 - pwd: '386c0565965f89de' - pwd_type: cisco_type_7 - provider: "{{ nxapi }}" - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_bgp_neighbor: *configure_type7_password - register: result - - - assert: *false - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Configure BGP neighbor transport type passive" - nxos_bgp_neighbor: &configure_transport_passive - asn: 65535 - neighbor: 3.3.3.3 - remote_as: 30 - transport_passive_only: true - provider: "{{ nxapi }}" - register: result - - assert: *true - - - name: "Check Idempotence" - nxos_bgp_neighbor: *configure_transport_passive - register: result - - - assert: *false - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - - name: "Configure BGP neighbor transport type default" - nxos_bgp_neighbor: &configure_transport_default - asn: 65535 - neighbor: 3.3.3.3 - remote_as: 30 - transport_passive_only: false - provider: "{{ nxapi }}" - register: result - - assert: *true - - - name: "Check Idempotence" - nxos_bgp_neighbor: *configure_transport_default - register: result - - - assert: *false - - - name: "Remove BGP" - nxos_bgp: *remove - register: result - - - assert: *true - - rescue: - - name: "Cleanup BGP" - nxos_bgp: *remove - ignore_errors: yes - - always: - - name: "Disable feature bgp" - nxos_feature: &disable_bgp - feature: bgp - state: disabled - provider: "{{ nxapi }}" - -- debug: msg="END TRANSPORT:NXAPI nxos_bgp_neighbor sanity test" diff --git a/test/integration/targets/nxos_command/tasks/cli.yaml b/test/integration/targets/nxos_command/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_command/tasks/cli.yaml +++ b/test/integration/targets/nxos_command/tasks/cli.yaml @@ -1,15 +1,25 @@ --- -- name: collect all cli test cases +- 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: test_cases + 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 }}" + 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_command/tasks/nxapi.yaml b/test/integration/targets/nxos_command/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_command/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_command/tasks/nxapi.yaml @@ -1,9 +1,19 @@ --- -- name: collect all nxapi test cases +- 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: test_cases + 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 }}" @@ -16,7 +26,7 @@ provider: "{{ cli }}" - name: run test case - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} connection={{ nxapi }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_command/tests/cli/negative.yaml b/test/integration/targets/nxos_command/tests/common/negative.yaml similarity index 70% rename from test/integration/targets/nxos_command/tests/cli/negative.yaml rename to test/integration/targets/nxos_command/tests/common/negative.yaml index 2d37457745..b41b83256d 100644 --- a/test/integration/targets/nxos_command/tests/cli/negative.yaml +++ b/test/integration/targets/nxos_command/tests/common/negative.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/negative.yaml" +- debug: msg="START {{ connection.transport }}/negative.yaml" - name: run 11 commands nxos_command: @@ -15,7 +15,7 @@ - show version - show version - show version - provier: "{{ cli }}" + provier: "{{ connection }}" ignore_errors: yes register: result @@ -24,4 +24,4 @@ - result.failed -- debug: msg="END cli/negative.yaml" +- debug: msg="END {{ connection.transport }}/negative.yaml" diff --git a/test/integration/targets/nxos_command/tests/nxapi/negative.yaml b/test/integration/targets/nxos_command/tests/nxapi/negative.yaml deleted file mode 100644 index 3763f958e6..0000000000 --- a/test/integration/targets/nxos_command/tests/nxapi/negative.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- debug: msg="START nxapi/negative.yaml" - -- name: run 11 commands - nxos_command: - commands: - - show version - - show version - - show version - - show version - - show version - - show version - - show version - - show version - - show version - - show version - - show version - provier: "{{ nxapi }}" - ignore_errors: yes - register: result - -- assert: - that: - - result.failed - - -- debug: msg="END nxapi/negative.yaml" diff --git a/test/integration/targets/nxos_config/tasks/cli.yaml b/test/integration/targets/nxos_config/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_config/tasks/cli.yaml +++ b/test/integration/targets/nxos_config/tasks/cli.yaml @@ -1,15 +1,25 @@ --- -- name: collect all cli test cases +- 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: test_cases + 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 }}" + 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_config/tasks/nxapi.yaml b/test/integration/targets/nxos_config/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_config/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_config/tasks/nxapi.yaml @@ -1,9 +1,19 @@ --- -- name: collect all nxapi test cases +- 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: test_cases + 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 }}" @@ -16,7 +26,7 @@ provider: "{{ cli }}" - name: run test case - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} connection={{ nxapi }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_config/tests/cli/defaults.yaml b/test/integration/targets/nxos_config/tests/cli/defaults.yaml deleted file mode 100644 index 1a9575b352..0000000000 --- a/test/integration/targets/nxos_config/tests/cli/defaults.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- debug: msg="START cli/defaults.yaml" - -- name: setup - nxos_config: - commands: - - no description - - shutdown - parents: - - interface Ethernet2/5 - match: none - provider: "{{ cli }}" - -- name: configure device with defaults included - nxos_config: - src: defaults/config.j2 - defaults: yes - provider: "{{ cli }}" - register: result - -- debug: var=result - -- assert: - that: - - "result.changed == true" - - "result.updates is defined" - -- name: check device with defaults included - nxos_config: - src: defaults/config.j2 - defaults: yes - provider: "{{ cli }}" - register: result - -- debug: var=result - -- assert: - that: - - "result.changed == false" - - "result.updates is not defined" - -- debug: msg="END cli/defaults.yaml" diff --git a/test/integration/targets/nxos_config/tests/cli/save.yaml b/test/integration/targets/nxos_config/tests/cli/save.yaml deleted file mode 100644 index 4c87a822fa..0000000000 --- a/test/integration/targets/nxos_config/tests/cli/save.yaml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- debug: msg="START cli/save.yaml" - -- name: setup - nxos_config: - commands: - - no description - - no shutdown - parents: - - interface Ethernet2/5 - match: none - provider: "{{ cli }}" - - -- name: save config - nxos_config: - save: true - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: save should always run - nxos_config: - save: true - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == true" - -- debug: msg="END cli/save.yaml" diff --git a/test/integration/targets/nxos_config/tests/cli/src_invalid.yaml b/test/integration/targets/nxos_config/tests/cli/src_invalid.yaml deleted file mode 100644 index 32931f8ab1..0000000000 --- a/test/integration/targets/nxos_config/tests/cli/src_invalid.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- debug: msg="START cli/src_invalid.yaml" - - -# Defend https://github.com/ansible/ansible-modules-core/issues/4797 -- name: configure with invalid src - nxos_config: - src: basic/foobar.j2 - provider: "{{ cli }}" - register: result - ignore_errors: yes - -- assert: - that: - - "result.changed == false" - - "result.failed == true" - - "result.msg == 'path specified in src not found'" - -- debug: msg="END cli/src_invalid.yaml" diff --git a/test/integration/targets/nxos_config/tests/cli/toplevel.yaml b/test/integration/targets/nxos_config/tests/cli/toplevel.yaml deleted file mode 100644 index f495c51d52..0000000000 --- a/test/integration/targets/nxos_config/tests/cli/toplevel.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- debug: msg='START cli/toplevel.yaml' - -- name: setup - nxos_config: - lines: hostname {{ inventory_hostname_short }} - provider: "{{ cli }}" - match: none - -- name: configure top level command - nxos_config: - lines: hostname foo - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == true" - - "'hostname foo' in result.updates" - -- name: configure top level command idempotent check - nxos_config: - lines: hostname foo - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - nxos_config: - lines: hostname {{ inventory_hostname_short }} - provider: "{{ cli }}" - match: none - -- debug: msg='END cli/toplevel.yaml' diff --git a/test/integration/targets/nxos_config/tests/cli/backup.yaml b/test/integration/targets/nxos_config/tests/common/backup.yaml similarity index 83% rename from test/integration/targets/nxos_config/tests/cli/backup.yaml rename to test/integration/targets/nxos_config/tests/common/backup.yaml index 7133852a1f..6f7cd37b41 100644 --- a/test/integration/targets/nxos_config/tests/cli/backup.yaml +++ b/test/integration/targets/nxos_config/tests/common/backup.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/backup.yaml" +- debug: msg="START {{ connection.transport }}/backup.yaml" - name: setup nxos_config: @@ -9,7 +9,7 @@ parents: - interface Ethernet2/5 match: none - provider: "{{ cli }}" + provider: "{{ connection }}" - name: collect any backup files find: @@ -28,7 +28,7 @@ nxos_config: src: basic/config.j2 backup: yes - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -47,4 +47,4 @@ that: - "backup_files.files is defined" -- debug: msg="END cli/backup.yaml" +- debug: msg="END {{ connection.transport }}/backup.yaml" diff --git a/test/integration/targets/nxos_config/tests/nxapi/defaults.yaml b/test/integration/targets/nxos_config/tests/common/defaults.yaml similarity index 74% rename from test/integration/targets/nxos_config/tests/nxapi/defaults.yaml rename to test/integration/targets/nxos_config/tests/common/defaults.yaml index cc867d398a..84b8614b61 100644 --- a/test/integration/targets/nxos_config/tests/nxapi/defaults.yaml +++ b/test/integration/targets/nxos_config/tests/common/defaults.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START nxapi/defaults.yaml" +- debug: msg="START {{ connection.transport }}/defaults.yaml" - name: setup nxos_config: @@ -9,13 +9,13 @@ parents: - interface Ethernet2/5 match: none - provider: "{{ nxapi }}" + provider: "{{ connection }}" - name: configure device with defaults included nxos_config: src: defaults/config.j2 defaults: yes - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result - debug: var=result @@ -29,7 +29,7 @@ nxos_config: src: defaults/config.j2 defaults: yes - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result - debug: var=result @@ -39,4 +39,4 @@ - "result.changed == false" - "result.updates is not defined" -- debug: msg="END nxapi/defaults.yaml" +- debug: msg="END {{ connection.transport }}/defaults.yaml" diff --git a/test/integration/targets/nxos_config/tests/nxapi/save.yaml b/test/integration/targets/nxos_config/tests/common/save.yaml similarity index 65% rename from test/integration/targets/nxos_config/tests/nxapi/save.yaml rename to test/integration/targets/nxos_config/tests/common/save.yaml index bd14176b05..7f15f6c677 100644 --- a/test/integration/targets/nxos_config/tests/nxapi/save.yaml +++ b/test/integration/targets/nxos_config/tests/common/save.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START nxapi/save.yaml" +- debug: msg="START {{ connection.transport }}/save.yaml" - name: setup nxos_config: @@ -9,13 +9,13 @@ parents: - interface Ethernet2/5 match: none - provider: "{{ nxapi }}" + provider: "{{ connection }}" - name: save config nxos_config: save: true - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result - assert: @@ -25,11 +25,11 @@ - name: save should always run nxos_config: save: true - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result - assert: that: - "result.changed == true" -- debug: msg="END nxapi/save.yaml" +- debug: msg="END {{ connection.transport }}/save.yaml" diff --git a/test/integration/targets/nxos_config/tests/cli/src_basic.yaml b/test/integration/targets/nxos_config/tests/common/src_basic.yaml similarity index 75% rename from test/integration/targets/nxos_config/tests/cli/src_basic.yaml rename to test/integration/targets/nxos_config/tests/common/src_basic.yaml index 7d2c8717c1..e2d3287b6e 100644 --- a/test/integration/targets/nxos_config/tests/cli/src_basic.yaml +++ b/test/integration/targets/nxos_config/tests/common/src_basic.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/src_basic.yaml" +- debug: msg="START {{ connection.transport }}/src_basic.yaml" - name: setup nxos_config: @@ -9,13 +9,13 @@ parents: - interface Ethernet2/5 match: none - provider: "{{ cli }}" + provider: "{{ connection }}" - name: configure device with config nxos_config: src: basic/config.j2 defaults: yes - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -28,7 +28,7 @@ nxos_config: src: basic/config.j2 defaults: yes - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -37,4 +37,4 @@ # https://github.com/ansible/ansible-modules-core/issues/4807 - "result.updates is not defined" -- debug: msg="END cli/src_basic.yaml" +- debug: msg="END {{ connection.transport }}/src_basic.yaml" diff --git a/test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml b/test/integration/targets/nxos_config/tests/common/src_invalid.yaml similarity index 67% rename from test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml rename to test/integration/targets/nxos_config/tests/common/src_invalid.yaml index e670e4ef5b..e7400e5789 100644 --- a/test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml +++ b/test/integration/targets/nxos_config/tests/common/src_invalid.yaml @@ -1,12 +1,12 @@ --- -- debug: msg="START nxapi/src_invalid.yaml" +- debug: msg="START {{ connection.transport }}/src_invalid.yaml" # Defend https://github.com/ansible/ansible-modules-core/issues/4797 - name: configure with invalid src nxos_config: src: basic/foobar.j2 - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result ignore_errors: yes @@ -16,4 +16,4 @@ - "result.failed == true" - "result.msg == 'path specified in src not found'" -- debug: msg="END nxapi/src_invalid.yaml" +- debug: msg="END {{ connection.transport }}/src_invalid.yaml" diff --git a/test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml b/test/integration/targets/nxos_config/tests/common/toplevel.yaml similarity index 68% rename from test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml rename to test/integration/targets/nxos_config/tests/common/toplevel.yaml index c88026c410..0ff6b0b3bd 100644 --- a/test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml +++ b/test/integration/targets/nxos_config/tests/common/toplevel.yaml @@ -1,16 +1,16 @@ --- -- debug: msg="START nxapi/toplevel.yaml" +- debug: msg='START {{ connection.transport }}/toplevel.yaml' - name: setup nxos_config: lines: hostname {{ inventory_hostname_short }} - provider: "{{ nxapi }}" + provider: "{{ connection }}" match: none - name: configure top level command nxos_config: lines: hostname foo - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result - assert: @@ -21,7 +21,7 @@ - name: configure top level command idempotent check nxos_config: lines: hostname foo - provider: "{{ nxapi }}" + provider: "{{ connection }}" register: result - assert: @@ -31,7 +31,7 @@ - name: teardown nxos_config: lines: hostname {{ inventory_hostname_short }} - provider: "{{ nxapi }}" + provider: "{{ connection }}" match: none -- debug: msg="END nxapi/toplevel.yaml" +- debug: msg='END {{ connection.transport }}/toplevel.yaml' diff --git a/test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/nxos_config/tests/common/toplevel_nonidempotent.yaml similarity index 69% rename from test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml rename to test/integration/targets/nxos_config/tests/common/toplevel_nonidempotent.yaml index 1fd3bd9d77..e950a97430 100644 --- a/test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml +++ b/test/integration/targets/nxos_config/tests/common/toplevel_nonidempotent.yaml @@ -1,16 +1,16 @@ --- -- debug: msg="START cli/nonidempotent.yaml" +- debug: msg="START {{ connection.transport }}/nonidempotent.yaml" - name: setup nxos_config: lines: hostname {{ inventory_hostname_short }} - provider: "{{ cli }}" + provider: "{{ connection }}" match: none - name: configure top level command nxos_config: lines: hostname foo - provider: "{{ cli }}" + provider: "{{ connection }}" match: strict register: result @@ -22,7 +22,7 @@ - name: configure top level command idempotent check nxos_config: lines: hostname foo - provider: "{{ cli }}" + provider: "{{ connection }}" match: strict register: result @@ -33,7 +33,7 @@ - name: teardown nxos_config: lines: hostname {{ inventory_hostname_short }} - provider: "{{ cli }}" + provider: "{{ connection }}" match: none -- debug: msg="END cli/nonidempotent.yaml" +- debug: msg="END {{ connection.transport }}/nonidempotent.yaml" diff --git a/test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml b/test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml deleted file mode 100644 index 7ca8007557..0000000000 --- a/test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- debug: msg="START nxapi/src_basic.yaml" - -- name: setup - nxos_config: - commands: - - no description - - no shutdown - parents: - - interface Ethernet2/5 - match: none - provider: "{{ nxapi }}" - -- name: configure device with config - nxos_config: - src: basic/config.j2 - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == true" -# https://github.com/ansible/ansible-modules-core/issues/4807 - - "result.updates is defined" - -- name: check device with config - nxos_config: - src: basic/config.j2 - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == false" -# https://github.com/ansible/ansible-modules-core/issues/4807 - - "result.updates is not defined" - -- debug: msg="END nxapi/src_basic.yaml" diff --git a/test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml b/test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml deleted file mode 100644 index 7a99ac3f2a..0000000000 --- a/test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- debug: msg="START nxapi/toplevel_nonidempontent" - -- name: setup - nxos_config: - lines: hostname {{ inventory_hostname_short }} - provider: "{{ nxapi }}" - match: none - -- name: configure top level command - nxos_config: - lines: hostname foo - provider: "{{ nxapi }}" - match: strict - register: result - -- assert: - that: - - "result.changed == true" - - "'hostname foo' in result.updates" - -- name: configure top level command idempotent check - nxos_config: - lines: hostname foo - provider: "{{ nxapi }}" - match: strict - register: result - -- assert: - that: - - "result.changed == true" - -- name: setup - nxos_config: - lines: hostname {{ inventory_hostname_short }} - provider: "{{ nxapi }}" - match: none - -- debug: msg="END nxapi/toplevel_nonidempontent"