From 464c88df8820cb29b99071c1996cd1b65ea86f76 Mon Sep 17 00:00:00 2001 From: kkewwei Date: Thu, 20 Feb 2025 10:59:18 +0800 Subject: [PATCH] Fix Flaky Test testPendingTasksWithClusterNotRecoveredBlock Signed-off-by: kkewwei Signed-off-by: kkewwei --- .../action/admin/cluster/tasks/PendingTasksBlocksIT.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java index 2be4acd16671f..45de63f790b12 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java @@ -32,6 +32,7 @@ package org.opensearch.action.admin.cluster.tasks; +import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.common.settings.Settings; import org.opensearch.gateway.GatewayService; import org.opensearch.test.InternalTestCluster; @@ -91,11 +92,12 @@ public void testPendingTasksWithClusterNotRecoveredBlock() throws Exception { } // restart the cluster but prevent it from performing state recovery - final int nodeCount = client().admin().cluster().prepareNodesInfo("data:true", "cluster_manager:true").get().getNodes().size(); + NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(); + final int dataNodesCount = client().admin().cluster().prepareNodesInfo("data:true").get().getNodes().size(); internalCluster().fullRestart(new InternalTestCluster.RestartCallback() { @Override public Settings onNodeStopped(String nodeName) { - return Settings.builder().put(GatewayService.RECOVER_AFTER_DATA_NODES_SETTING.getKey(), nodeCount + 1).build(); + return Settings.builder().put(GatewayService.RECOVER_AFTER_DATA_NODES_SETTING.getKey(), dataNodesCount + 1).build(); } @Override