From 5a49567c71438a289479f169a4befc7ce02684b2 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 13 Aug 2018 14:20:28 -0400 Subject: [PATCH] Fix iosxr copy and delete tasks (#44083) * Fix iosxr copy and delete tasks * Drop local from non-smoke tasks --- .../targets/iosxr_banner/tasks/cli.yaml | 8 ----- .../targets/iosxr_command/tasks/cli.yaml | 6 ---- .../iosxr_command/tests/cli/cli_command.yaml | 36 ++++++++----------- .../iosxr_command/tests/cli/prompt.yaml | 7 ++-- .../targets/iosxr_config/tasks/cli.yaml | 6 ---- .../targets/iosxr_facts/tasks/cli.yaml | 6 ---- .../targets/iosxr_interface/tasks/cli.yaml | 8 ----- .../targets/iosxr_logging/tasks/cli.yaml | 8 ----- .../targets/iosxr_netconf/tasks/cli.yaml | 6 ---- .../targets/iosxr_smoke/tasks/cli.yaml | 4 +-- .../targets/iosxr_smoke/tasks/netconf.yaml | 4 +-- .../targets/iosxr_user/tasks/cli.yaml | 8 ----- 12 files changed, 20 insertions(+), 87 deletions(-) diff --git a/test/integration/targets/iosxr_banner/tasks/cli.yaml b/test/integration/targets/iosxr_banner/tasks/cli.yaml index 97dfa2c3f7f..3f93a4f3696 100644 --- a/test/integration/targets/iosxr_banner/tasks/cli.yaml +++ b/test/integration/targets/iosxr_banner/tasks/cli.yaml @@ -14,11 +14,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -# Only one of the Testcase would be run to check if `connection: local` -# is established. Full suite is run with `connection:network_cli` or `connection:netconf` -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_command/tasks/cli.yaml b/test/integration/targets/iosxr_command/tasks/cli.yaml index 890d3acf3e4..3f93a4f3696 100644 --- a/test/integration/targets/iosxr_command/tasks/cli.yaml +++ b/test/integration/targets/iosxr_command/tasks/cli.yaml @@ -14,9 +14,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_command/tests/cli/cli_command.yaml b/test/integration/targets/iosxr_command/tests/cli/cli_command.yaml index 31e410e5d1f..5101e2aa81e 100644 --- a/test/integration/targets/iosxr_command/tests/cli/cli_command.yaml +++ b/test/integration/targets/iosxr_command/tests/cli/cli_command.yaml @@ -23,31 +23,23 @@ - "result.failed == true" - "result.msg is defined" -- name: Remove existing file if any +- name: delete config file on disk to prevent failure of copy task for duplicate cli_command: command: 'delete harddisk:ansible_tmp.txt' - prompt: 'Delete harddisk\:ansible_tmp\.txt\[confirm\]' - answer: "\r\n" + prompt: 'Delete harddisk\:/?ansible_tmp\.txt\[confirm\]' + answer: "" ignore_errors: yes -- block: - - name: Run command with prompt - cli_command: - command: 'copy running-config harddisk:ansible_tmp.txt' - prompt: 'Destination file name \(control-c to abort\)\: \[\/ansible_tmp.txt\]\?' - answer: 'ansible_tmp.txt' - register: result - - - assert: - that: - - "result.stdout is defined" - - "'ansible_tmp' in result.stdout" - always: - - name: Remove copied file - cli_command: - command: 'delete harddisk:ansible_tmp.txt' - prompt: 'Delete harddisk\:ansible_tmp\.txt\[confirm\]' - answer: "\r\n" - ignore_errors: yes +- name: Run command with prompt + cli_command: + command: 'copy running-config harddisk:ansible_tmp.txt' + prompt: 'Destination file name \(control-c to abort\)\: \[\/ansible_tmp.txt\]\?' + answer: 'ansible_tmp.txt' + register: result + +- assert: + that: + - "result.stdout is defined" + - "'ansible_tmp' in result.stdout" - debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/iosxr_command/tests/cli/prompt.yaml b/test/integration/targets/iosxr_command/tests/cli/prompt.yaml index eb64a8a8dda..83f6cc8a3a2 100644 --- a/test/integration/targets/iosxr_command/tests/cli/prompt.yaml +++ b/test/integration/targets/iosxr_command/tests/cli/prompt.yaml @@ -1,12 +1,13 @@ --- -- debug: msg="START cli/prompt.yaml on connection={{ ansible_connection }}" +- debug: + msg: "START cli/prompt.yaml on connection={{ ansible_connection }}" - name: delete config file on disk to prevent failure of copy task for duplicate iosxr_command: commands: - command: 'delete harddisk:ansible_tmp.txt' - prompt: 'Delete harddisk\:ansible_tmp\.txt\[confirm\]' - answer: "\r\n" + prompt: 'Delete harddisk\:/?ansible_tmp\.txt\[confirm\]' + answer: "" ignore_errors: yes - name: copy diff --git a/test/integration/targets/iosxr_config/tasks/cli.yaml b/test/integration/targets/iosxr_config/tasks/cli.yaml index 890d3acf3e4..3f93a4f3696 100644 --- a/test/integration/targets/iosxr_config/tasks/cli.yaml +++ b/test/integration/targets/iosxr_config/tasks/cli.yaml @@ -14,9 +14,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_facts/tasks/cli.yaml b/test/integration/targets/iosxr_facts/tasks/cli.yaml index 890d3acf3e4..3f93a4f3696 100644 --- a/test/integration/targets/iosxr_facts/tasks/cli.yaml +++ b/test/integration/targets/iosxr_facts/tasks/cli.yaml @@ -14,9 +14,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_interface/tasks/cli.yaml b/test/integration/targets/iosxr_interface/tasks/cli.yaml index 97dfa2c3f7f..3f93a4f3696 100644 --- a/test/integration/targets/iosxr_interface/tasks/cli.yaml +++ b/test/integration/targets/iosxr_interface/tasks/cli.yaml @@ -14,11 +14,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -# Only one of the Testcase would be run to check if `connection: local` -# is established. Full suite is run with `connection:network_cli` or `connection:netconf` -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_logging/tasks/cli.yaml b/test/integration/targets/iosxr_logging/tasks/cli.yaml index cb2f3ff6e7f..8c9d032f48c 100644 --- a/test/integration/targets/iosxr_logging/tasks/cli.yaml +++ b/test/integration/targets/iosxr_logging/tasks/cli.yaml @@ -15,13 +15,5 @@ loop_control: loop_var: test_case_to_run -# Only one of the Testcase would be run to check if `connection: local` -# is established. Full suite is run with `connection:network_cli` or `connection:netconf` -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - - name: reset connection meta: reset_connection diff --git a/test/integration/targets/iosxr_netconf/tasks/cli.yaml b/test/integration/targets/iosxr_netconf/tasks/cli.yaml index 890d3acf3e4..3f93a4f3696 100644 --- a/test/integration/targets/iosxr_netconf/tasks/cli.yaml +++ b/test/integration/targets/iosxr_netconf/tasks/cli.yaml @@ -14,9 +14,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_smoke/tasks/cli.yaml b/test/integration/targets/iosxr_smoke/tasks/cli.yaml index 97dfa2c3f7f..e6956cc5b04 100644 --- a/test/integration/targets/iosxr_smoke/tasks/cli.yaml +++ b/test/integration/targets/iosxr_smoke/tasks/cli.yaml @@ -15,10 +15,8 @@ loop_control: loop_var: test_case_to_run -# Only one of the Testcase would be run to check if `connection: local` -# is established. Full suite is run with `connection:network_cli` or `connection:netconf` - name: run test case (connection=local) include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" + with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_smoke/tasks/netconf.yaml b/test/integration/targets/iosxr_smoke/tasks/netconf.yaml index 904db032050..2b284b5886e 100644 --- a/test/integration/targets/iosxr_smoke/tasks/netconf.yaml +++ b/test/integration/targets/iosxr_smoke/tasks/netconf.yaml @@ -15,10 +15,8 @@ loop_control: loop_var: test_case_to_run -# Only one of the Testcase would be run to check if `connection: local` -# is established. Full suite is run with `connection:network_cli` or `connection:netconf` - name: run test case (connection=local) include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" + with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_user/tasks/cli.yaml b/test/integration/targets/iosxr_user/tasks/cli.yaml index 590ba835445..a08939d6d58 100644 --- a/test/integration/targets/iosxr_user/tasks/cli.yaml +++ b/test/integration/targets/iosxr_user/tasks/cli.yaml @@ -25,11 +25,3 @@ with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - -# Only one of the Testcase would be run to check if `connection: local` -# is established. Full suite is run with `connection:network_cli` or `connection:netconf` -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run