diff --git a/src/integration-tests/test_admin_client.py b/src/integration-tests/test_admin_client.py index bac87bb77..67ebe8542 100644 --- a/src/integration-tests/test_admin_client.py +++ b/src/integration-tests/test_admin_client.py @@ -90,6 +90,7 @@ def extract_stats(admin_response: str) -> dict: def expect_same_structure( entry: Union[dict, list, str, int], expected: Union[dict, list, str, int, dt.ValueConstraint], + path: str = "", ) -> None: """ Check if the specified 'entry' has the same structure as the specified 'expected'. @@ -100,14 +101,20 @@ def expect_same_structure( if isinstance(expected, dict): assert isinstance(entry, dict) - assert expected.keys() == entry.keys() + assert expected.keys() == entry.keys(), ( + path, + "Extra expected keys:", + expected.keys() - entry.keys(), + "Missing expected keys:", + entry.keys() - expected.keys(), + ) for key in expected: - expect_same_structure(entry[key], expected[key]) + expect_same_structure(entry[key], expected[key], path + "." + key) elif isinstance(expected, list): assert isinstance(entry, list) assert len(expected) == len(entry) for obj2, expected2 in zip(entry, expected): - expect_same_structure(obj2, expected2) + expect_same_structure(obj2, expected2, path + "." + key) elif isinstance(expected, str): assert isinstance(entry, str) assert expected == entry @@ -117,7 +124,7 @@ def expect_same_structure( assert expected.check(entry) else: assert isinstance(expected, int) - assert entry == expected + assert entry == expected, (path, "expected:", expected, "actual:", entry) def test_breathing(single_node: Cluster) -> None: @@ -210,7 +217,7 @@ def test_queue_stats(single_node: Cluster) -> None: stats = extract_stats(admin.send_admin("encoding json_pretty stat show")) queue_stats = stats["domainQueues"]["domains"][tc.DOMAIN_FANOUT][task.uri] - expect_same_structure(queue_stats, dt.TEST_QUEUE_STATS_AFTER_POST) + expect_same_structure(queue_stats, dt.TEST_QUEUE_STATS_AFTER_POST, "after-post") # Stage 2: check stats after confirming messages consumer_foo: Client = proxy.create_client("consumer_foo") @@ -228,7 +235,9 @@ def test_queue_stats(single_node: Cluster) -> None: stats = extract_stats(admin.send_admin("encoding json_pretty stat show")) queue_stats = stats["domainQueues"]["domains"][tc.DOMAIN_FANOUT][task.uri] - expect_same_structure(queue_stats, dt.TEST_QUEUE_STATS_AFTER_CONFIRM) + expect_same_structure( + queue_stats, dt.TEST_QUEUE_STATS_AFTER_CONFIRM, "after-confirm" + ) # Stage 3: check stats after purging an appId res = admin.send_admin( @@ -239,7 +248,7 @@ def test_queue_stats(single_node: Cluster) -> None: stats = extract_stats(admin.send_admin("encoding json_pretty stat show")) queue_stats = stats["domainQueues"]["domains"][tc.DOMAIN_FANOUT][task.uri] - expect_same_structure(queue_stats, dt.TEST_QUEUE_STATS_AFTER_PURGE) + expect_same_structure(queue_stats, dt.TEST_QUEUE_STATS_AFTER_PURGE, "after-purge") consumer_foo.close(f"{task.uri}?id=foo") consumer_bar.close(f"{task.uri}?id=bar") @@ -251,7 +260,7 @@ def test_queue_stats(single_node: Cluster) -> None: res = admin.send_admin("encoding json_pretty stat show") obj = json.loads(res) - expect_same_structure(obj, dt.TEST_QUEUE_STATS_TOO_OFTEN_SNAPSHOTS) + expect_same_structure(obj, dt.TEST_QUEUE_STATS_TOO_OFTEN_SNAPSHOTS, "too-often") admin.stop()