test: stabilize flaky resource manager client tests#11011
Conversation
Wait for standalone resource manager metadata and RU statistics to become observable before asserting their values. Measure token bucket wait time using the duration returned by the controller so host scheduling delays do not make timing assertions flaky. Signed-off-by: Ryan Leung <rleungx@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughIntegration tests now account for asynchronous resource-group propagation by polling for visibility, controller state, RU statistics, and fill-rate updates. Controller timing assertions use durations returned by request handling instead of measuring elapsed wall-clock time. ChangesResource manager integration test stability
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Keep the upstream GetResourceGroup fallback changes while preserving the remaining resource manager client test stabilization. Signed-off-by: Ryan Leung <rleungx@gmail.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/integrations/mcs/resourcemanager/resource_manager_test.go (1)
804-807: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueScope the error variable inside the closure.
Since
getErris not used outside of thetestutil.Eventuallyclosure, it can be declared locally within the function to minimize its scope.♻️ Proposed refactor
- var getErr error - testutil.Eventually(re, func() bool { - _, getErr = cli.GetResourceGroup(suite.ctx, group.Name) - return getErr == nil + testutil.Eventually(re, func() bool { + _, err := cli.GetResourceGroup(suite.ctx, group.Name) + return err == nil }, testutil.WithTickInterval(50*time.Millisecond))🤖 Prompt for 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. In `@tests/integrations/mcs/resourcemanager/resource_manager_test.go` around lines 804 - 807, Remove the outer getErr declaration and declare the error variable within the testutil.Eventually callback alongside the GetResourceGroup call, preserving the callback’s boolean success check.
🤖 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.
Nitpick comments:
In `@tests/integrations/mcs/resourcemanager/resource_manager_test.go`:
- Around line 804-807: Remove the outer getErr declaration and declare the error
variable within the testutil.Eventually callback alongside the GetResourceGroup
call, preserving the callback’s boolean success check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 76627cfe-5758-44fb-b807-cbc1419f802c
📒 Files selected for processing (1)
tests/integrations/mcs/resourcemanager/resource_manager_test.go
|
@rleungx: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: Close #10650, Close #8512, Close #8739, Close #7400, Ref #6810
Several tests in TestResourceManagerClientTestSuite assume that asynchronous
resource-manager state is visible immediately or include unrelated wall-clock
overhead in timing assertions. These assumptions make the suite flaky under CI
load, especially with standalone resource-manager discovery.
What is changed and how does it work?
The existing final assertions remain in place. The changes only replace
immediate reads and fixed sleeps with condition-based waits and use the
controller-reported wait duration for the timing check.
Check List
Tests
Release note
Summary by CodeRabbit