janhoy commented on code in PR #2391:
URL: https://github.com/apache/solr/pull/2391#discussion_r3217033659


##########
solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java:
##########
@@ -389,6 +663,87 @@ public void waitForNode(JettySolrRunner jetty, int 
timeoutSeconds)
             timeoutSeconds, TimeUnit.SECONDS, (o, n) -> n != null && 
n.contains(nodeName));
   }
 
+  /**
+   * Wait for the expected number of live nodes in the cluster.
+   *
+   * @param expectedCount expected number of live nodes
+   * @param timeoutSeconds timeout in seconds
+   * @throws InterruptedException if interrupted while waiting
+   * @throws TimeoutException if the expected count is not reached within the 
timeout
+   */
+  public void waitForLiveNodes(int expectedCount, int timeoutSeconds)
+      throws InterruptedException, TimeoutException {
+    TimeOut timeout = new TimeOut(timeoutSeconds, TimeUnit.SECONDS, 
TimeSource.NANO_TIME);
+    while (!timeout.hasTimedOut()) {
+      long runningNodes = 
jettys.stream().filter(JettySolrRunner::isRunning).count();
+      if (runningNodes == expectedCount) {
+        log.info("Verified {} live nodes", runningNodes);
+        return;
+      }
+      Thread.sleep(200);
+    }
+    // Final check after timeout
+    long actualCount = 
jettys.stream().filter(JettySolrRunner::isRunning).count();
+    throw new TimeoutException(
+        "Live node count mismatch: expected " + expectedCount + " but got " + 
actualCount);

Review Comment:
   Added a TODO to code..



-- 
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