Skip to content

Commit

Permalink
Fix Flaky Test org.opensearch.gateway.RecoveryFromGatewayIT.testShard…
Browse files Browse the repository at this point in the history
…StoreFetchMultiNodeMultiIndexesUsingBatchAction

Signed-off-by: kkewwei <[email protected]>
  • Loading branch information
kkewwei committed Sep 27, 2024
1 parent 5888867 commit ba7d90c
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,8 @@ public void testSingleShardStoreFetchUsingBatchAction() throws ExecutionExceptio
DiscoveryNode[] nodes = getDiscoveryNodes();
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response = prepareAndSendRequest(
new String[] { indexName },
nodes
nodes,
false
);
Index index = resolveIndex(indexName);
ShardId shardId = new ShardId(index, 0);
Expand All @@ -1379,12 +1380,14 @@ public void testSingleShardStoreFetchUsingBatchAction() throws ExecutionExceptio

public void testShardStoreFetchMultiNodeMultiIndexesUsingBatchAction() throws Exception {
internalCluster().startNodes(2);
ensureStableCluster(2);
String indexName1 = "test1";
String indexName2 = "test2";
DiscoveryNode[] nodes = getDiscoveryNodes();
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response = prepareAndSendRequest(
new String[] { indexName1, indexName2 },
nodes
nodes,
true
);
ClusterSearchShardsResponse searchShardsResponse = client().admin().cluster().prepareSearchShards(indexName1, indexName2).get();
for (ClusterSearchShardsGroup clusterSearchShardsGroup : searchShardsResponse.getGroups()) {
Expand All @@ -1406,7 +1409,8 @@ public void testShardStoreFetchNodeNotConnectedUsingBatchAction() {
String indexName = "test";
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response = prepareAndSendRequest(
new String[] { indexName },
new DiscoveryNode[] { nonExistingNode }
new DiscoveryNode[] { nonExistingNode },
false
);
assertTrue(response.hasFailures());
assertEquals(1, response.failures().size());
Expand All @@ -1418,6 +1422,7 @@ public void testShardStoreFetchCorruptedIndexUsingBatchAction() throws Exception
String index1Name = "test1";
String index2Name = "test2";
prepareIndices(new String[] { index1Name, index2Name }, 1, 1);

Map<ShardId, ShardAttributes> shardAttributesMap = prepareRequestMap(new String[] { index1Name, index2Name }, 1);
Index index1 = resolveIndex(index1Name);
ShardId shardId1 = new ShardId(index1, 0);
Expand Down Expand Up @@ -1513,10 +1518,14 @@ private void prepareIndices(String[] indices, int numberOfPrimaryShards, int num

private TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch prepareAndSendRequest(
String[] indices,
DiscoveryNode[] nodes
DiscoveryNode[] nodes,
boolean ensureGreen
) {
Map<ShardId, ShardAttributes> shardAttributesMap = null;
prepareIndices(indices, 1, 1);
if (ensureGreen) {
ensureGreen(indices);
}
shardAttributesMap = prepareRequestMap(indices, 1);
TransportNodesListShardStoreMetadataBatch.NodesStoreFilesMetadataBatch response;
return ActionTestUtils.executeBlocking(
Expand Down

0 comments on commit ba7d90c

Please sign in to comment.