refactor: replace magic numbers with named constants in tests#987
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (29)
✅ Files skipped from review due to trivial changes (11)
🚧 Files skipped from review as they are similar to previous changes (16)
📝 WalkthroughWalkthroughThis PR centralises shared timing, polling, and port values in ChangesCentralise timing and port constants
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@testsuite/tests/singlecluster/observability/conftest.py`:
- Around line 44-46: The polling predicates passed to backoff.on_predicate are
inverted: backoff retries when the predicate returns True, so change the lambdas
in the observability monitor decorators to return True on failure (e.g., use
len(x) != 5 instead of len(x) == 5, and len(x) != 1 instead of len(x) == 1) so
retries occur while the expected condition is not yet met; keep the existing
interval and max_tries (OBSERVABILITY_MONITOR_POLL_INTERVAL /
OBSERVABILITY_MONITOR_MAX_RETRIES) unchanged and only flip the predicate logic
in the two decorated monitor functions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 967620a5-c5af-4432-982b-3143ad23aa64
📒 Files selected for processing (29)
testsuite/tests/multicluster/load_balanced/test_change_default_geo.pytestsuite/tests/multicluster/load_balanced/test_change_strategy.pytestsuite/tests/singlecluster/authorino/authorization/opa/external_registry/test_cache.pytestsuite/tests/singlecluster/authorino/identity/plain/test_jwt_user_story.pytestsuite/tests/singlecluster/authorino/identity/x509/gateway_validation/test_multi_ca_trust.pytestsuite/tests/singlecluster/authorino/wristband/conftest.pytestsuite/tests/singlecluster/egress/credentials_injection/conftest.pytestsuite/tests/singlecluster/egress/test_egress.pytestsuite/tests/singlecluster/gateway/dnspolicy/health_check/test_additional_headers.pytestsuite/tests/singlecluster/gateway/dnspolicy/health_check/test_remove_endpoint.pytestsuite/tests/singlecluster/gateway/reconciliation/change_targetref/conftest.pytestsuite/tests/singlecluster/gateway/reconciliation/change_targetref/test_update_tlspolicy_target_ref.pytestsuite/tests/singlecluster/gateway/reconciliation/test_gw_doesnt_exist.pytestsuite/tests/singlecluster/gateway/reconciliation/test_invalid_issuer_reference.pytestsuite/tests/singlecluster/gateway/reconciliation/test_same_target.pytestsuite/tests/singlecluster/gateway/scaling/test_auto_scale_gateway.pytestsuite/tests/singlecluster/gateway/scaling/test_manual_scale_gateway.pytestsuite/tests/singlecluster/grpc/test_grpcroute.pytestsuite/tests/singlecluster/identical_hostnames/rlp/test_rlp_on_gw_and_route.pytestsuite/tests/singlecluster/identical_hostnames/rlp/test_rlp_on_routes.pytestsuite/tests/singlecluster/limitador/test_multiple_iterations.pytestsuite/tests/singlecluster/limitador/tokens_rate_limit/basic/test_trlp.pytestsuite/tests/singlecluster/limitador/tokens_rate_limit/basic/test_trlp_streaming.pytestsuite/tests/singlecluster/limitador/tokens_rate_limit/multiple_iterations/test_multiple_trlp_iterations.pytestsuite/tests/singlecluster/limitador/tokens_rate_limit/multiple_iterations/test_multiple_trlp_stream_iterations.pytestsuite/tests/singlecluster/observability/conftest.pytestsuite/tests/singlecluster/tracing/control_plane/test_control_plane_errors.pytestsuite/tests/singlecluster/tracing/control_plane/test_control_plane_lifecycle.pytestsuite/utils/constants.py
Signed-off-by: Priyanshu-u07 <connect.priyanshu8271@gmail.com>
56b4930 to
29a744e
Compare
|
Hi @Priyanshu-u07, your PR is almost ready for approval, but you need to resolve the conflicts first 👍 |
|
Thank you for the review @emmaaroche! I've resolved the merge conflicts. PTAL. |
emmaaroche
left a comment
There was a problem hiding this comment.
LGTM, thank you for working on this!
Description
Replaces all hardcoded magic numbers in test files with named constants from
testsuite/utils/constants.py.Closes #930
Changes
Refactored Files (28)
Files
Fix
test_rlp_on_routes.py: Fixed typos 1rp10m/2rp10m to 1rp10s/2rp10s (limit window is 10 seconds not minutes).observability/conftest.py: Fixedbackoff.on_predicatepredicate inversion (== to !=), ensuring retry continues untilexpected monitor count is reached.
Verification
Note
Intentionally left as hardcoded
sleep(1)intest_jwt_user_story.py: Fixed 1 second wait used between retries. It is only a small delay while the main configurable value isJWT_STARTUP_MAX_RETRIES.max_tries=7inmtls/conftest.py: Kept hardcoded because it is tied to thebackoff.fibo. Making it a constant would make the retry behavior harder to understand.Summary by CodeRabbit
Summary by CodeRabbit