mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -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
3
test/integration/targets/junos_rpc/defaults/main.yaml
Normal file
3
test/integration/targets/junos_rpc/defaults/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/junos_rpc/tasks/main.yaml
Normal file
2
test/integration/targets/junos_rpc/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
14
test/integration/targets/junos_rpc/tasks/netconf.yaml
Normal file
14
test/integration/targets/junos_rpc/tasks/netconf.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
- name: collect netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
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
|
72
test/integration/targets/junos_rpc/tests/netconf/rpc.yaml
Normal file
72
test/integration/targets/junos_rpc/tests/netconf/rpc.yaml
Normal file
|
@ -0,0 +1,72 @@
|
|||
---
|
||||
- debug: msg="START netconf/rpc.yaml"
|
||||
|
||||
- name: Execute RPC on device
|
||||
junos_rpc:
|
||||
rpc: get-interface-information
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "'<name>\nem0\n</name>' in result['xml']"
|
||||
- "result.output is defined"
|
||||
|
||||
- name: Execute RPC with args on device
|
||||
junos_rpc:
|
||||
rpc: get-interface-information
|
||||
args:
|
||||
interface-name: em0
|
||||
media: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "'<name>\nem0\n</name>' in result['xml']"
|
||||
- "'<name>\nlo0\n</name>' not in result['xml']"
|
||||
|
||||
- name: Execute RPC on device and get output in text format
|
||||
junos_rpc:
|
||||
rpc: get-interface-information
|
||||
output: text
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.output is defined"
|
||||
- "result.output_lines is defined"
|
||||
- "'Physical interface: em0' in result['output']"
|
||||
|
||||
- name: Execute RPC on device and get output in json format
|
||||
junos_rpc:
|
||||
rpc: get-interface-information
|
||||
output: json
|
||||
args:
|
||||
interface-name: em0
|
||||
media: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.output is defined"
|
||||
- "result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == \"em0\""
|
||||
|
||||
- name: Execute invalid RPC
|
||||
junos_rpc:
|
||||
rpc: show-interface-information
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- debug: msg="END netconf/rpc.yaml"
|
Loading…
Add table
Add a link
Reference in a new issue