Skip to content

Commit ba7d90c

Browse files
committed
Fix Flaky Test org.opensearch.gateway.RecoveryFromGatewayIT.testShardStoreFetchMultiNodeMultiIndexesUsingBatchAction
Signed-off-by: kkewwei <[email protected]>
1 parent 5888867 commit ba7d90c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 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());
@@ -1418,6 +1422,7 @@ public void testShardStoreFetchCorruptedIndexUsingBatchAction() throws Exception
14181422
String index1Name = "test1";
14191423
String index2Name = "test2";
14201424
prepareIndices(new String[] { index1Name, index2Name }, 1, 1);
1425+
14211426
Map<ShardId, ShardAttributes> shardAttributesMap = prepareRequestMap(new String[] { index1Name, index2Name }, 1);
14221427
Index index1 = resolveIndex(index1Name);
14231428
ShardId shardId1 = new ShardId(index1, 0);
@@ -1513,10 +1518,14 @@ private void prepareIndices(String[] indices, int numberOfPrimaryShards, int num
15131518

15141519
private TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch prepareAndSendRequest(
15151520
String[] indices,
1516-
DiscoveryNode[] nodes
1521+
DiscoveryNode[] nodes,
1522+
boolean ensureGreen
15171523
) {
15181524
Map<ShardId, ShardAttributes> shardAttributesMap = null;
15191525
prepareIndices(indices, 1, 1);
1526+
if (ensureGreen) {
1527+
ensureGreen(indices);
1528+
}
15201529
shardAttributesMap = prepareRequestMap(indices, 1);
15211530
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response;
15221531
return ActionTestUtils.executeBlocking(

0 commit comments

Comments
 (0)