Skip to content

Commit

Permalink
Add ..better... reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
sbyrnes committed Feb 2, 2025
1 parent d339a5a commit b381de4
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions internal-lab-setup-assets/tester/lab-tester/lab-tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,44 @@
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()
) # 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}'!"
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()
Expand All @@ -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!")

0 comments on commit b381de4

Please sign in to comment.