Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests in org.opensearch.cluster.routing.remote.RemoteRoutingTableServiceTests #14264

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading