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 (#14264)

Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit 5ec2abe)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jun 17, 2024
1 parent eb6471d commit 61a7064
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 61a7064

Please sign in to comment.