diff options
Diffstat (limited to 'tests/integration/targets/vyos_command')
9 files changed, 43 insertions, 39 deletions
diff --git a/tests/integration/targets/vyos_command/defaults/main.yaml b/tests/integration/targets/vyos_command/defaults/main.yaml index 9ef5ba5..a845c24 100644 --- a/tests/integration/targets/vyos_command/defaults/main.yaml +++ b/tests/integration/targets/vyos_command/defaults/main.yaml @@ -1,3 +1,3 @@ --- -testcase: "*" +testcase: '*' test_items: [] diff --git a/tests/integration/targets/vyos_command/tasks/cli.yaml b/tests/integration/targets/vyos_command/tasks/cli.yaml index 890d3ac..90f265f 100644 --- a/tests/integration/targets/vyos_command/tasks/cli.yaml +++ b/tests/integration/targets/vyos_command/tasks/cli.yaml @@ -1,22 +1,22 @@ --- - name: collect all cli test cases find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" + 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}" + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' loop_control: loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_command/tasks/main.yaml b/tests/integration/targets/vyos_command/tasks/main.yaml index d4cf26f..a3db933 100644 --- a/tests/integration/targets/vyos_command/tasks/main.yaml +++ b/tests/integration/targets/vyos_command/tasks/main.yaml @@ -1,2 +1,4 @@ --- -- {include: cli.yaml, tags: ['cli']} +- include: cli.yaml + tags: + - cli diff --git a/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml index 5ff72fa..690937f 100644 --- a/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml +++ b/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml @@ -2,14 +2,14 @@ - debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" - name: test bad operator + register: result + ignore_errors: true vyos.vyos.vyos_command: commands: - show version - show interfaces wait_for: - result[0] is 'VyOS' - register: result - ignore_errors: true - assert: that: diff --git a/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml b/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml index a10f2bc..61ed054 100644 --- a/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml +++ b/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml @@ -1,41 +1,43 @@ --- - debug: - msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}" + msg: START cli/cli_command.yaml on connection={{ ansible_connection }} - block: + - name: get output for single command - network.cli.cli_command: - command: show version register: result + ansible.netcommon.cli_command: + command: show version - assert: that: - - "result.changed == false" - - "result.stdout is defined" + - result.changed == false + - result.stdout is defined - name: send invalid command - network.cli.cli_command: - command: 'show foo' register: result ignore_errors: true + ansible.netcommon.cli_command: + command: show foo - assert: that: - - "result.failed == true" - - "result.msg is defined" - when: "ansible_connection == 'network_cli'" + - result.failed == true + - result.msg is defined + when: ansible_connection == 'ansible.netcommon.network_cli' - block: + - name: test failure for local connection - network.cli.cli_command: - command: show version register: result ignore_errors: true + ansible.netcommon.cli_command: + command: show version - assert: that: - - 'result.failed == true' + - result.failed == true - "'Connection type local is not valid for this module' in result.msg" - when: "ansible_connection == 'local'" + when: ansible_connection == 'local' - debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_command/tests/cli/contains.yaml b/tests/integration/targets/vyos_command/tests/cli/contains.yaml index b8665fa..efaf811 100644 --- a/tests/integration/targets/vyos_command/tests/cli/contains.yaml +++ b/tests/integration/targets/vyos_command/tests/cli/contains.yaml @@ -2,6 +2,7 @@ - debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" - name: test contains operator + register: result vyos.vyos.vyos_command: commands: - show version @@ -9,7 +10,6 @@ wait_for: - result[0] contains VyOS - result[1] contains eth0 - register: result - assert: that: diff --git a/tests/integration/targets/vyos_command/tests/cli/invalid.yaml b/tests/integration/targets/vyos_command/tests/cli/invalid.yaml index 04d203d..ac8af3f 100644 --- a/tests/integration/targets/vyos_command/tests/cli/invalid.yaml +++ b/tests/integration/targets/vyos_command/tests/cli/invalid.yaml @@ -2,21 +2,23 @@ - debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" - name: run invalid command - vyos.vyos.vyos_command: - commands: show foo register: result ignore_errors: true + vyos.vyos.vyos_command: + commands: show foo -- assert: {that: result.failed} +- assert: + that: result.failed - name: run commands that include invalid command + register: result + ignore_errors: true vyos.vyos.vyos_command: commands: - show version - show foo - register: result - ignore_errors: true -- assert: {that: result.failed} +- assert: + that: result.failed - debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_command/tests/cli/output.yaml b/tests/integration/targets/vyos_command/tests/cli/output.yaml index 1bc0dc6..9ed1906 100644 --- a/tests/integration/targets/vyos_command/tests/cli/output.yaml +++ b/tests/integration/targets/vyos_command/tests/cli/output.yaml @@ -2,9 +2,9 @@ - debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" - name: get output for single command + register: result vyos.vyos.vyos_command: commands: show version - register: result - assert: that: @@ -13,11 +13,11 @@ - result.stdout_lines is defined - name: get output for multiple commands + register: result vyos.vyos.vyos_command: commands: - show version - show interfaces - register: result - assert: that: @@ -26,14 +26,12 @@ - result.stdout | length == 2 - name: Get output for multiple commands that call less explicitly + register: result vyos.vyos.vyos_command: commands: - # NOTE: We only test show commands that will output <ANSIBLE_VYOS_TERMINAL_LENGTH - # Otherwise you will get ": "command timeout triggered" - show hardware cpu detail - show hardware mem - show license - register: result - assert: that: diff --git a/tests/integration/targets/vyos_command/tests/cli/timeout.yaml b/tests/integration/targets/vyos_command/tests/cli/timeout.yaml index 57120ac..fceea5c 100644 --- a/tests/integration/targets/vyos_command/tests/cli/timeout.yaml +++ b/tests/integration/targets/vyos_command/tests/cli/timeout.yaml @@ -2,13 +2,13 @@ - debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" - name: test bad condition + register: result + ignore_errors: true vyos.vyos.vyos_command: commands: - show version wait_for: - result[0] contains bad_value_string - register: result - ignore_errors: true - assert: that: |