Skip to content

Commit

Permalink
Add fixes and better error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
sbyrnes committed Feb 2, 2025
1 parent 11af276 commit c626cc3
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions internal-lab-setup-assets/tester/lab-tester/lab-tester.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from netmiko import Netmiko

TEST_INTERFACE = "mgmtEth0/RP0/CPU0/0" # Guaranteed to exist in our XRd
TEST_INTERFACE = "int mgmtEth0/RP0/CPU0/0" # Guaranteed to exist in our XRd
XRD_LAB_IPS = os.environ.get("XRD_LAB_IPS") # Fed in by Makefile

# Lab access creds
Expand All @@ -13,26 +13,44 @@
CMD_SHOW_DESCRIPTION = f"show run int {TEST_INTERFACE} | i description"
TEST_DESCRIPTION = "Management Interface"

success = []
failure = []


def test_show_version(connection):
output = connection.send_command("show version")
assert (
"Cisco IOS XR Software" in output
), f"Show version does not have expected string 'Cisco IOS XR Software'. Output: {output}"
try:
assert (
"Cisco IOS XR Software" in output
), f"Show version does not have expected string 'Cisco IOS XR Software'. Output: {output}"
except AssertionError:
failure.append(connection.host)
else:
success.append(connection.host)


def test_configure_description(connection):
# Note: If any description existed before, it will be blanked out
connection.send_config_set(TEST_INTERFACE, f"description {TEST_DESCRIPTION}")
new_desc = connection.send_command(CMD_SHOW_DESCRIPTION)
assert (
new_desc == f"description {TEST_DESCRIPTION}"
), f"'{new_desc}' on router does not match 'description {TEST_DESCRIPTION}'!"
connection.send_config_set(TEST_INTERFACE, "no description") # revert
connection.send_config_set(
[TEST_INTERFACE, f"description {TEST_DESCRIPTION}", "commit", "end"]
)
new_desc = (
connection.send_command(CMD_SHOW_DESCRIPTION).splitlines()[-1].strip()
) # skip newline and timestamp

# Verify
try:
assert (
new_desc.strip() == f"description {TEST_DESCRIPTION}"
), f"'{new_desc}' on router does not match 'description {TEST_DESCRIPTION}'!"
except AssertionError:
failure.append(connection.host)
else:
connection.send_config_set(TEST_INTERFACE, "no description", "commit") # revert
success.append(connection.host)


lab_ips = XRD_LAB_IPS.split()
print(lab_ips)

for ip in lab_ips:
# Create a variable that represents an SSH connection to our router.
Expand Down

0 comments on commit c626cc3

Please sign in to comment.