diff --git a/internal-lab-setup-assets/tester/lab-tester/lab-tester.py b/internal-lab-setup-assets/tester/lab-tester/lab-tester.py index 9c2b0bb..0bc3b47 100644 --- a/internal-lab-setup-assets/tester/lab-tester/lab-tester.py +++ b/internal-lab-setup-assets/tester/lab-tester/lab-tester.py @@ -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 @@ -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.