From 2425374fddb5ba5f4f1b5ac8f3ed31ed1144f43b Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 13 Dec 2017 14:30:24 -0500 Subject: [PATCH] Actually move vyos tests to network_cli (#33710) * Fix vyos on network_cli on python3 bytes do not have format() in Python3 * Push connection to tasks, with bonus connection=local test * Run tests without explicit connection set * Add/update START messages where appropriate --- lib/ansible/plugins/cliconf/vyos.py | 10 +++++----- test/integration/targets/vyos_banner/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_banner/tests/cli/basic-no-login.yaml | 3 +++ .../vyos_banner/tests/cli/basic-post-login.yaml | 3 +++ .../vyos_banner/tests/cli/basic-pre-login.yaml | 3 +++ test/integration/targets/vyos_command/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_command/tests/cli/bad_operator.yaml | 4 ++-- .../targets/vyos_command/tests/cli/contains.yaml | 4 ++-- .../targets/vyos_command/tests/cli/invalid.yaml | 4 ++-- .../targets/vyos_command/tests/cli/output.yaml | 4 ++-- .../targets/vyos_command/tests/cli/timeout.yaml | 4 ++-- test/integration/targets/vyos_config/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_config/tests/cli/check_config.yaml | 4 ++-- .../targets/vyos_config/tests/cli/comment.yaml | 4 ++-- .../targets/vyos_config/tests/cli/save.yaml | 4 ++-- .../targets/vyos_config/tests/cli/simple.yaml | 4 ++-- test/integration/targets/vyos_facts/tasks/cli.yaml | 11 +++++++++-- .../integration/targets/vyos_interface/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_interface/tests/cli/basic.yaml | 2 +- .../targets/vyos_interface/tests/cli/intent.yaml | 2 +- .../targets/vyos_l3_interface/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_l3_interface/tests/cli/basic.yaml | 2 ++ test/integration/targets/vyos_linkagg/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_linkagg/tests/cli/basic.yaml | 2 ++ test/integration/targets/vyos_lldp/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_lldp/tests/cli/basic.yaml | 2 ++ .../targets/vyos_lldp_interface/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_lldp_interface/tests/cli/basic.yaml | 2 ++ test/integration/targets/vyos_logging/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_logging/tests/cli/basic.yaml | 2 ++ .../targets/vyos_static_route/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_static_route/tests/cli/basic.yaml | 2 ++ test/integration/targets/vyos_user/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_user/tests/cli/basic.yaml | 2 ++ test/integration/targets/vyos_vlan/tasks/cli.yaml | 11 +++++++++-- .../targets/vyos_vlan/tests/cli/basic.yaml | 2 ++ .../targets/vyos_vlan/tests/cli/multiple.yaml | 2 ++ 37 files changed, 169 insertions(+), 51 deletions(-) diff --git a/lib/ansible/plugins/cliconf/vyos.py b/lib/ansible/plugins/cliconf/vyos.py index 84c137f9cfb..8425721dc54 100644 --- a/lib/ansible/plugins/cliconf/vyos.py +++ b/lib/ansible/plugins/cliconf/vyos.py @@ -55,18 +55,18 @@ class Cliconf(CliconfBase): return self.send_command(b'show configuration commands') def edit_config(self, command): - for cmd in chain([b'configure'], to_list(command)): - self.send_command(cmd) + for cmd in chain(['configure'], to_list(command)): + self.send_command(to_bytes(cmd)) def get(self, command, prompt=None, answer=None, sendonly=False): return self.send_command(to_bytes(command), prompt=to_bytes(prompt), answer=to_bytes(answer), sendonly=sendonly) def commit(self, comment=None): if comment: - command = b'commit comment "{0}"'.format(comment) + command = 'commit comment "{0}"'.format(comment) else: - command = b'commit' - self.send_command(command) + command = 'commit' + self.send_command(to_bytes(command)) def discard_changes(self, *args, **kwargs): self.send_command(b'discard') diff --git a/test/integration/targets/vyos_banner/tasks/cli.yaml b/test/integration/targets/vyos_banner/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_banner/tasks/cli.yaml +++ b/test/integration/targets/vyos_banner/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_banner/tests/cli/basic-no-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml index 57de75db963..d513d2e1845 100644 --- a/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml +++ b/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml @@ -1,4 +1,7 @@ --- +- debug: + msg: "cli/basic-no-login.yaml on connection={{ ansible_connection }}" + - name: Setup vyos_banner: banner: pre-login diff --git a/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml index a7d2f08650d..bda84a8c8b2 100644 --- a/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml +++ b/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml @@ -1,4 +1,7 @@ --- +- debug: + msg: "cli/basic-post-login.yaml on connection={{ ansible_connection }}" + - name: setup - remove post-login vyos_banner: banner: post-login diff --git a/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml index 0329b3f2118..eb66a73b444 100644 --- a/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml +++ b/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml @@ -1,4 +1,7 @@ --- +- debug: + msg: "cli/basic-pre-login.yaml on connection={{ ansible_connection }}" + - name: setup - remove pre-login vyos_banner: banner: pre-login diff --git a/test/integration/targets/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_command/tasks/cli.yaml +++ b/test/integration/targets/vyos_command/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml index b72cb94a22e..9e9de9f7b60 100644 --- a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml +++ b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/bad_operator.yaml" +- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" - name: test bad operator vyos_command: @@ -16,4 +16,4 @@ - result.failed == true - result.msg is defined -- debug: msg="END cli/bad_operator.yaml" +- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/tests/cli/contains.yaml index 56c88790848..85c6e86a181 100644 --- a/test/integration/targets/vyos_command/tests/cli/contains.yaml +++ b/test/integration/targets/vyos_command/tests/cli/contains.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/contains.yaml" +- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" - name: test contains operator vyos_command: @@ -17,4 +17,4 @@ - result.stdout is defined - result.stdout_lines is defined -- debug: msg="END cli/contains.yaml" +- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/tests/cli/invalid.yaml index 961fda22924..e6d25e411f7 100644 --- a/test/integration/targets/vyos_command/tests/cli/invalid.yaml +++ b/test/integration/targets/vyos_command/tests/cli/invalid.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/invalid.yaml" +- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" - name: run invalid command vyos_command: @@ -19,4 +19,4 @@ - assert: { that: result.failed } -- debug: msg="END cli/invalid.yaml" +- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/tests/cli/output.yaml index 764c6e180c8..e3644b78782 100644 --- a/test/integration/targets/vyos_command/tests/cli/output.yaml +++ b/test/integration/targets/vyos_command/tests/cli/output.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/output.yaml" +- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" - name: get output for single command vyos_command: @@ -41,4 +41,4 @@ - result.stdout_lines is defined - result.stdout_lines[2] | length >= 20 -- debug: msg="END cli/output.yaml" +- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/tests/cli/timeout.yaml index fecae8aed78..4994ebff802 100644 --- a/test/integration/targets/vyos_command/tests/cli/timeout.yaml +++ b/test/integration/targets/vyos_command/tests/cli/timeout.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/timeout.yaml" +- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" - name: test bad condition vyos_command: @@ -15,4 +15,4 @@ - result.failed == true - result.msg is defined -- debug: msg="END cli/timeout.yaml" +- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tasks/cli.yaml b/test/integration/targets/vyos_config/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_config/tasks/cli.yaml +++ b/test/integration/targets/vyos_config/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_config/tests/cli/check_config.yaml b/test/integration/targets/vyos_config/tests/cli/check_config.yaml index 56ebb04eeeb..c7df344545a 100644 --- a/test/integration/targets/vyos_config/tests/cli/check_config.yaml +++ b/test/integration/targets/vyos_config/tests/cli/check_config.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/config_check.yaml" +- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}" - name: setup vyos_config: @@ -23,4 +23,4 @@ that: - "result.changed == false" -- debug: msg="END cli/config_check.yaml" +- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/comment.yaml b/test/integration/targets/vyos_config/tests/cli/comment.yaml index 0c1bf4e9141..3c71dfc64d8 100644 --- a/test/integration/targets/vyos_config/tests/cli/comment.yaml +++ b/test/integration/targets/vyos_config/tests/cli/comment.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/comment.yaml" +- debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}" - name: setup vyos_config: @@ -31,4 +31,4 @@ lines: set system host-name {{ inventory_hostname_short }} match: none -- debug: msg="END cli/comment.yaml" +- debug: msg="END cli/comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/save.yaml b/test/integration/targets/vyos_config/tests/cli/save.yaml index 98e23af5fb6..7b058a7be30 100644 --- a/test/integration/targets/vyos_config/tests/cli/save.yaml +++ b/test/integration/targets/vyos_config/tests/cli/save.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/save.yaml" +- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" - name: setup vyos_config: @@ -51,4 +51,4 @@ match: none save: true -- debug: msg="END cli/simple.yaml" +- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/simple.yaml b/test/integration/targets/vyos_config/tests/cli/simple.yaml index 99cff152638..a4a879957c3 100644 --- a/test/integration/targets/vyos_config/tests/cli/simple.yaml +++ b/test/integration/targets/vyos_config/tests/cli/simple.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START cli/simple.yaml" +- debug: msg="START cli/simple.yaml on connection={{ ansible_connection }}" - name: setup vyos_config: @@ -30,4 +30,4 @@ lines: set system host-name {{ inventory_hostname_short }} match: none -- debug: msg="END cli/simple.yaml" +- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_facts/tasks/cli.yaml b/test/integration/targets/vyos_facts/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_facts/tasks/cli.yaml +++ b/test/integration/targets/vyos_facts/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_interface/tasks/cli.yaml b/test/integration/targets/vyos_interface/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_interface/tasks/cli.yaml +++ b/test/integration/targets/vyos_interface/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_interface/tests/cli/basic.yaml index 5c5c4bb95e3..0f1549a7381 100644 --- a/test/integration/targets/vyos_interface/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_interface/tests/cli/basic.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START vyos_interface cli/basic.yaml" +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - name: Run vyos lsmod command vyos_command: diff --git a/test/integration/targets/vyos_interface/tests/cli/intent.yaml b/test/integration/targets/vyos_interface/tests/cli/intent.yaml index b9603a5d4da..fad955109a6 100644 --- a/test/integration/targets/vyos_interface/tests/cli/intent.yaml +++ b/test/integration/targets/vyos_interface/tests/cli/intent.yaml @@ -1,5 +1,5 @@ --- -- debug: msg="START vyos_interface cli/intent.yaml" +- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" - name: Run vyos lsmod command vyos_command: diff --git a/test/integration/targets/vyos_l3_interface/tasks/cli.yaml b/test/integration/targets/vyos_l3_interface/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_l3_interface/tasks/cli.yaml +++ b/test/integration/targets/vyos_l3_interface/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_l3_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml index 7f15b172050..ac9e9d9c1b0 100644 --- a/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: Remove IP address vyos_l3_interface: name: eth1 diff --git a/test/integration/targets/vyos_linkagg/tasks/cli.yaml b/test/integration/targets/vyos_linkagg/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_linkagg/tasks/cli.yaml +++ b/test/integration/targets/vyos_linkagg/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_linkagg/tests/cli/basic.yaml b/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml index 27c2df1209c..1a171a70270 100644 --- a/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="cli/basic.yaml on connection={{ ansible_connection }}" + - name: Remove linkagg vyos_linkagg: name: bond0 diff --git a/test/integration/targets/vyos_lldp/tasks/cli.yaml b/test/integration/targets/vyos_lldp/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_lldp/tasks/cli.yaml +++ b/test/integration/targets/vyos_lldp/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_lldp/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp/tests/cli/basic.yaml index ec2dfb42ffe..bc7774f0ee9 100644 --- a/test/integration/targets/vyos_lldp/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_lldp/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: Make sure LLDP is not running before tests vyos_config: lines: delete service lldp diff --git a/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml b/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml +++ b/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_lldp_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml index 089d9b7a982..362d1817fe1 100644 --- a/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: Make sure LLDP is not running before tests vyos_config: lines: delete service lldp diff --git a/test/integration/targets/vyos_logging/tasks/cli.yaml b/test/integration/targets/vyos_logging/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_logging/tasks/cli.yaml +++ b/test/integration/targets/vyos_logging/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_logging/tests/cli/basic.yaml b/test/integration/targets/vyos_logging/tests/cli/basic.yaml index 098770c3479..6b13334216b 100644 --- a/test/integration/targets/vyos_logging/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_logging/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: set-up logging vyos_logging: dest: console diff --git a/test/integration/targets/vyos_static_route/tasks/cli.yaml b/test/integration/targets/vyos_static_route/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_static_route/tasks/cli.yaml +++ b/test/integration/targets/vyos_static_route/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_static_route/tests/cli/basic.yaml b/test/integration/targets/vyos_static_route/tests/cli/basic.yaml index b0190f7b156..f8fa87d9f79 100644 --- a/test/integration/targets/vyos_static_route/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_static_route/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: create static route vyos_static_route: prefix: 172.24.0.0/24 diff --git a/test/integration/targets/vyos_user/tasks/cli.yaml b/test/integration/targets/vyos_user/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_user/tasks/cli.yaml +++ b/test/integration/targets/vyos_user/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_user/tests/cli/basic.yaml b/test/integration/targets/vyos_user/tests/cli/basic.yaml index dbd78ee117a..346ecda33a2 100644 --- a/test/integration/targets/vyos_user/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_user/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: Setup vyos_config: lines: diff --git a/test/integration/targets/vyos_vlan/tasks/cli.yaml b/test/integration/targets/vyos_vlan/tasks/cli.yaml index d675462dd02..890d3acf3e4 100644 --- a/test/integration/targets/vyos_vlan/tasks/cli.yaml +++ b/test/integration/targets/vyos_vlan/tasks/cli.yaml @@ -4,12 +4,19 @@ paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" register: test_cases + delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case - include: "{{ test_case_to_run }}" +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" 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/vyos_vlan/tests/cli/basic.yaml b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml index dde914d1de8..249d36ad972 100644 --- a/test/integration/targets/vyos_vlan/tests/cli/basic.yaml +++ b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + - name: setup - remove vlan used in test vyos_config: lines: diff --git a/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml b/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml index 942902f8bc5..25bc1af095e 100644 --- a/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml +++ b/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml @@ -1,4 +1,6 @@ --- +- debug: msg="START cli/multiple.yaml on connection={{ ansible_connection }}" + - name: setup - remove vlan used in test vyos_config: lines: