mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Add junos integration test (#24404)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
---
|
||||
- { include: netconf_xml.yaml, tags: ['netconf', 'xml'] }
|
||||
- { include: netconf_text.yaml, tags: ['netconf', 'text'] }
|
||||
- { include: netconf_json.yaml, tags: ['netconf', 'json'] }
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: collect netconf_json test cases with json encoding
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf_json"
|
||||
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
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: collect netconf_text test cases with xml encoding
|
||||
- name: collect netconf_text test cases with text encoding
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf_text"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/bad_operator.yaml"
|
||||
|
||||
- name: test bad operator with json encoding
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
wait_for:
|
||||
- "result[0]['software-information'][0]['host-name'][0]['data'] foo fxp0"
|
||||
format: json
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END netconf_json/bad_operator.yaml"
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/contains.yaml"
|
||||
|
||||
- name: test contains operator with json encoding
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
format: json
|
||||
wait_for:
|
||||
- "result[0]['software-information'][0]['host-name'][0]['data'] contains {{ inventory_hostname_short }}"
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] contains fxp0"
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/contains.yaml"
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/equal.yaml"
|
||||
|
||||
- name: test == operator with xml encoding
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
wait_for:
|
||||
- "result[0]['software-information'][0]['host-name'][0]['data'] == {{ inventory_hostname_short }}"
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == fxp0"
|
||||
format: json
|
||||
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'][0]['host-name'][0]['data'] eq {{ inventory_hostname_short }}"
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] eq fxp0"
|
||||
format: json
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/equal.yaml"
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/greaterthan.yaml"
|
||||
|
||||
- name: test gt operator
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
format: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] 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: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] > 1500"
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/greaterthan.yaml"
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/greaterthanorequal.yaml"
|
||||
|
||||
- name: test ge operator
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
format: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] 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: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] >= 1514"
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/greaterthanorequal.yaml"
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/lessthan.yaml"
|
||||
|
||||
- name: test lt operator
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
format: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] 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: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] lt 9000"
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/lessthan.yaml"
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/lessthanorequal.yaml"
|
||||
|
||||
- name: test le operator
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
format: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] 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: json
|
||||
wait_for:
|
||||
- "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] <= 1514"
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/lessthanorequal.yaml"
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/notequal.yaml"
|
||||
|
||||
- name: test neq operator
|
||||
junos_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces fxp0
|
||||
format: json
|
||||
wait_for:
|
||||
- "result[0]['software-information'][0]['host-name'][0]['data'] 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: json
|
||||
wait_for:
|
||||
- "result[0]['software-information'][0]['host-name'][0]['data'] != localhost"
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/notequal.yaml"
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
- debug: msg="START netconf_json/output.yaml"
|
||||
|
||||
- name: get output for single command
|
||||
junos_command:
|
||||
commands: ['show version']
|
||||
format: json
|
||||
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: json
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout_lines is defined"
|
||||
|
||||
- debug: msg="END netconf_json/output.yaml"
|
||||
Reference in New Issue
Block a user