HDDS-15806. Replace Thread.sleep with GenericTestUtils.waitFor in server-scm node tests#10704
Open
smengcl wants to merge 5 commits into
Open
HDDS-15806. Replace Thread.sleep with GenericTestUtils.waitFor in server-scm node tests#10704smengcl wants to merge 5 commits into
smengcl wants to merge 5 commits into
Conversation
…ver-scm node tests
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates SCM node-related unit tests in hadoop-hdds/server-scm to avoid fixed-duration sleeps and instead wait deterministically for expected conditions using GenericTestUtils.waitFor, reducing test flakiness and unnecessary delays.
Changes:
- Replaced
Thread.sleep(...)/ staticsleep(...)calls withGenericTestUtils.waitFor(...)polling in several SCM node tests. - Updated test method signatures to declare
TimeoutExceptionwhere required bywaitFor. - Added the necessary test utility imports in the updated test classes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeMetrics.java | Replaces a fixed sleep after processing a heartbeat with a waitFor on healthy node count. |
| hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java | Replaces multiple fixed sleeps with waitFor conditions and updates thrown exceptions accordingly. |
| hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestContainerPlacement.java | Replaces a fixed sleep with waitFor to ensure node health state is reflected before asserting placement metrics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sarvekshayr
reviewed
Jul 10, 2026
sarvekshayr
left a comment
Contributor
There was a problem hiding this comment.
Thanks @smengcl for the patch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Thread.sleepwaits withGenericTestUtils.waitForpolling inhadoop-hdds/server-scmnode tests.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15806
How was this patch tested?