diff options
author | John R Barker <john@johnrbarker.com> | 2016-10-28 19:50:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-28 19:50:29 +0100 |
commit | e0cc7b34151def2ce0b08dbe3cb995107a2d6a0f (patch) | |
tree | 09df24fe1a91723d5fe716d8b9da843b383d5204 /test/integration/targets/junos_command | |
parent | 4a067c3f502aa2254d8f35d8598895df8f3d1365 (diff) | |
download | ansible-e0cc7b34151def2ce0b08dbe3cb995107a2d6a0f.tar.gz |
Migrate Network Tests into ansible/ansible (#18233)
* Docs Networking tests
* Copy networking tests from test-network-modules
* Networking transport settings - group_vars
* Network playbooks
* Debug should be off by default
* Update nxos.yaml
* Remove items from top level
* Use dependencies, not pre-tasks
* Remove trailing blank lines
* Remove backup files
* newlines
Diffstat (limited to 'test/integration/targets/junos_command')
20 files changed, 525 insertions, 0 deletions
diff --git a/test/integration/targets/junos_command/defaults/main.yaml b/test/integration/targets/junos_command/defaults/main.yaml new file mode 100644 index 0000000000..9ef5ba5165 --- /dev/null +++ b/test/integration/targets/junos_command/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/junos_command/tasks/main.yaml b/test/integration/targets/junos_command/tasks/main.yaml new file mode 100644 index 0000000000..9924bd301d --- /dev/null +++ b/test/integration/targets/junos_command/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- { include: netconf_xml.yaml, tags: ['netconf', 'xml'] } +- { include: netconf_text.yaml, tags: ['netconf', 'text'] } + diff --git a/test/integration/targets/junos_command/tasks/netconf_text.yaml b/test/integration/targets/junos_command/tasks/netconf_text.yaml new file mode 100644 index 0000000000..3f123c1284 --- /dev/null +++ b/test/integration/targets/junos_command/tasks/netconf_text.yaml @@ -0,0 +1,17 @@ +--- +- name: collect netconf_text test cases with xml encoding + find: + paths: "{{ role_path }}/tests/netconf_text" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + + diff --git a/test/integration/targets/junos_command/tasks/netconf_xml.yaml b/test/integration/targets/junos_command/tasks/netconf_xml.yaml new file mode 100644 index 0000000000..93b6def35f --- /dev/null +++ b/test/integration/targets/junos_command/tasks/netconf_xml.yaml @@ -0,0 +1,17 @@ +--- +- name: collect netconf_xml test cases with xml encoding + find: + paths: "{{ role_path }}/tests/netconf_xml" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + + diff --git a/test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml b/test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml new file mode 100644 index 0000000000..91aac25edc --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml @@ -0,0 +1,21 @@ +--- +- debug: msg="START netconf_text/bad_operator.yaml" + +- name: test bad operator with text encoding + junos_command: + commands: + - show version + - show interfaces fxp0 + wait_for: + - "result[1].interface-information[0].physical-interface[0].name[0].data foo fxp0" + encoding: text + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END netconf_text/bad_operator.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_text/contains.yaml b/test/integration/targets/junos_command/tests/netconf_text/contains.yaml new file mode 100644 index 0000000000..30a3d1fd18 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_text/contains.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START netconf_text/contains.yaml" + +- name: test contains operator with text encoding + junos_command: + commands: + - show version + - show interfaces fxp0 + display: text + wait_for: + - "result[0] contains vsrx01" + - "result[1] contains fxp0" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_text/contains.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_text/invalid.yaml b/test/integration/targets/junos_command/tests/netconf_text/invalid.yaml new file mode 100644 index 0000000000..cab272e9cc --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_text/invalid.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START netconf_text/invalid.yaml" + +- name: run invalid command + junos_command: + commands: show foo + display: text + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- debug: var=result + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- name: run commands that include invalid command + junos_command: + commands: + - show version + - show foo + display: text + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END netconf_text/invalid.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_text/output.yaml b/test/integration/targets/junos_command/tests/netconf_text/output.yaml new file mode 100644 index 0000000000..cf1308d86f --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_text/output.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START netconf_text/output.yaml" + +- name: get output for single command + junos_command: + commands: show version + display: text + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: get output for multiple commands + junos_command: + commands: + - show version + - show route + display: text + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_text/output.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_text/timeout.yaml b/test/integration/targets/junos_command/tests/netconf_text/timeout.yaml new file mode 100644 index 0000000000..d72d5e5c06 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_text/timeout.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START netconf_text/timeout.yaml" + +- name: test bad condition + junos_command: + commands: + - show version + wait_for: + - "result[0] contains bad_value_string" + display: text + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END netconf_text/timeout.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml b/test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml new file mode 100644 index 0000000000..bc97b14d37 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml @@ -0,0 +1,21 @@ +--- +- debug: msg="START netconf_xml/bad_operator.yaml" + +- name: test bad operator with xml encoding + junos_command: + commands: + - show version + - show interfaces fxp0 + wait_for: + - "result[1].interface-information[0].physical-interface[0].name[0].data foo fxp0" + format: xml + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END netconf_xml/bad_operator.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/contains.yaml b/test/integration/targets/junos_command/tests/netconf_xml/contains.yaml new file mode 100644 index 0000000000..fa79d8957d --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/contains.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START netconf_xml/contains.yaml" + +- name: test contains operator with xml encoding + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[0].software-information.host-name contains vsrx01" + - "result[1].interface-information.physical-interface.name contains fxp0" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/contains.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml new file mode 100644 index 0000000000..3240488cb3 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START netconf_xml/equal.yaml" + +- name: test == operator with xml encoding + junos_command: + commands: + - show version + - show interfaces fxp0 + wait_for: + - "result[0].software-information.host-name == vsrx01" + - "result[1].interface-information.physical-interface.name == fxp0" + format: xml + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: test eq operator with json encoding + junos_command: + commands: + - show version + - show interfaces fxp0 + wait_for: + - "result[0].software-information.host-name eq vsrx01" + - "result[1].interface-information.physical-interface.name eq fxp0" + format: xml + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/equal.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml b/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml new file mode 100644 index 0000000000..65c306429b --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START netconf_xml/greaterthan.yaml" + +- name: test gt operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu gt 1500" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: test > operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu > 1500" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/greaterthan.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml new file mode 100644 index 0000000000..d6a2ae7102 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START netconf_xml/greaterthanorequal.yaml" + +- name: test ge operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu ge 1514" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: test >= operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu >= 1514" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/greaterthanorequal.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml b/test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml new file mode 100644 index 0000000000..3f541f2944 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml @@ -0,0 +1,31 @@ +--- +- debug: msg="START netconf_xml/invalid.yaml" + +- name: run invalid command + junos_command: + commands: ['show foo'] + provider: "{{ netconf }}" + register: result + ignore_errors: yes +- debug: var=result + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- name: run commands that include invalid command + junos_command: + commands: + - show version + - show foo + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END netconf_xml/invalid.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml b/test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml new file mode 100644 index 0000000000..f487c2b3ab --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START netconf_xml/lessthan.yaml" + +- name: test lt operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu lt 9000" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: test < operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu lt 9000" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/lessthan.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml new file mode 100644 index 0000000000..d3c571e90b --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START netconf_xml/lessthanorequal.yaml" + +- name: test le operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu le 1514" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: test <= operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[1].interface-information.physical-interface.mtu <= 1514" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/lessthanorequal.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml new file mode 100644 index 0000000000..191161d4a3 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START netconf_xml/notequal.yaml" + +- name: test neq operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[0].software-information.host-name neq localhost" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: test != operator + junos_command: + commands: + - show version + - show interfaces fxp0 + format: xml + wait_for: + - "result[0].software-information.host-name != localhost" + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/notequal.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/output.yaml b/test/integration/targets/junos_command/tests/netconf_xml/output.yaml new file mode 100644 index 0000000000..1043ff9f67 --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/output.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START netconf_xml/output.yaml" + +- name: get output for single command + junos_command: + commands: ['show version'] + format: xml + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- name: get output for multiple commands + junos_command: + commands: + - show version + - show route + format: xml + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +- debug: msg="END netconf_xml/output.yaml" diff --git a/test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml b/test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml new file mode 100644 index 0000000000..ff6b93275d --- /dev/null +++ b/test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START netconf_xml/timeout.yaml" + +- name: test bad condition + junos_command: + commands: + - show version + wait_for: + - "result[0] contains bad_value_string" + provider: "{{ netconf }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END netconf_xml/timeout.yaml" |