From f2edadec4669af5fe6bf68c28d8c8813e57960dc Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Wed, 6 Apr 2022 18:08:15 -0500 Subject: [PATCH] Remove sleep when waiting for node closure (#1722) Signed-off-by: Peter Nied --- .../security/test/helper/cluster/ClusterHelper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java index 1ebd46cec6..75ad6e103b 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java @@ -39,6 +39,7 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -247,10 +248,10 @@ public final void stopCluster() throws Exception { private void closeAllNodes() throws Exception { //close non master nodes - opensearchNodes.stream().filter(n->!n.isMasterEligible()).forEach(node->closeNode(node)); + opensearchNodes.stream().filter(n->!n.isMasterEligible()).forEach(ClusterHelper::closeNode); //close master nodes - opensearchNodes.stream().filter(n->n.isMasterEligible()).forEach(node->closeNode(node)); + opensearchNodes.stream().filter(n->n.isMasterEligible()).forEach(ClusterHelper::closeNode); opensearchNodes.clear(); clusterState = ClusterState.STOPPED; } @@ -258,7 +259,7 @@ private void closeAllNodes() throws Exception { private static void closeNode(Node node) { try { node.close(); - Thread.sleep(250); + node.awaitClose(250, TimeUnit.MILLISECONDS); } catch (Throwable e) { //ignore }