Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It: Include full path for admin stat it test failures #453

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/integration-tests/test_admin_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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")
Expand All @@ -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(
Expand All @@ -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")
Expand All @@ -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()

Expand Down
Loading