Skip to content

Commit

Permalink
Fix flaky tests in org.opensearch.cluster.routing.remote.RemoteRoutin…
Browse files Browse the repository at this point in the history
…gTableServiceTests (opensearch-project#14264)

Signed-off-by: Gao Binlong <[email protected]>
  • Loading branch information
gaobinlong authored and wangdongyu.danny committed Aug 22, 2024
1 parent a09368e commit 1d0fada
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ public void testGetIndicesRoutingMapDiffIndexAdded() {
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid")
.build()
).numberOfShards(randomInt(1000)).numberOfReplicas(randomInt(10)).build();
).numberOfShards(between(1, 1000)).numberOfReplicas(randomInt(10)).build();
RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetadata).build();

String indexName2 = randomAlphaOfLength(randomIntBetween(1, 50));
int noOfShards = randomInt(1000);
int noOfShards = between(1, 1000);
int noOfReplicas = randomInt(10);
final IndexMetadata indexMetadata2 = new IndexMetadata.Builder(indexName2).settings(
Settings.builder()
Expand All @@ -252,8 +252,7 @@ public void testGetIndicesRoutingMapDiffIndexAdded() {

public void testGetIndicesRoutingMapDiffShardChanged() {
String indexName = randomAlphaOfLength(randomIntBetween(1, 50));
final Index index = new Index(indexName, "uuid");
int noOfShards = randomInt(1000);
int noOfShards = between(1, 1000);
int noOfReplicas = randomInt(10);
final IndexMetadata indexMetadata = new IndexMetadata.Builder(indexName).settings(
Settings.builder()
Expand Down Expand Up @@ -299,8 +298,7 @@ public void testGetIndicesRoutingMapDiffShardChanged() {

public void testGetIndicesRoutingMapDiffShardDetailChanged() {
String indexName = randomAlphaOfLength(randomIntBetween(1, 50));
final Index index = new Index(indexName, "uuid");
int noOfShards = randomInt(1000);
int noOfShards = between(1, 1000);
int noOfReplicas = randomInt(10);
final IndexMetadata indexMetadata = new IndexMetadata.Builder(indexName).settings(
Settings.builder()
Expand Down Expand Up @@ -328,7 +326,7 @@ public void testGetIndicesRoutingMapDiffIndexDeleted() {
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid")
.build()
).numberOfShards(randomInt(1000)).numberOfReplicas(randomInt(10)).build();
).numberOfShards(between(1, 1000)).numberOfReplicas(randomInt(10)).build();
RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetadata).build();

String indexName2 = randomAlphaOfLength(randomIntBetween(1, 50));
Expand All @@ -337,7 +335,7 @@ public void testGetIndicesRoutingMapDiffIndexDeleted() {
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid2")
.build()
).numberOfShards(randomInt(1000)).numberOfReplicas(randomInt(10)).build();
).numberOfShards(between(1, 1000)).numberOfReplicas(randomInt(10)).build();
RoutingTable routingTable2 = RoutingTable.builder().addAsNew(indexMetadata2).build();

DiffableUtils.MapDiff<String, IndexRoutingTable, Map<String, IndexRoutingTable>> diff = remoteRoutingTableService
Expand Down Expand Up @@ -732,7 +730,6 @@ private ClusterState createIndices(int numberOfIndices) {
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
for (int i = 0; i < numberOfIndices; i++) {
String indexName = randomAlphaOfLength(randomIntBetween(1, 50));
final Index index = new Index(indexName, "uuid");
final IndexMetadata indexMetadata = new IndexMetadata.Builder(indexName).settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
Expand All @@ -751,7 +748,7 @@ private ClusterState createClusterState(String indexName) {
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid")
.build()
).numberOfShards(randomInt(1000)).numberOfReplicas(randomInt(10)).build();
).numberOfShards(between(1, 1000)).numberOfReplicas(randomInt(10)).build();
RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetadata).build();
return ClusterState.builder(ClusterName.DEFAULT)
.routingTable(routingTable)
Expand Down

0 comments on commit 1d0fada

Please sign in to comment.