diff --git a/test/integration/targets/nxos_system/tasks/cli.yaml b/test/integration/targets/nxos_system/tasks/cli.yaml index 46d86dd698..0ab3f8f908 100644 --- a/test/integration/targets/nxos_system/tasks/cli.yaml +++ b/test/integration/targets/nxos_system/tasks/cli.yaml @@ -1,16 +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 - delegate_to: localhost + 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_system/tasks/nxapi.yaml b/test/integration/targets/nxos_system/tasks/nxapi.yaml index fc67dff230..e071f293a2 100644 --- a/test/integration/targets/nxos_system/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_system/tasks/nxapi.yaml @@ -1,10 +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 - delegate_to: localhost + 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 }}" @@ -17,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_system/tests/cli/set_hostname.yaml b/test/integration/targets/nxos_system/tests/common/set_hostname.yaml similarity index 62% rename from test/integration/targets/nxos_system/tests/cli/set_hostname.yaml rename to test/integration/targets/nxos_system/tests/common/set_hostname.yaml index 8d82137d7c..6c252dba18 100644 --- a/test/integration/targets/nxos_system/tests/cli/set_hostname.yaml +++ b/test/integration/targets/nxos_system/tests/common/set_hostname.yaml @@ -1,16 +1,16 @@ --- -- debug: msg="START cli/set_hostname.yaml" +- debug: msg="START {{ connection.transport }}/set_hostname.yaml" - name: setup nxos_config: lines: hostname switch match: none - provider: "{{ cli }}" + provider: "{{ connection }}" - name: configure hostname nxos_system: hostname: foo - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -20,7 +20,7 @@ - name: verify hostname nxos_system: hostname: foo - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -31,6 +31,6 @@ nxos_config: lines: "hostname {{ inventory_hostname }}" match: none - provider: "{{ cli }}" + provider: "{{ connection }}" -- debug: msg="END cli/set_hostname.yaml" +- debug: msg="END {{ connection.transport }}/set_hostname.yaml" diff --git a/test/integration/targets/nxos_system/tests/cli/set_lookup_source.yaml-not-on-nxos b/test/integration/targets/nxos_system/tests/common/set_lookup_source.yaml-not-on-nxos similarity index 78% rename from test/integration/targets/nxos_system/tests/cli/set_lookup_source.yaml-not-on-nxos rename to test/integration/targets/nxos_system/tests/common/set_lookup_source.yaml-not-on-nxos index 4a39a49882..087209245d 100644 --- a/test/integration/targets/nxos_system/tests/cli/set_lookup_source.yaml-not-on-nxos +++ b/test/integration/targets/nxos_system/tests/common/set_lookup_source.yaml-not-on-nxos @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/set_lookup_source.yaml" +- debug: msg="START {{ connection.transport }}/set_lookup_source.yaml" - name: setup nxos_config: @@ -7,12 +7,12 @@ - no ip domain lookup source-interface - vrf definition ansible match: none - provider: "{{ cli }}" + provider: "{{ connection }}" - name: configure lookup_source nxos_system: lookup_source: Management1 - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -23,7 +23,7 @@ - name: verify lookup_source nxos_system: lookup_source: Management1 - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -35,7 +35,7 @@ lookup_source: - interface: Management1 vrf: ansible - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -50,7 +50,7 @@ lookup_source: - interface: Management1 vrf: ansible - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -63,6 +63,6 @@ - no ip domain lookup source-interface - no vrf definition ansible match: none - provider: "{{ cli }}" + provider: "{{ connection }}" -- debug: msg="END cli/set_lookup_source.yaml" +- debug: msg="END {{ connection.transport }}/set_lookup_source.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_hostname.yaml b/test/integration/targets/nxos_system/tests/nxapi/set_hostname.yaml deleted file mode 100644 index 74398c800a..0000000000 --- a/test/integration/targets/nxos_system/tests/nxapi/set_hostname.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- debug: msg="START nxapi/set_hostname.yaml" - -- name: setup - nxos_config: - lines: hostname switch - match: none - provider: "{{ nxapi }}" - -- name: configure hostname - nxos_system: - hostname: foo - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify hostname - nxos_system: - hostname: foo - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - nxos_config: - lines: "hostname {{ inventory_hostname }}" - match: none - provider: "{{ nxapi }}" - -- debug: msg="END nxapi/set_hostname.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_lookup_source.yaml-not-on-nxos b/test/integration/targets/nxos_system/tests/nxapi/set_lookup_source.yaml-not-on-nxos deleted file mode 100644 index 7a39bb2492..0000000000 --- a/test/integration/targets/nxos_system/tests/nxapi/set_lookup_source.yaml-not-on-nxos +++ /dev/null @@ -1,68 +0,0 @@ ---- -- debug: msg="START nxapi/set_lookup_source.yaml" - -- name: setup - nxos_config: - lines: - - no ip domain lookup source-interface - - vrf definition ansible - match: none - provider: "{{ nxapi }}" - -- name: configure lookup_source - nxos_system: - lookup_source: Management1 - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - result.changed == true - - "'ip domain lookup source-interface Management1' in result.commands" - -- name: verify lookup_source - nxos_system: - lookup_source: Management1 - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - result.changed == false - -- name: change to vrf - nxos_system: - lookup_source: - - interface: Management1 - vrf: ansible - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - result.changed == true - - "'no ip domain lookup source-interface Management1' in result.commands" - - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" - - result.commands|length == 2 - -- name: verify change to vrf - nxos_system: - lookup_source: - - interface: Management1 - vrf: ansible - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - result.changed == false - -- name: teardown - nxos_config: - lines: - - no ip domain lookup source-interface - - no vrf definition ansible - match: none - provider: "{{ nxapi }}" - -- debug: msg="END nxapi/set_lookup_source.yaml" diff --git a/test/integration/targets/nxos_user/tasks/cli.yaml b/test/integration/targets/nxos_user/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_user/tasks/cli.yaml +++ b/test/integration/targets/nxos_user/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_user/tasks/nxapi.yaml b/test/integration/targets/nxos_user/tasks/nxapi.yaml index 5fb9cedaa6..e071f293a2 100644 --- a/test/integration/targets/nxos_user/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_user/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 }}" @@ -14,10 +24,9 @@ - feature nxapi - nxapi http port 80 provider: "{{ cli }}" - timeout: 100 - 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 @@ -27,4 +36,3 @@ lines: - no feature nxapi provider: "{{ cli }}" - timeout: 100 diff --git a/test/integration/targets/nxos_user/tests/cli/basic.yaml b/test/integration/targets/nxos_user/tests/common/basic.yaml similarity index 87% rename from test/integration/targets/nxos_user/tests/cli/basic.yaml rename to test/integration/targets/nxos_user/tests/common/basic.yaml index 44a46a28d7..764156a6ac 100644 --- a/test/integration/targets/nxos_user/tests/cli/basic.yaml +++ b/test/integration/targets/nxos_user/tests/common/basic.yaml @@ -6,7 +6,7 @@ - name: ansibletest2 - name: ansibletest3 state: absent - provider: "{{ cli }}" + provider: "{{ connection }}" # Start tests - name: Create user @@ -14,7 +14,7 @@ name: ansibletest1 roles: network-operator state: present - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -30,7 +30,7 @@ - name: ansibletest3 state: present roles: network-admin - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -44,7 +44,7 @@ - name: ansibletest2 - name: ansibletest3 state: absent - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: diff --git a/test/integration/targets/nxos_user/tests/nxapi/basic.yaml b/test/integration/targets/nxos_user/tests/nxapi/basic.yaml deleted file mode 100644 index 553193955a..0000000000 --- a/test/integration/targets/nxos_user/tests/nxapi/basic.yaml +++ /dev/null @@ -1,53 +0,0 @@ ---- -- name: Remove old entries of user - nxos_user: - aggregate: - - name: ansibletest1 - - name: ansibletest2 - - name: ansibletest3 - state: absent - provider: "{{ nxapi }}" - -# Start tests -- name: Create user - nxos_user: - name: ansibletest1 - roles: network-operator - state: present - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - 'result.changed == true' - - '"username" in result.commands[0]' - - '"role network-operator" in result.commands[1]' - -- name: Collection of users - nxos_user: - aggregate: - - name: ansibletest2 - - name: ansibletest3 - state: present - roles: network-admin - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - 'result.changed == true' - -- name: tearDown - nxos_user: - aggregate: - - name: ansibletest1 - - name: ansibletest2 - - name: ansibletest3 - state: absent - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - 'result.changed == true' - - '"no username" in result.commands[0]' diff --git a/test/integration/targets/nxos_vlan/tasks/cli.yaml b/test/integration/targets/nxos_vlan/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_vlan/tasks/cli.yaml +++ b/test/integration/targets/nxos_vlan/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_vlan/tasks/nxapi.yaml b/test/integration/targets/nxos_vlan/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_vlan/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_vlan/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_vlan/tests/cli/sanity.yaml b/test/integration/targets/nxos_vlan/tests/cli/sanity.yaml deleted file mode 100644 index d1bc8aa2a9..0000000000 --- a/test/integration/targets/nxos_vlan/tests/cli/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ cli }}" - -- import_tasks: targets/nxos_vlan/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_vlan/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vlan/tests/nxapi/sanity.yaml deleted file mode 100644 index 1613c28ce8..0000000000 --- a/test/integration/targets/nxos_vlan/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ nxapi }}" - -- import_tasks: targets/nxos_vlan/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_vrf/tasks/cli.yaml b/test/integration/targets/nxos_vrf/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_vrf/tasks/cli.yaml +++ b/test/integration/targets/nxos_vrf/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_vrf/tasks/nxapi.yaml b/test/integration/targets/nxos_vrf/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_vrf/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_vrf/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_vrf/tests/cli/sanity.yaml b/test/integration/targets/nxos_vrf/tests/cli/sanity.yaml deleted file mode 100644 index 8b02508be0..0000000000 --- a/test/integration/targets/nxos_vrf/tests/cli/sanity.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- debug: msg="START TRANSPORT:CLI nxos_vrf sanity test" - -- name: Ensure ntc VRF exists on switch - nxos_vrf: - vrf: ntc - provider: "{{ cli }}" - -- name: Ensure ntc VRF does not exist on switch - nxos_vrf: - vrf: ntc - state: absent - provider: "{{ cli }}" - -- debug: msg="END TRANSPORT:CLI nxos_vrf sanity test" diff --git a/test/integration/targets/nxos_vrf/tests/common/sanity.yaml b/test/integration/targets/nxos_vrf/tests/common/sanity.yaml new file mode 100644 index 0000000000..2f6cad64e4 --- /dev/null +++ b/test/integration/targets/nxos_vrf/tests/common/sanity.yaml @@ -0,0 +1,15 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vrf sanity test" + +- name: Ensure ntc VRF exists on switch + nxos_vrf: + vrf: ntc + provider: "{{ connection }}" + +- name: Ensure ntc VRF does not exist on switch + nxos_vrf: + vrf: ntc + state: absent + provider: "{{ connection }}" + +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vrf sanity test" diff --git a/test/integration/targets/nxos_vrf/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vrf/tests/nxapi/sanity.yaml deleted file mode 100644 index ca7bab1959..0000000000 --- a/test/integration/targets/nxos_vrf/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_vrf sanity test" - -- name: Ensure ntc VRF exists on switch - nxos_vrf: - vrf: ntc - provider: "{{ nxapi }}" - -- name: Ensure ntc VRF does not exist on switch - nxos_vrf: - vrf: ntc - state: absent - provider: "{{ nxapi }}" - -- debug: msg="END TRANSPORT:NXAPI nxos_vrf sanity test"