Skip to content

test(client): pin 1.7.0 backend_metrics shape with deterministic structural assertions#342

Open
Muawiya-contact wants to merge 2 commits into
apache:mainfrom
Muawiya-contact:fix/backend-metrics-strict-assertion
Open

test(client): pin 1.7.0 backend_metrics shape with deterministic structural assertions#342
Muawiya-contact wants to merge 2 commits into
apache:mainfrom
Muawiya-contact:fix/backend-metrics-strict-assertion

Conversation

@Muawiya-contact
Copy link
Copy Markdown
Contributor

test(client): pin 1.7.0 backend_metrics shape with deterministic structural assertions

Closes #326


What does this PR do?

Replaces the loose assertGreater(len(...), 1) check in test_metric.py with deterministic structural assertions based on the actual /metrics/backend response captured from a real HugeGraph server.

The problem

The old assertion only checked length — shape drift in the API response would pass silently without any test failure.

# Before — too loose
self.assertGreater(len(backend_metrics["hugegraph"]), 1)

The fix

# After — deterministic structural assertion
missing_keys = EXPECTED_BACKEND_SERVER_KEYS - set(server_entry.keys())
self.assertFalse(missing_keys, f"Missing expected keys: {missing_keys}")

What was verified

  • Captured the actual /metrics/backend response from a real HugeGraph server
  • Pinned EXPECTED_BACKEND_SERVER_KEYS from that real response
  • Asserts backend, nodes, cluster_id, servers fields exist with correct types
  • Asserts all expected rocksdb metric keys are present in the server entry

Test results

Server version Result
HugeGraph 1.7.0 (Docker) ✅ PASSED
HugeGraph latest (Docker) ✅ PASSED

Both versions return identical shapes — one assertion covers both.

Files changed

Only one file touched: hugegraph-python-client/src/tests/api/test_metric.py

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 22, 2026
@Muawiya-contact
Copy link
Copy Markdown
Contributor Author

@imbajin, any feedback please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python-client size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] test: restore strict assertion for backend_metrics in test_metric.py

1 participant