Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration workflow for iosxr #526

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
39 changes: 39 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Integration
on:
pull_request_target:
branches: [main]
types:
- labeled
- opened
- reopened
- synchronize
paths:
- "plugins/**"
- "tests/integration/**"
workflow_dispatch:

jobs:
safe-to-test:
if: >-
github.event.label.name == 'safe to test' ||
github.event.action != 'labeled'
uses: ansible-network/github_actions/.github/workflows/safe-to-test.yml@main
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

integration:
uses: ansible/ansible-content-actions/.github/workflows/network_integration.yaml@main
needs:
- safe-to-test
with:
lab_title: cisco_iosxr
network_os: cisco.iosxr.iosxr
pytest_addopts: "--color=yes -n 2 --log-level WARNING -vvv"
collection_pre_install: >-
git+https://github.com/ansible-collections/ansible.utils.git
git+https://github.com/ansible-collections/ansible.netcommon.git
secrets:
cml_ssh_password: ${{ secrets.CML_SSH_PASSWORD }}
virl_host: ${{ secrets.VIRL_HOST }}
virl_password: ${{ secrets.VIRL_PASSWORD }}
Empty file added tests/integration/__init__.py
Empty file.
130 changes: 130 additions & 0 deletions tests/integration/labs/single.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
lab:
description: ""
notes: ""
title: cisco.iosxr.iosxr
version: 0.2.2
links:
- id: l0
n1: n0
n2: n1
i1: i1
i2: i0
conditioning: {}
label: xr9kv-0-Mgmt/0<->ext-conn-0-port
nodes:
- boot_disk_size: null
configuration: |2-
hostname iosxr
domain name ansible.com
username ansible
group root-lr
group sysadmin
secret 10 $6$r9zWl1mjMw94Dl1.$V7Xh1CuqtHHEbfRjHqFjZlMnFrjCivkjbSYPoH/S6MjQBR.r/G3sFk3PQre.TsnSpfy.hKf.35Tclt8KkRzaQ.
password 7 05080F1C2243
!
aaa authentication login default local
cdp
line default
login authentication default
transport input ssh
!
call-home
service active
contact smart-licensing
profile CiscoTAC-1
active
destination transport-method email disable
destination transport-method http
!
!
control-plane
management-plane
inband
interface all
allow all
allow SSH
!
!
!
!
interface MgmtEth0/RP0/CPU0/0
cdp
ipv4 address dhcp
!
interface GigabitEthernet0/0/0/0
shutdown
!
interface preconfigure GigabitEthernet0/0/0/1
negotiation auto
shutdown
!
interface preconfigure GigabitEthernet0/0/0/2
shutdown
!
router static
address-family ipv4 unicast
0.0.0.0/0 192.168.255.1
!
!
crypto key generate rsa the_default general-keys 2048 | -----BEGIN PUBLIC KEY-----
MB0wDQYJKoZIhvcNAQEBBQADDAAwCQIBAAIEAOnDAg==
-----END PUBLIC KEY-----
|
ssh timeout 60
ssh server v2
end
cpu_limit: null
cpus: null
data_volume: null
hide_links: false
id: n0
image_definition: null
label: 7.7.1-0
node_definition: xr9kv
parameters: {}
ram: null
tags: []
x: -120
y: 40
interfaces:
- id: i0
label: Loopback0
type: loopback
- id: i1
label: MgmtEth0/RP0/CPU0/0
slot: 0
type: physical
- id: i2
label: GigabitEthernet0/0/0/0
slot: 1
type: physical
- id: i3
label: GigabitEthernet0/0/0/1
slot: 2
type: physical
- id: i4
label: GigabitEthernet0/0/0/2
slot: 3
type: physical
- boot_disk_size: null
configuration: []
cpu_limit: null
cpus: null
data_volume: null
hide_links: false
id: n1
image_definition: null
label: ext-conn-0
node_definition: external_connector
parameters: {}
ram: null
tags: []
x: 160
y: 0
interfaces:
- id: i0
label: port
slot: 0
type: physical
annotations: []
4 changes: 4 additions & 0 deletions tests/integration/network-integration.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[persistent_connection]
command_timeout = 100
connect_timeout = 100
connect_retry_timeout = 100
41 changes: 41 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import subprocess

import pytest


def run(ansible_project, environment):
__tracebackhide__ = True
args = [
"ansible-navigator",
"run",
str(ansible_project.playbook),
"-i",
str(ansible_project.inventory),
"--ee",
"false",
"--mode",
"stdout",
"--pas",
str(ansible_project.playbook_artifact),
"--ll",
"debug",
"--lf",
str(ansible_project.log_file),
]
process = subprocess.run(
args=args,
env=environment,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
check=False,
shell=False,
)
if process.returncode:
print(process.stdout.decode("utf-8"))
print(process.stderr.decode("utf-8"))

pytest.fail(reason=f"Integration test failed: {ansible_project.role}")


def test_integration(ansible_project, environment):
run(ansible_project, environment)
Loading