Skip to content

Commit 9e53d9b

Browse files
authored
Fix Flaky Test org.opensearch.gateway.RecoveryFromGatewayIT.testShardStoreFetchMultiNodeMultiIndexesUsingBatchAction (#16093)
Signed-off-by: kkewwei <[email protected]>
1 parent 68e3e45 commit 9e53d9b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,8 @@ public void testSingleShardStoreFetchUsingBatchAction() throws ExecutionExceptio
13661366
DiscoveryNode[] nodes = getDiscoveryNodes();
13671367
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response = prepareAndSendRequest(
13681368
new String[] { indexName },
1369-
nodes
1369+
nodes,
1370+
false
13701371
);
13711372
Index index = resolveIndex(indexName);
13721373
ShardId shardId = new ShardId(index, 0);
@@ -1379,12 +1380,14 @@ public void testSingleShardStoreFetchUsingBatchAction() throws ExecutionExceptio
13791380

13801381
public void testShardStoreFetchMultiNodeMultiIndexesUsingBatchAction() throws Exception {
13811382
internalCluster().startNodes(2);
1383+
ensureStableCluster(2);
13821384
String indexName1 = "test1";
13831385
String indexName2 = "test2";
13841386
DiscoveryNode[] nodes = getDiscoveryNodes();
13851387
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response = prepareAndSendRequest(
13861388
new String[] { indexName1, indexName2 },
1387-
nodes
1389+
nodes,
1390+
true
13881391
);
13891392
ClusterSearchShardsResponse searchShardsResponse = client().admin().cluster().prepareSearchShards(indexName1, indexName2).get();
13901393
for (ClusterSearchShardsGroup clusterSearchShardsGroup : searchShardsResponse.getGroups()) {
@@ -1406,7 +1409,8 @@ public void testShardStoreFetchNodeNotConnectedUsingBatchAction() {
14061409
String indexName = "test";
14071410
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response = prepareAndSendRequest(
14081411
new String[] { indexName },
1409-
new DiscoveryNode[] { nonExistingNode }
1412+
new DiscoveryNode[] { nonExistingNode },
1413+
false
14101414
);
14111415
assertTrue(response.hasFailures());
14121416
assertEquals(1, response.failures().size());
@@ -1513,10 +1517,14 @@ private void prepareIndices(String[] indices, int numberOfPrimaryShards, int num
15131517

15141518
private TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch prepareAndSendRequest(
15151519
String[] indices,
1516-
DiscoveryNode[] nodes
1520+
DiscoveryNode[] nodes,
1521+
boolean ensureGreen
15171522
) {
15181523
Map<ShardId, ShardAttributes> shardAttributesMap = null;
15191524
prepareIndices(indices, 1, 1);
1525+
if (ensureGreen) {
1526+
ensureGreen(indices);
1527+
}
15201528
shardAttributesMap = prepareRequestMap(indices, 1);
15211529
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response;
15221530
return ActionTestUtils.executeBlocking(

0 commit comments

Comments
 (0)