From 0635a8ee1be77a9b990f5f29a179232e3dc39c01 Mon Sep 17 00:00:00 2001 From: Vinay M <63404819+roverflow@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:53:58 +0530 Subject: [PATCH] ADD integration workflow for ios (#1150) * ADD integration workflow for ios * fix lint * fix lint * Use of cat9k * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * added 8k * remove cisco user --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/integration-test.yml | 39 +++++ tests/integration/__init__.py | 0 tests/integration/labs/single.yaml | 210 +++++++++++++++++++++++++ tests/integration/test_integration.py | 41 +++++ 4 files changed, 290 insertions(+) create mode 100644 .github/workflows/integration-test.yml create mode 100644 tests/integration/__init__.py create mode 100644 tests/integration/labs/single.yaml create mode 100644 tests/integration/test_integration.py diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 000000000..604d2f366 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -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_ios + network_os: cisco.ios.ios + 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 }} diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/labs/single.yaml b/tests/integration/labs/single.yaml new file mode 100644 index 000000000..ee3d6065c --- /dev/null +++ b/tests/integration/labs/single.yaml @@ -0,0 +1,210 @@ +--- +lab: + description: "" + notes: "" + title: cisco.ios.ios + version: 0.2.2 +links: + - id: l0 + n1: n0 + n2: n1 + i1: i1 + i2: i0 + conditioning: {} + label: cat8000v-0-GigabitEthernet1<->ext-conn-0-port +nodes: + - boot_disk_size: null + configuration: |2- + service timestamps debug datetime msec + service timestamps log datetime msec + platform qfp utilization monitor load 80 + platform punt-keepalive disable-kernel-core + platform sslvpn use-pd + platform console serial + ! + hostname cisco + ! + boot-start-marker + boot-end-marker + ! + ! + no aaa new-model + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ip domain name ansible.com + ! + ! + ! + login on-success log + ! + ! + subscriber templating + ! + pae + ! + ! + crypto pki trustpoint SLA-TrustPoint + enrollment pkcs12 + revocation-check crl + hash sha256 + ! + ! + crypto pki certificate chain SLA-TrustPoint + certificate ca 01 + 30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030 + 32310E30 0C060355 040A1305 43697363 6F312030 1E060355 04031317 43697363 + 6F204C69 63656E73 696E6720 526F6F74 20434130 1E170D31 33303533 30313934 + 3834375A 170D3338 30353330 31393438 34375A30 32310E30 0C060355 040A1305 + 43697363 6F312030 1E060355 04031317 43697363 6F204C69 63656E73 696E6720 + 526F6F74 20434130 82012230 0D06092A 864886F7 0D010101 05000382 010F0030 + 82010A02 82010100 A6BCBD96 131E05F7 145EA72C 2CD686E6 17222EA1 F1EFF64D + CBB4C798 212AA147 C655D8D7 9471380D 8711441E 1AAF071A 9CAE6388 8A38E520 + 1C394D78 462EF239 C659F715 B98C0A59 5BBB5CBD 0CFEBEA3 700A8BF7 D8F256EE + 4AA4E80D DB6FD1C9 60B1FD18 FFC69C96 6FA68957 A2617DE7 104FDC5F EA2956AC + 7390A3EB 2B5436AD C847A2C5 DAB553EB 69A9A535 58E9F3E3 C0BD23CF 58BD7188 + 68E69491 20F320E7 948E71D7 AE3BCC84 F10684C7 4BC8E00F 539BA42B 42C68BB7 + C7479096 B4CB2D62 EA2F505D C7B062A4 6811D95B E8250FC4 5D5D5FB8 8F27D191 + C55F0D76 61F9A4CD 3D992327 A8BB03BD 4E6D7069 7CBADF8B DF5F4368 95135E44 + DFC7C6CF 04DD7FD1 02030100 01A34230 40300E06 03551D0F 0101FF04 04030201 + 06300F06 03551D13 0101FF04 05300301 01FF301D 0603551D 0E041604 1449DC85 + 4B3D31E5 1B3E6A17 606AF333 3D3B4C73 E8300D06 092A8648 86F70D01 010B0500 + 03820101 00507F24 D3932A66 86025D9F E838AE5C 6D4DF6B0 49631C78 240DA905 + 604EDCDE FF4FED2B 77FC460E CD636FDB DD44681E 3A5673AB 9093D3B1 6C9E3D8B + D98987BF E40CBD9E 1AECA0C2 2189BB5C 8FA85686 CD98B646 5575B146 8DFC66A8 + 467A3DF4 4D565700 6ADF0F0D CF835015 3C04FF7C 21E878AC 11BA9CD2 55A9232C + 7CA7B7E6 C1AF74F6 152E99B7 B1FCF9BB E973DE7F 5BDDEB86 C71E3B49 1765308B + 5FB0DA06 B92AFE7F 494E8A9E 07B85737 F3A58BE1 1A48A229 C37C1E69 39F08678 + 80DDCD16 D6BACECA EEBC7CF9 8428787B 35202CDC 60E4616A B623CDBD 230E3AFB + 418616A9 4093E049 4D10AB75 27E86F73 932E35B5 8862FDAE 0275156F 719BB2F0 + D697DF7F 28 + quit + ! + ! + license udi pid C8000V sn 9EGHOCL6VW2 + memory free low-watermark processor 201711 + diagnostic bootup level minimal + ! + ! + ! + username ansible privilege 15 secret 9 $9$VslpRow9omMy..$5zvxcxrJqLeDd0qEe.5FANSAeLgz9LLAzMiAjieb/nc + ! + redundancy + ! + ! + ! + ! + ! + ! + ! + ! + interface GigabitEthernet1 + ip address dhcp + no shutdown + negotiation auto + ! + interface GigabitEthernet2 + no ip address + shutdown + negotiation auto + ! + interface GigabitEthernet3 + no ip address + shutdown + negotiation auto + ! + interface GigabitEthernet4 + no ip address + shutdown + negotiation auto + ! + ip forward-protocol nd + ! + no ip http server + ip http secure-server + ip ssh bulk-mode 131072 + ! + ! + ! + ! + ! + control-plane + ! + ! + line con 0 + stopbits 1 + line aux 0 + line vty 0 4 + login local + transport input ssh + ! + ! + ! + ! + ! + ! + ! + end + cpu_limit: null + cpus: null + data_volume: null + hide_links: false + id: n0 + image_definition: null + label: cat8000v-0 + node_definition: cat8000v + parameters: {} + ram: null + tags: [] + x: -120 + y: 40 + interfaces: + - id: i0 + label: Loopback0 + type: loopback + - id: i1 + label: GigabitEthernet1 + slot: 0 + type: physical + - id: i2 + label: GigabitEthernet2 + slot: 1 + type: physical + - id: i3 + label: GigabitEthernet3 + slot: 2 + type: physical + - id: i4 + label: GigabitEthernet4 + 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: [] diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py new file mode 100644 index 000000000..eeda0eed7 --- /dev/null +++ b/tests/integration/test_integration.py @@ -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)