From a330106b2e2c811db49477d71b8a472c964d2aeb Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 8 Aug 2019 12:29:41 -0700 Subject: fixed --- test/integration/targets/vyos_command/aliases | 1 + .../targets/vyos_command/defaults/main.yaml | 3 ++ .../targets/vyos_command/tasks/cli.yaml | 22 +++++++++++ .../targets/vyos_command/tasks/main.yaml | 2 + .../vyos_command/tests/cli/bad_operator.yaml | 19 ++++++++++ .../vyos_command/tests/cli/cli_command.yaml | 41 ++++++++++++++++++++ .../targets/vyos_command/tests/cli/contains.yaml | 20 ++++++++++ .../targets/vyos_command/tests/cli/invalid.yaml | 22 +++++++++++ .../targets/vyos_command/tests/cli/output.yaml | 44 ++++++++++++++++++++++ .../targets/vyos_command/tests/cli/timeout.yaml | 18 +++++++++ .../targets/vyos_command/vyos_command/aliases | 1 - .../vyos_command/vyos_command/defaults/main.yaml | 3 -- .../vyos_command/vyos_command/tasks/cli.yaml | 22 ----------- .../vyos_command/vyos_command/tasks/main.yaml | 2 - .../vyos_command/tests/cli/bad_operator.yaml | 19 ---------- .../vyos_command/tests/cli/cli_command.yaml | 41 -------------------- .../vyos_command/tests/cli/contains.yaml | 20 ---------- .../vyos_command/tests/cli/invalid.yaml | 22 ----------- .../vyos_command/tests/cli/output.yaml | 44 ---------------------- .../vyos_command/tests/cli/timeout.yaml | 18 --------- 20 files changed, 192 insertions(+), 192 deletions(-) create mode 100644 test/integration/targets/vyos_command/aliases create mode 100644 test/integration/targets/vyos_command/defaults/main.yaml create mode 100644 test/integration/targets/vyos_command/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_command/tasks/main.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/bad_operator.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/cli_command.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/contains.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/invalid.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/output.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/timeout.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/aliases delete mode 100644 test/integration/targets/vyos_command/vyos_command/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml (limited to 'test/integration/targets/vyos_command') diff --git a/test/integration/targets/vyos_command/aliases b/test/integration/targets/vyos_command/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_command/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_command/defaults/main.yaml b/test/integration/targets/vyos_command/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_command/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_command/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + 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 }}" + 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/tasks/main.yaml b/test/integration/targets/vyos_command/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_command/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml new file mode 100644 index 00000000..bf3334f2 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" + +- name: test bad operator + vyos.vyos.vyos_command: + commands: + - show version + - show interfaces + wait_for: + - result[0] is 'VyOS' + register: result + ignore_errors: yes + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml new file mode 100644 index 00000000..caeb2021 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml @@ -0,0 +1,41 @@ +--- +- debug: + msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}" + +- block: + - name: get output for single command + cli_command: + command: show version + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" + + - name: send invalid command + cli_command: + command: 'show foo' + register: result + ignore_errors: yes + + - assert: + that: + - "result.failed == true" + - "result.msg is defined" + when: "ansible_connection == 'network_cli'" + +- block: + - name: test failure for local connection + cli_command: + command: show version + register: result + ignore_errors: yes + + - assert: + that: + - 'result.failed == true' + - "'Connection type local is not valid for this module' in result.msg" + when: "ansible_connection == 'local'" + +- debug: msg="END cli/cli_command.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 new file mode 100644 index 00000000..b8665fa7 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/contains.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + vyos.vyos.vyos_command: + commands: + - show version + - show interface + wait_for: + - result[0] contains VyOS + - result[1] contains eth0 + register: result + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- 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 new file mode 100644 index 00000000..672f6e81 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/invalid.yaml @@ -0,0 +1,22 @@ +--- +- 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: yes + +- assert: { that: result.failed } + +- name: run commands that include invalid command + vyos.vyos.vyos_command: + commands: + - show version + - show foo + register: result + ignore_errors: yes + +- assert: { that: result.failed } + +- 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 new file mode 100644 index 00000000..bdc8b2a8 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/output.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" + +- name: get output for single command + vyos.vyos.vyos_command: + commands: show version + register: result + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: get output for multiple commands + vyos.vyos.vyos_command: + commands: + - show version + - show interfaces + register: result + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout | length == 2 + +- name: Get output for multiple commands that call less explicitly + vyos.vyos.vyos_command: + commands: + # NOTE: We only test show commands that will output = 20 + +- 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 new file mode 100644 index 00000000..e4716ed6 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/timeout.yaml @@ -0,0 +1,18 @@ +--- +- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" + +- name: test bad condition + vyos.vyos.vyos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + register: result + ignore_errors: yes + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/aliases b/test/integration/targets/vyos_command/vyos_command/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_command/vyos_command/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_command/vyos_command/defaults/main.yaml b/test/integration/targets/vyos_command/vyos_command/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_command/vyos_command/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: collect all cli test cases - find: - 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 }}" - 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/vyos_command/tasks/main.yaml b/test/integration/targets/vyos_command/vyos_command/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml deleted file mode 100644 index 9e9de9f7..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" - -- name: test bad operator - vyos_command: - commands: - - show version - - show interfaces - wait_for: - - result[0] is 'VyOS' - register: result - ignore_errors: yes - -- assert: - that: - - result.failed == true - - result.msg is defined - -- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml deleted file mode 100644 index caeb2021..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- debug: - msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}" - -- block: - - name: get output for single command - cli_command: - command: show version - register: result - - - assert: - that: - - "result.changed == false" - - "result.stdout is defined" - - - name: send invalid command - cli_command: - command: 'show foo' - register: result - ignore_errors: yes - - - assert: - that: - - "result.failed == true" - - "result.msg is defined" - when: "ansible_connection == 'network_cli'" - -- block: - - name: test failure for local connection - cli_command: - command: show version - register: result - ignore_errors: yes - - - assert: - that: - - 'result.failed == true' - - "'Connection type local is not valid for this module' in result.msg" - when: "ansible_connection == 'local'" - -- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml deleted file mode 100644 index 85c6e86a..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" - -- name: test contains operator - vyos_command: - commands: - - show version - - show interface - wait_for: - - result[0] contains VyOS - - result[1] contains eth0 - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml deleted file mode 100644 index e6d25e41..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" - -- name: run invalid command - vyos_command: - commands: show foo - register: result - ignore_errors: yes - -- assert: { that: result.failed } - -- name: run commands that include invalid command - vyos_command: - commands: - - show version - - show foo - register: result - ignore_errors: yes - -- assert: { that: result.failed } - -- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml deleted file mode 100644 index 294f62f7..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" - -- name: get output for single command - vyos_command: - commands: show version - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -- name: get output for multiple commands - vyos_command: - commands: - - show version - - show interfaces - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout | length == 2 - -- name: Get output for multiple commands that call less explicitly - vyos_command: - commands: - # NOTE: We only test show commands that will output = 20 - -- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml deleted file mode 100644 index 4994ebff..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" - -- name: test bad condition - vyos_command: - commands: - - show version - wait_for: - - result[0] contains bad_value_string - register: result - ignore_errors: yes - -- assert: - that: - - result.failed == true - - result.msg is defined - -- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" -- cgit v1.2.3