test(client): pin 1.7.0 backend_metrics shape with deterministic structural assertions#342
Conversation
…ctural assertions
|
@imbajin, any feedback please? |
There was a problem hiding this comment.
Pull request overview
This PR tightens the python-client integration test for GET /metrics/backend by replacing a loose length-only assertion with deterministic structural assertions that pin the expected HugeGraph 1.7.0 backend_metrics response shape (and intended to remain compatible with newer versions).
Changes:
- Introduces a pinned set of expected metric keys (
EXPECTED_BACKEND_SERVER_KEYS) for each backend server entry. - Replaces the old conditional/len-based assertion with explicit structural checks for graph entry fields (
backend,nodes,cluster_id,servers) and expected RocksDB metrics.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace strict single-graph check with assertGreaterEqual(>=1) to support multi-graph environments - Add assertIsInstance for cluster_id to enforce documented str type - Loop over all servers dict entries instead of checking only the first, ensuring every server entry is fully validated against expected RocksDB metric keys No functional change; test coverage and portability improved. Verified: ruff check + ruff format clean. Live backend test pending CI. Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
|
Hey @imbajin — all 13 CI checks are green and Copilot's review looks good too. Would love to get your eyes on this when you have a moment. Thanks! |
…tion and sorted missing keys
|
@imbajin, Done ✅ |
|
@imbajin I have added now... |
|
Note we refact the test frame in #357 |
|
Thanks for the heads-up @imbajin. I checked #357 and understand the test framework has been refactored there. My intention in #342 was specifically to restore deterministic structural assertions for backend_metrics. If there are any adjustments needed to align this PR with the new test framework in #357, I'd be happy to update it. Thanks for reviewing. |
|
just resolve the conflicts 🔢 |
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 intest_metric.pywith deterministic structural assertions based on the actual/metrics/backendresponse 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.
The fix
What was verified
/metrics/backendresponse from a real HugeGraph serverEXPECTED_BACKEND_SERVER_KEYSfrom that real responsebackend,nodes,cluster_id,serversfields exist with correct typesTest results
Both versions return identical shapes — one assertion covers both.
Files changed
Only one file touched:
hugegraph-python-client/src/tests/api/test_metric.py