diff --git a/test/integration/targets/nxos_evpn_global/tasks/cli.yaml b/test/integration/targets/nxos_evpn_global/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_evpn_global/tasks/cli.yaml +++ b/test/integration/targets/nxos_evpn_global/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_evpn_global/tasks/nxapi.yaml b/test/integration/targets/nxos_evpn_global/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_evpn_global/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_evpn_global/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_evpn_global/tests/cli/sanity.yaml b/test/integration/targets/nxos_evpn_global/tests/connection/sanity.yaml similarity index 75% rename from test/integration/targets/nxos_evpn_global/tests/cli/sanity.yaml rename to test/integration/targets/nxos_evpn_global/tests/connection/sanity.yaml index ac3290b580..3ceabd7d6a 100644 --- a/test/integration/targets/nxos_evpn_global/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_evpn_global/tests/connection/sanity.yaml @@ -1,18 +1,18 @@ --- -- debug: msg="START TRANSPORT:CLI nxos_evpn_global sanity test" +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_evpn_global sanity test" - name: "Setup" nxos_config: &remove_evpn_config lines: no nv overlay evpn match: none - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: "Disable feature nv overlay" nxos_feature: &disable_feature_nv_overlay feature: nv overlay state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - block: @@ -20,13 +20,13 @@ nxos_feature: &enable_feature_nv_overlay feature: nv overlay state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: "Enable nv overlay evpn" nxos_evpn_global: &enable_evpn nv_overlay_evpn: true - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: &true @@ -44,7 +44,7 @@ - name: "Disable nv overlay evpn" nxos_evpn_global: &disable_evpn nv_overlay_evpn: false - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -58,7 +58,7 @@ when: not (platform | search('N3K')) rescue: - - debug: msg="TRANSPORT:CLI nxos_evpn_global sanity test - FALURE ENCOUNTERED" + - debug: msg="TRANSPORT:{{ connection.transport }} nxos_evpn_global sanity test - FALURE ENCOUNTERED" always: @@ -70,4 +70,4 @@ nxos_feature: *disable_feature_nv_overlay ignore_errors: yes - - debug: msg="END TRANSPORT:CLI nxos_evpn_global sanity test" + - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_evpn_global sanity test" diff --git a/test/integration/targets/nxos_evpn_global/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_evpn_global/tests/nxapi/sanity.yaml deleted file mode 100644 index d368a20df6..0000000000 --- a/test/integration/targets/nxos_evpn_global/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,73 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_evpn_global sanity test" - -- name: "Setup" - nxos_config: &remove_evpn_config - lines: no nv overlay evpn - match: none - provider: "{{ nxapi }}" - ignore_errors: yes - -- name: "Disable feature nv overlay" - nxos_feature: &disable_feature_nv_overlay - feature: nv overlay - state: disabled - provider: "{{ nxapi }}" - ignore_errors: yes - -- block: - - name: "Enable feature nv overlay" - nxos_feature: &enable_feature_nv_overlay - feature: nv overlay - state: enabled - provider: "{{ nxapi }}" - ignore_errors: yes - - - name: "Enable nv overlay evpn" - nxos_evpn_global: &enable_evpn - nv_overlay_evpn: true - provider: "{{ nxapi }}" - register: result - - - assert: &true - that: - - "result.changed == true" - - - name: "CHECK IDEMPOTENCE - enable nv overlay evpn" - nxos_evpn_global: *enable_evpn - register: result - - - assert: &false - that: - - "result.changed == false" - - - name: "Disable nv overlay evpn" - nxos_evpn_global: &disable_evpn - nv_overlay_evpn: false - provider: "{{ nxapi }}" - register: result - - - assert: *true - - - name: "CHECK DEMPOTENCE - Disable nv overlay evpn" - nxos_evpn_global: *disable_evpn - register: result - - - assert: *false - - when: not (platform | search('N3K')) - - rescue: - - debug: msg="TRANSPORT:NXAPI nxos_evpn_global sanity test - FALURE ENCOUNTERED" - - always: - - - name: "Cleanup - Disable nv overlay evpn" - nxos_config: *remove_evpn_config - ignore_errors: yes - - - name: "Cleanup - Disable feature nv overlay" - nxos_feature: *disable_feature_nv_overlay - ignore_errors: yes - - - debug: msg="END TRANSPORT:NXAPI nxos_evpn_global sanity test" diff --git a/test/integration/targets/nxos_evpn_vni/tasks/cli.yaml b/test/integration/targets/nxos_evpn_vni/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_evpn_vni/tasks/cli.yaml +++ b/test/integration/targets/nxos_evpn_vni/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_evpn_vni/tasks/nxapi.yaml b/test/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_evpn_vni/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_evpn_vni/tests/cli/sanity.yaml b/test/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml similarity index 73% rename from test/integration/targets/nxos_evpn_vni/tests/cli/sanity.yaml rename to test/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml index d2b963cb5b..c37adfaf19 100644 --- a/test/integration/targets/nxos_evpn_vni/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml @@ -1,24 +1,24 @@ --- -- debug: msg="START TRANSPORT:CLI nxos_evpn_vni sanity test" +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_evpn_vni sanity test" - name: "Setup" nxos_config: &remove_evpn lines: no nv overlay evpn - provider: "{{ cli }}" + provider: "{{ connection }}" match: none ignore_errors: yes - block: - name: "Enable feature BGP" - nxos_feature: + nxos_feature: feature: bgp state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" - name: "Enable nv overlay evpn" - nxos_config: + nxos_config: lines: nv overlay evpn - provider: "{{ cli }}" + provider: "{{ connection }}" match: none - name: "Configure nxos_evpn_vni" @@ -29,7 +29,7 @@ - "5000:10" - "4100:100" route_target_export: auto - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: &true @@ -48,7 +48,7 @@ nxos_evpn_vni: &rvni vni: 6000 state: absent - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: *true @@ -65,10 +65,10 @@ ignore_errors: yes - name: "Disable feature bgp" - nxos_feature: + nxos_feature: feature: bgp state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes -- debug: msg="END TRANSPORT:CLI nxos_evpn_vni sanity test" +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_evpn_vni sanity test" diff --git a/test/integration/targets/nxos_evpn_vni/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_evpn_vni/tests/nxapi/sanity.yaml deleted file mode 100644 index 83123c493a..0000000000 --- a/test/integration/targets/nxos_evpn_vni/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,74 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_evpn_vni sanity test" - -- name: "Setup" - nxos_config: &remove_evpn - lines: no nv overlay evpn - provider: "{{ nxapi }}" - match: none - ignore_errors: yes - -- block: - - name: "Enable feature BGP" - nxos_feature: - feature: bgp - state: enabled - provider: "{{ nxapi }}" - - - name: "Enable nv overlay evpn" - nxos_config: - lines: nv overlay evpn - provider: "{{ nxapi }}" - match: none - - - name: "Configure nxos_evpn_vni" - nxos_evpn_vni: &evpn_vni - vni: 6000 - route_distinguisher: "60:10" - route_target_import: - - "5000:10" - - "4100:100" - route_target_export: auto - provider: "{{ nxapi }}" - register: result - - - assert: &true - that: - - "result.changed == true" - - - name: "Check Idempotence" - nxos_evpn_vni: *evpn_vni - register: result - - - assert: &false - that: - - "result.changed == false" - - - name: "remove nxos_evpn_vni" - nxos_evpn_vni: &rvni - vni: 6000 - state: absent - provider: "{{ nxapi }}" - register: result - - - assert: *true - - - name: "Check Idempotence" - nxos_evpn_vni: *rvni - register: result - - - assert: *false - - always: - - name: "Remove nv overlay evpn" - nxos_config: *remove_evpn - ignore_errors: yes - - - name: "Disable feature bgp" - nxos_feature: - feature: bgp - state: disabled - provider: "{{ nxapi }}" - ignore_errors: yes - -- debug: msg="END TRANSPORT:NXAPI nxos_evpn_vni sanity test" diff --git a/test/integration/targets/nxos_facts/tasks/cli.yaml b/test/integration/targets/nxos_facts/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_facts/tasks/cli.yaml +++ b/test/integration/targets/nxos_facts/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_facts/tasks/nxapi.yaml b/test/integration/targets/nxos_facts/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_facts/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_facts/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_facts/tests/cli/all_facts.yaml b/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml deleted file mode 100644 index a90e51f62a..0000000000 --- a/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- debug: msg="START cli/all_facts.yaml" - - -- name: test getting all facts - nxos_facts: - provider: "{{ cli }}" - gather_subset: - - all - register: result - - - -- assert: - that: - # _facts modules should never report a change - - "result.changed == false" - - # Correct subsets are present - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" - - # Items from those subsets are present - - "result.ansible_facts.ansible_net_filesystems is defined" - - "result.ansible_facts.ansible_net_interfaces is defined" - - "result.ansible_facts.ansible_net_config is defined" - - "result.ansible_facts.ansible_net_model is defined" - - # Check that these facts not only are present, but are valid (positive integers) - - "result.ansible_facts.ansible_net_memfree_mb > 1" - - "result.ansible_facts.ansible_net_memtotal_mb > 1" - -- debug: msg="END cli/all_facts.yaml" diff --git a/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml b/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml deleted file mode 100644 index d35d544701..0000000000 --- a/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- debug: msg="START cli/not_hardware_facts.yaml" - - -- name: test not hardware - nxos_facts: - provider: "{{ cli }}" - gather_subset: - - "!hardware" - register: result - -- assert: - that: - # _facts modules should never report a change - - "result.changed == false" - - # Correct subsets are present - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" - - # ... and not present - - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" - - # Items from those subsets are present - # FIXME - # - "result.ansible_facts.ansible_net_interfaces.['Ethernet2/15'].mtu > 1" # interfaces - # ... and not present - - "result.ansible_facts.ansible_net_filesystems is not defined" - -- debug: msg="END cli/not_hardware_facts.yaml" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml b/test/integration/targets/nxos_facts/tests/common/all_facts.yaml similarity index 86% rename from test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml rename to test/integration/targets/nxos_facts/tests/common/all_facts.yaml index d3fac5a141..60939abab7 100644 --- a/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml +++ b/test/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -1,10 +1,10 @@ --- -- debug: msg="START nxapi/all_facts.yaml" +- debug: msg="START {{ connection.transport }}/all_facts.yaml" - name: test getting all facts nxos_facts: - provider: "{{ nxapi }}" + provider: "{{ connection }}" gather_subset: - all timeout: 60 @@ -33,4 +33,4 @@ - "result.ansible_facts.ansible_net_memfree_mb > 1" - "result.ansible_facts.ansible_net_memtotal_mb > 1" -- debug: msg="END nxapi/all_facts.yaml" +- debug: msg="END {{ connection.transport }}/all_facts.yaml" diff --git a/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml b/test/integration/targets/nxos_facts/tests/common/default_facts.yaml similarity index 92% rename from test/integration/targets/nxos_facts/tests/cli/default_facts.yaml rename to test/integration/targets/nxos_facts/tests/common/default_facts.yaml index dd03425384..45a94accef 100644 --- a/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml +++ b/test/integration/targets/nxos_facts/tests/common/default_facts.yaml @@ -1,10 +1,10 @@ --- -- debug: msg="START cli/default_facts.yaml" +- debug: msg="START {{ connection.transport }}/default_facts.yaml" - name: test getting default facts nxos_facts: - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: diff --git a/test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml b/test/integration/targets/nxos_facts/tests/common/invalid_subset.yaml similarity index 80% rename from test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml rename to test/integration/targets/nxos_facts/tests/common/invalid_subset.yaml index baf183eec3..93d0131d9b 100644 --- a/test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml +++ b/test/integration/targets/nxos_facts/tests/common/invalid_subset.yaml @@ -1,10 +1,10 @@ --- -- debug: msg="START cli/invalid_subset.yaml" +- debug: msg="START {{ connection.transport }}/invalid_subset.yaml" - name: test invalid subset (foobar) nxos_facts: - provider: "{{ cli }}" + provider: "{{ connection }}" gather_subset: - "foobar" register: result @@ -26,7 +26,7 @@ - name: test subset specified multiple times nxos_facts: - provider: "{{ cli }}" + provider: "{{ connection }}" gather_subset: - "!hardware" - "hardware" @@ -45,4 +45,4 @@ -- debug: msg="END cli/invalid_subset.yaml" +- debug: msg="END {{ connection.transport }}/invalid_subset.yaml" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml b/test/integration/targets/nxos_facts/tests/common/not_hardware.yaml similarity index 82% rename from test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml rename to test/integration/targets/nxos_facts/tests/common/not_hardware.yaml index 8abe3dd6f5..66dd0b1e78 100644 --- a/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml +++ b/test/integration/targets/nxos_facts/tests/common/not_hardware.yaml @@ -1,10 +1,10 @@ --- -- debug: msg="START nxapi/not_hardware_facts.yaml" +- debug: msg="START {{ connection.transport }}/not_hardware_facts.yaml" - name: test not hardware nxos_facts: - provider: "{{ nxapi }}" + provider: "{{ connection }}" gather_subset: - "!hardware" timeout: 30 @@ -29,4 +29,4 @@ # ... and not present - "result.ansible_facts.ansible_net_filesystems is not defined" -- debug: msg="END nxapi/not_hardware_facts.yaml" +- debug: msg="END {{ connection.transport }}/not_hardware_facts.yaml" diff --git a/test/integration/targets/nxos_facts/tests/cli/sanity.yaml b/test/integration/targets/nxos_facts/tests/common/sanity.yaml similarity index 90% rename from test/integration/targets/nxos_facts/tests/cli/sanity.yaml rename to test/integration/targets/nxos_facts/tests/common/sanity.yaml index 8ef2d46163..77c9bade21 100644 --- a/test/integration/targets/nxos_facts/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_facts/tests/common/sanity.yaml @@ -1,10 +1,10 @@ --- -- debug: msg="START TRANSPORT:CLI nxos_facts sanity test" +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_facts sanity test" - name: "nxos_facts gather hardware facts" nxos_facts: gather_subset: hardware - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -29,7 +29,7 @@ - name: "nxos_facts gather config facts" nxos_facts: gather_subset: config - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -52,7 +52,7 @@ gather_subset: - hardware - config - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -75,4 +75,4 @@ - "result.ansible_facts.ansible_net_memfree_mb > 1" - "result.ansible_facts.ansible_net_memtotal_mb > 1" -- debug: msg="END TRANSPORT:CLI nxos_facts sanity test" +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_facts sanity test" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml b/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml deleted file mode 100644 index 412993abb4..0000000000 --- a/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- debug: msg="START nxapi/default_facts.yaml" - - -- name: test getting default facts - nxos_facts: - provider: "{{ nxapi }}" - register: result - -- assert: - that: - # _facts modules should never report a change - - "result.changed == false" - - # Correct subsets are present - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" - - "result.ansible_facts.ansible_net_filesystems is defined" - # ... and not present - - "'config' not in result.ansible_facts.ansible_net_gather_subset" - - # Items from those subsets are present - - "result.ansible_facts.ansible_net_filesystems is defined" #hw - - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw - - "result.ansible_facts.ansible_net_model is defined" #default - - "result.ansible_facts.ansible_net_interfaces is defined" #interfaces - # FIXME -# - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces - - # ... and not present - - "result.ansible_facts.ansible_net_config is not defined" # config - -- debug: msg="END nxapi/default.yaml" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml b/test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml deleted file mode 100644 index 6b108c3dbf..0000000000 --- a/test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -- debug: msg="START nxapi/invalid_subset.yaml" - - -- name: test invalid subset (foobar) - nxos_facts: - provider: "{{ nxapi }}" - gather_subset: - - "foobar" - register: result - ignore_errors: true - - -- assert: - that: - # Failures shouldn't return changes - - "result.changed == false" - # It's a failure - - "result.failed == true" - # Sensible Failure message - - "result.msg == 'Bad subset'" - -############### -# FIXME Future -# We may in the future want to add a test for - -- name: test subset specified multiple times - nxos_facts: - provider: "{{ nxapi }}" - gather_subset: - - "!hardware" - - "hardware" - register: result - ignore_errors: true - -- assert: - that: - # Failures shouldn't return changes - - "result.changed == false" - # It's a failure - - "result.failed == true" - # Sensible Failure message - - "result.msg == 'Bad subset'" - ignore_errors: true - - - -- debug: msg="END nxapi/invalid_subset.yaml" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_facts/tests/nxapi/sanity.yaml deleted file mode 100644 index adbf415697..0000000000 --- a/test/integration/targets/nxos_facts/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,78 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_facts sanity test" - -- name: "nxos_facts gather hardware facts" - nxos_facts: - gather_subset: hardware - provider: "{{ nxapi }}" - register: result - -- assert: - that: - # _facts modules should never report a change - - "result.changed == false" - - # Correct subsets are present - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - # Other facts are not present - - "'config' not in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - - # Items from those subsets are present - - "result.ansible_facts.ansible_net_filesystems is defined" - - # Check that these facts not only are present, but are valid (positive integers) - - "result.ansible_facts.ansible_net_memfree_mb > 1" - - "result.ansible_facts.ansible_net_memtotal_mb > 1" - -- name: "nxos_facts gather config facts" - nxos_facts: - gather_subset: config - provider: "{{ nxapi }}" - register: result - -- assert: - that: - # _facts modules should never report a change - - "result.changed == false" - - # Correct subsets are present - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - # Other facts are not present - - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - - # Items from those subsets are present - - "result.ansible_facts.ansible_net_config is defined" - -- name: "nxos_facts gather config and hardware facts" - nxos_facts: - gather_subset: - - hardware - - config - provider: "{{ nxapi }}" - register: result - -- assert: - that: - # _facts modules should never report a change - - "result.changed == false" - - # Correct subsets are present - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - # Other facts are not present - - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - - # Items from those subsets are present - - "result.ansible_facts.ansible_net_filesystems is defined" - - "result.ansible_facts.ansible_net_config is defined" - - # Check that these facts not only are present, but are valid (positive integers) - - "result.ansible_facts.ansible_net_memfree_mb > 1" - - "result.ansible_facts.ansible_net_memtotal_mb > 1" - -- debug: msg="END TRANSPORT:NXAPI nxos_facts sanity test" diff --git a/test/integration/targets/nxos_feature/tasks/cli.yaml b/test/integration/targets/nxos_feature/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_feature/tasks/cli.yaml +++ b/test/integration/targets/nxos_feature/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_feature/tasks/nxapi.yaml b/test/integration/targets/nxos_feature/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_feature/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_feature/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_feature/tests/cli/configure.yaml b/test/integration/targets/nxos_feature/tests/common/configure.yaml similarity index 69% rename from test/integration/targets/nxos_feature/tests/cli/configure.yaml rename to test/integration/targets/nxos_feature/tests/common/configure.yaml index 61fa71a8bc..edc4dd1858 100644 --- a/test/integration/targets/nxos_feature/tests/cli/configure.yaml +++ b/test/integration/targets/nxos_feature/tests/common/configure.yaml @@ -1,17 +1,17 @@ --- -- debug: msg="START cli/configure.yaml" +- debug: msg="START {{ connection.transport }}/configure.yaml" - name: setup nxos_config: lines: no feature bgp match: none - provider: "{{ cli }}" + provider: "{{ connection }}" - name: enable bgp nxos_feature: feature: bgp state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -22,7 +22,7 @@ nxos_feature: feature: bgp state: enabled - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -33,7 +33,7 @@ nxos_feature: feature: bgp state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -44,7 +44,7 @@ nxos_feature: feature: bgp state: disabled - provider: "{{ cli }}" + provider: "{{ connection }}" register: result - assert: @@ -55,6 +55,6 @@ nxos_config: lines: no feature bgp match: none - provider: "{{ cli }}" + provider: "{{ connection }}" -- debug: msg="END cli/configure.yaml" +- debug: msg="END {{ connection.transport }}/configure.yaml" diff --git a/test/integration/targets/nxos_feature/tests/cli/invalid.yaml b/test/integration/targets/nxos_feature/tests/common/invalid.yaml similarity index 53% rename from test/integration/targets/nxos_feature/tests/cli/invalid.yaml rename to test/integration/targets/nxos_feature/tests/common/invalid.yaml index 7e198b61b2..dbdf6d3f41 100644 --- a/test/integration/targets/nxos_feature/tests/cli/invalid.yaml +++ b/test/integration/targets/nxos_feature/tests/common/invalid.yaml @@ -1,10 +1,10 @@ --- -- debug: msg="START cli/invalid.yaml" +- debug: msg="START {{ connection.transport }}/invalid.yaml" - name: configure invalid feature name nxos_feature: feature: invalid - provider: "{{ cli }}" + provider: "{{ connection }}" register: result ignore_errors: yes @@ -12,4 +12,4 @@ that: - result.failed == true -- debug: msg="END cli/invalid.yaml" +- debug: msg="END {{ connection.transport }}/invalid.yaml" diff --git a/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml b/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml deleted file mode 100644 index 7c5d003cb5..0000000000 --- a/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- debug: msg="START nxapi/configure.yaml" - -- name: setup - nxos_config: - lines: no feature bgp - match: none - provider: "{{ nxapi }}" - -- name: enable bgp - nxos_feature: - feature: bgp - state: enabled - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify bgp - nxos_feature: - feature: bgp - state: enabled - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == false" - -- name: disable bgp - nxos_feature: - feature: bgp - state: disabled - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify bgp - nxos_feature: - feature: bgp - state: disabled - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - nxos_config: - lines: no feature bgp - match: none - provider: "{{ nxapi }}" - -- debug: msg="END nxapi/configure.yaml" diff --git a/test/integration/targets/nxos_feature/tests/nxapi/invalid.yaml b/test/integration/targets/nxos_feature/tests/nxapi/invalid.yaml deleted file mode 100644 index 19223a20c3..0000000000 --- a/test/integration/targets/nxos_feature/tests/nxapi/invalid.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- debug: msg="START nxapi/invalid.yaml" - -- name: configure invalid feature name - nxos_feature: - feature: invalid - provider: "{{ nxapi }}" - register: result - ignore_errors: yes - -- assert: - that: - - result.failed == true - -- debug: msg="END nxapi/invalid.yaml"