mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Add junos integration test (#24404)
This commit is contained in:
parent
c5adf08c40
commit
5b3ea6562b
25 changed files with 628 additions and 3 deletions
|
@ -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"
|
Loading…
Add table
Add a link
Reference in a new issue