From b381de482f3c205a9f84ebb87db19069ae268cb7 Mon Sep 17 00:00:00 2001 From: Shannon Byrnes Date: Sun, 2 Feb 2025 16:01:42 -0500 Subject: [PATCH] Add ..better... reporting --- .../tester/lab-tester/lab-tester.py | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) 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 2b4c36d..ab46444 100644 --- a/internal-lab-setup-assets/tester/lab-tester/lab-tester.py +++ b/internal-lab-setup-assets/tester/lab-tester/lab-tester.py @@ -13,26 +13,28 @@ CMD_SHOW_DESCRIPTION = f"show run int {TEST_INTERFACE} | i description" TEST_DESCRIPTION = "Management Interface" -success = [] -failure = [] +success = set() +failure = set() def test_show_version(connection): + seek = "Cisco IOS XR Software" output = connection.send_command("show version") try: - assert ( - "Cisco IOS XR Software" in output - ), f"Show version does not have expected string 'Cisco IOS XR Software'. Output: {output}" + assert seek in output except AssertionError: - failure.append(connection.host) + print( + f"FAILED: Show version does not have expected string '{seek}'. Output: {output}" + ) + failure.add(connection.host) else: - success.append(connection.host) + success.add(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}", "commit", "end"] + [TEST_INTERFACE, f"description {TEST_DESCRIPTION}", "commit"] ) new_desc = ( connection.send_command(CMD_SHOW_DESCRIPTION).splitlines()[-1].strip() @@ -40,14 +42,15 @@ def test_configure_description(connection): # Verify try: - assert ( - new_desc.strip() == f"description {TEST_DESCRIPTION}" - ), f"'{new_desc}' on router does not match 'description {TEST_DESCRIPTION}'!" + assert new_desc.strip() == f"description {TEST_DESCRIPTION}" except AssertionError: - failure.append(connection.host) + print( + f"FAILED: '{new_desc}' on router does not match 'description {TEST_DESCRIPTION}'!" + ) + failure.add(connection.host) else: connection.send_config_set(TEST_INTERFACE, "no description", "commit") # revert - success.append(connection.host) + success.add(connection.host) lab_ips = XRD_LAB_IPS.split() @@ -64,7 +67,7 @@ def test_configure_description(connection): test_configure_description(connection) print(f"{len(success)} Succeeded") -print(f"{len(failure)} failed") -if failure: - print(line for line in failure) +print(f"{len(failure)} Failed") +for host in failure: + print(host) print("Complete!")