Skip to content

HDDS-15806. Replace Thread.sleep with GenericTestUtils.waitFor in server-scm node tests#10704

Open
smengcl wants to merge 5 commits into
apache:masterfrom
smengcl:HDDS-15806-scm-node-tests-wait-not-sleep
Open

HDDS-15806. Replace Thread.sleep with GenericTestUtils.waitFor in server-scm node tests#10704
smengcl wants to merge 5 commits into
apache:masterfrom
smengcl:HDDS-15806-scm-node-tests-wait-not-sleep

Conversation

@smengcl

@smengcl smengcl commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  1. Replaces fixed Thread.sleep waits with GenericTestUtils.waitFor polling in hadoop-hdds/server-scm node tests.
  2. Fixed reversed assertEquals(actual, expected) argument order
  3. testScmHeartbeat: the previous wait condition is satisfied at registration time, so it never actually depended on heartbeat processing. It now asserts NumHBProcessed, which is the signal that reflects processed heartbeats. And since processHeartbeat() runs synchronously in the test loop, this is a plain assertion with no wait

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15806

How was this patch tested?

  • Tests themselves.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...) / static sleep(...) calls with GenericTestUtils.waitFor(...) polling in several SCM node tests.
  • Updated test method signatures to declare TimeoutException where required by waitFor.
  • 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.

@smengcl smengcl marked this pull request as ready for review July 10, 2026 02:09

@sarvekshayr sarvekshayr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @smengcl for the patch.

Copilot AI review requested due to automatic review settings July 10, 2026 19:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 10, 2026 21:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@smengcl smengcl marked this pull request as draft July 10, 2026 22:05
Copilot AI review requested due to automatic review settings July 10, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@smengcl smengcl marked this pull request as ready for review July 10, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants