Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is the configuration template for ansible-test network-integration tests.
#
# You do not need this template if you are:
#
# 1) Running integration tests without using ansible-test.
# 2) Using the `--platform` option to provision temporary network instances on EC2.
#
# If you do not want to use the automatically provisioned temporary network instances,
# fill in the @VAR placeholders below and save this file without the .template extension,
# into the tests/integration directory of the collection you're testing.
#
# NOTE: Automatic provisioning of network instances on EC2 requires an ansible-core-ci API key.
[junos]
junos_test ansible_host=x.x.x.x ansible_network_os="junos" ansible_user=xyz ansible_ssh_pass=xyz

[all:vars]
ansible_python_interpreter=/usr/bin/python3
###
# Example
#
# [vyos]
# vyos01.example.net ansible_connection=local ansible_network_os="vyos" ansible_user=admin ansible_ssh_pass=mypassword
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
junos
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- prepare_junos_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Collect netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yml"
connection: local
register: test_cases

- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"

- name: Run test case (connection=local)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
vars:
ansible_connection: local
tags:
- local

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Invoke netconf tasks
ansible.builtin.include_tasks: local.yml


- name: Invoke netconf tasks
ansible.builtin.include_tasks: pyez.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Collect netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yml"
connection: local
register: test_cases

- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"

- name: Run test case (connection=juniper.device.pyez)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
vars:
ansible_connection: juniper.device.pyez
tags:
- pyez

Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
- name: TEST 1 - Execute single "show version" command.
juniper.device.command:
commands: "show version"
register: test1

- name: Check TEST 1
ansible.builtin.assert:
that:
test1.msg == "The command executed successfully."

- name: Creates directory
ansible.builtin.file:
path: out
state: directory
mode: '0644'

- name: TEST 2 - Execute three commands.
juniper.device.command:
commands:
- "show version"
- "show system uptime"
- "show interface terse"
register: test2

- name: Check TEST 2
ansible.builtin.assert:
that:
- test2.results[0].command == "show version"
- test2.results[0].msg == "The command executed successfully."
- test2.results[1].command == "show system uptime"
- test2.results[1].msg == "The command executed successfully."
- test2.results[2].command == "show interface terse"
- test2.results[2].msg == "The command executed successfully."

- name: Print the command output of each.
ansible.builtin.debug:
var: item.stdout
with_items: "{{ test2.results }}"

- name: TEST 3 - Two commands with XML output.
juniper.device.command:
commands:
- "show route"
- "show version"
format: xml
register: test3

- name: Check TEST 3
ansible.builtin.assert:
that:
- test3.results[0].command == "show route"
- test3.results[0].msg == "The command executed successfully."
- test3.results[1].command == "show version"
- test3.results[1].msg == "The command executed successfully."

- name: TEST 4 - show route with XML output - show version with JSON output
juniper.device.command:
commands:
- "show route"
- "show version"
formats:
- "xml"
- "json"
register: test4

- name: Check TEST 4
ansible.builtin.assert:
that:
- test4.results[0].command == "show route"
- test4.results[0].msg == "The command executed successfully."
- test4.results[1].command == "show version"
- test4.results[1].msg == "The command executed successfully."

- name: TEST 5 - save outputs in dest_dir
juniper.device.command:
commands:
- "show route"
- "show version"
dest_dir: "./out"
register: test5

- name: Check TEST 5
ansible.builtin.assert:
that:
- test5.results[0].command == "show route"
- test5.results[0].msg == "The command executed successfully."
- test5.results[1].command == "show version"
- test5.results[1].msg == "The command executed successfully."

- name: TEST 6 - save output to dest
juniper.device.command:
command: "show system uptime"
dest: "./out/{{ inventory_hostname }}.uptime.output"
register: test6

- name: Check TEST 6
ansible.builtin.assert:
that:
- test6.command == "show system uptime"
- test6.msg == "The command executed successfully."

- name: TEST 7 - save output to dest
juniper.device.command:
command:
- "show route"
- "show version"
dest: "./out/{{ inventory_hostname }}.commands.output"
register: test7

- name: Check TEST 7
ansible.builtin.assert:
that:
- test7.results[0].command == "show route"
- test7.results[0].msg == "The command executed successfully."
- test7.results[1].command == "show version"
- test7.results[1].msg == "The command executed successfully."

- name: TEST 8 - Multiple commands, save outputs, but don't return them
juniper.device.command:
commands:
- "show route"
- "show version"
formats:
- "xml"
- "json"
dest_dir: "./out/"
return_output: false
register: test8

- name: Check TEST 8
ansible.builtin.assert:
that:
- test8.results[0].command == "show route"
- test8.results[0].msg == "The command executed successfully."
- test8.results[1].command == "show version"
- test8.results[1].msg == "The command executed successfully."
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- prepare_junos_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Collect netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yml"
connection: local
register: test_cases

- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"

- name: Run test case (connection=local)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
vars:
ansible_connection: local
tags:
- local
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Invoke netconf tasks
ansible.builtin.include_tasks: local.yml


- name: Invoke netconf tasks
ansible.builtin.include_tasks: pyez.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Collect netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yml"
connection: local
register: test_cases

- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"

- name: Run test case (connection=juniper.device.pyez)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
vars:
ansible_connection: juniper.device.pyez
tags:
- pyez
Loading