yandrey321 commented on code in PR #10837:
URL: https://github.com/apache/ozone/pull/10837#discussion_r3749832010


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -790,28 +791,20 @@ public void testScmDetectStaleAndDeadNode()
       DatanodeDetails staleNode = 
HddsTestUtils.createRandomDatanodeAndRegister(
           nodeManager);
 
-      // Heartbeat once
+      // Heartbeat the stale node once; it ages into stale then dead while the
+      // other nodes are kept alive.
       nodeManager.processHeartbeat(staleNode);
 
-      // Heartbeat all other nodes.
-      for (DatanodeDetails dn : nodeList) {
-        nodeManager.processHeartbeat(dn);
-      }
-
-      // Wait for 2 seconds .. and heartbeat good nodes again.
-      Thread.sleep(2 * 1000);
-
-      for (DatanodeDetails dn : nodeList) {
-        nodeManager.processHeartbeat(dn);
-      }
+      // Keep the good nodes alive until the stale node moves into stale state.
+      GenericTestUtils.waitFor(() -> {
+        for (DatanodeDetails dn : nodeList) {
+          nodeManager.processHeartbeat(dn);
+        }
+        return nodeManager.getNodeCount(NodeStatus.inServiceStale()) == 1;
+      }, interval, 10 * 1000);

Review Comment:
   nit: max wait time should be named constant.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to