From c810a62db966a5396d1ec9e762334cb9bf22751b Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Thu, 17 Aug 2017 04:35:33 -0400 Subject: [PATCH] nxos: merge nxapi/cli tests - ospf, portchannel, rollback, switchport (#28240) * refactor nxos_ospf * refactor nxos_portchannel * refactor nxos_rollback * refactor nxos_switchport --- .../targets/nxos_ospf/tasks/cli.yaml | 16 ++++++++-- .../targets/nxos_ospf/tasks/nxapi.yaml | 16 ++++++++-- .../targets/nxos_ospf/tests/cli/sanity.yaml | 4 --- .../targets/nxos_ospf/tests/nxapi/sanity.yaml | 4 --- .../targets/nxos_portchannel/tasks/cli.yaml | 16 ++++++++-- .../targets/nxos_portchannel/tasks/nxapi.yaml | 16 ++++++++-- .../nxos_portchannel/tests/cli/sanity.yaml | 4 --- .../nxos_portchannel/tests/nxapi/sanity.yaml | 4 --- .../targets/nxos_rollback/tasks/cli.yaml | 16 ++++++++-- .../targets/nxos_rollback/tasks/nxapi.yaml | 16 ++++++++-- .../tests/{cli => common}/sanity.yaml | 10 +++---- .../nxos_rollback/tests/nxapi/sanity.yaml | 29 ------------------- .../targets/nxos_switchport/tasks/cli.yaml | 16 ++++++++-- .../targets/nxos_switchport/tasks/nxapi.yaml | 16 ++++++++-- .../nxos_switchport/tests/cli/sanity.yaml | 4 --- .../nxos_switchport/tests/nxapi/sanity.yaml | 4 --- 16 files changed, 109 insertions(+), 82 deletions(-) delete mode 100644 test/integration/targets/nxos_ospf/tests/cli/sanity.yaml delete mode 100644 test/integration/targets/nxos_ospf/tests/nxapi/sanity.yaml delete mode 100644 test/integration/targets/nxos_portchannel/tests/cli/sanity.yaml delete mode 100644 test/integration/targets/nxos_portchannel/tests/nxapi/sanity.yaml rename test/integration/targets/nxos_rollback/tests/{cli => common}/sanity.yaml (63%) delete mode 100644 test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml delete mode 100644 test/integration/targets/nxos_switchport/tests/cli/sanity.yaml delete mode 100644 test/integration/targets/nxos_switchport/tests/nxapi/sanity.yaml diff --git a/test/integration/targets/nxos_ospf/tasks/cli.yaml b/test/integration/targets/nxos_ospf/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_ospf/tasks/cli.yaml +++ b/test/integration/targets/nxos_ospf/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_ospf/tasks/nxapi.yaml b/test/integration/targets/nxos_ospf/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_ospf/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_ospf/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_ospf/tests/cli/sanity.yaml b/test/integration/targets/nxos_ospf/tests/cli/sanity.yaml deleted file mode 100644 index f207b01258..0000000000 --- a/test/integration/targets/nxos_ospf/tests/cli/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ cli }}" - -- import_tasks: targets/nxos_ospf/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_ospf/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_ospf/tests/nxapi/sanity.yaml deleted file mode 100644 index 15af0691a9..0000000000 --- a/test/integration/targets/nxos_ospf/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ nxapi }}" - -- import_tasks: targets/nxos_ospf/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_portchannel/tasks/cli.yaml b/test/integration/targets/nxos_portchannel/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_portchannel/tasks/cli.yaml +++ b/test/integration/targets/nxos_portchannel/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_portchannel/tasks/nxapi.yaml b/test/integration/targets/nxos_portchannel/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_portchannel/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_portchannel/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_portchannel/tests/cli/sanity.yaml b/test/integration/targets/nxos_portchannel/tests/cli/sanity.yaml deleted file mode 100644 index 420af7420e..0000000000 --- a/test/integration/targets/nxos_portchannel/tests/cli/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ cli }}" - -- import_tasks: "{{ role_path }}/tests/common/sanity.yaml" diff --git a/test/integration/targets/nxos_portchannel/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_portchannel/tests/nxapi/sanity.yaml deleted file mode 100644 index e30ea6eaf7..0000000000 --- a/test/integration/targets/nxos_portchannel/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ nxapi }}" - -- import_tasks: "{{ role_path }}/tests/common/sanity.yaml" diff --git a/test/integration/targets/nxos_rollback/tasks/cli.yaml b/test/integration/targets/nxos_rollback/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_rollback/tasks/cli.yaml +++ b/test/integration/targets/nxos_rollback/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_rollback/tasks/nxapi.yaml b/test/integration/targets/nxos_rollback/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_rollback/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_rollback/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_rollback/tests/cli/sanity.yaml b/test/integration/targets/nxos_rollback/tests/common/sanity.yaml similarity index 63% rename from test/integration/targets/nxos_rollback/tests/cli/sanity.yaml rename to test/integration/targets/nxos_rollback/tests/common/sanity.yaml index a03a52631e..7922669643 100644 --- a/test/integration/targets/nxos_rollback/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_rollback/tests/common/sanity.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START TRANSPORT:CLI nxos_rollback sanity test" +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_rollback sanity test" - name: delete existing checkpoint file nxos_config: &delete @@ -7,23 +7,23 @@ - terminal dont-ask - delete backup.cfg match: none - provider: "{{ cli }}" + provider: "{{ connection }}" ignore_errors: yes - name: Create checkpoint file nxos_rollback: checkpoint_file: backup.cfg timeout: 300 - provider: "{{ cli }}" + provider: "{{ connection }}" - name: rollback to the previously created checkpoint file nxos_rollback: rollback_to: backup.cfg timeout: 300 - provider: "{{ cli }}" + provider: "{{ connection }}" - name: cleanup checkpoint file nxos_config: *delete ignore_errors: yes -- debug: msg="END TRANSPORT:CLI nxos_rollback sanity test" +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_rollback sanity test" diff --git a/test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml deleted file mode 100644 index 248568a964..0000000000 --- a/test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- debug: msg="START TRANSPORT:NXAPI nxos_rollback sanity test" - -- name: delete existing checkpoint file - nxos_config: &delete - commands: - - terminal dont-ask - - delete backup.cfg - match: none - provider: "{{ nxapi }}" - ignore_errors: yes - -- name: Create checkpoint file - nxos_rollback: - checkpoint_file: backup.cfg - timeout: 300 - provider: "{{ nxapi }}" - -- name: rollback to the previously created checkpoint file - nxos_rollback: - rollback_to: backup.cfg - timeout: 300 - provider: "{{ nxapi }}" - -- name: cleanup checkpoint file - nxos_config: *delete - ignore_errors: yes - -- debug: msg="END TRANSPORT:NXAPI nxos_rollback sanity test" diff --git a/test/integration/targets/nxos_switchport/tasks/cli.yaml b/test/integration/targets/nxos_switchport/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_switchport/tasks/cli.yaml +++ b/test/integration/targets/nxos_switchport/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_switchport/tasks/nxapi.yaml b/test/integration/targets/nxos_switchport/tasks/nxapi.yaml index ea525379f7..e071f293a2 100644 --- a/test/integration/targets/nxos_switchport/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_switchport/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_switchport/tests/cli/sanity.yaml b/test/integration/targets/nxos_switchport/tests/cli/sanity.yaml deleted file mode 100644 index b1928202be..0000000000 --- a/test/integration/targets/nxos_switchport/tests/cli/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ cli }}" - -- import_tasks: targets/nxos_switchport/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_switchport/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_switchport/tests/nxapi/sanity.yaml deleted file mode 100644 index 8899ed72b4..0000000000 --- a/test/integration/targets/nxos_switchport/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ nxapi }}" - -- import_tasks: targets/nxos_switchport/tests/common/sanity.yaml