Skip to content
Merged
Show file tree
Hide file tree
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 @@ -721,7 +721,7 @@ static Request clusterHealth(ClusterHealthRequest healthRequest) {
.withWaitForStatus(healthRequest.waitForStatus())
.withWaitForNoRelocatingShards(healthRequest.waitForNoRelocatingShards())
.withWaitForNoInitializingShards(healthRequest.waitForNoInitializingShards())
.withWaitForActiveShards(healthRequest.waitForActiveShards())
.withWaitForActiveShards(healthRequest.waitForActiveShards(), ActiveShardCount.NONE)
.withWaitForNodes(healthRequest.waitForNodes())
.withWaitForEvents(healthRequest.waitForEvents())
.withTimeout(healthRequest.timeout())
Expand Down Expand Up @@ -1047,7 +1047,11 @@ Params withVersionType(VersionType versionType) {
}

Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
if (activeShardCount != null && activeShardCount != ActiveShardCount.DEFAULT) {
return withWaitForActiveShards(activeShardCount, ActiveShardCount.DEFAULT);
}

Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCount defaultActiveShardCount) {
if (activeShardCount != null && activeShardCount != defaultActiveShardCount) {
return putParam("wait_for_active_shards", activeShardCount.toString().toLowerCase(Locale.ROOT));
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ public void testClusterHealth() {
default:
throw new UnsupportedOperationException();
}
setRandomWaitForActiveShards(healthRequest::waitForActiveShards, expectedParams, "0");
setRandomWaitForActiveShards(healthRequest::waitForActiveShards, ActiveShardCount.NONE, expectedParams);
if (randomBoolean()) {
ClusterHealthRequest.Level level = randomFrom(ClusterHealthRequest.Level.values());
healthRequest.level(level);
Expand Down Expand Up @@ -2187,23 +2187,24 @@ private static void setRandomMasterTimeout(MasterNodeRequest<?> request, Map<Str
}

private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> setter, Map<String, String> expectedParams) {
setRandomWaitForActiveShards(setter, expectedParams, null);
setRandomWaitForActiveShards(setter, ActiveShardCount.DEFAULT, expectedParams);
}

private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> setter,Map<String, String> expectedParams,
String defaultValue) {
private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> setter, ActiveShardCount defaultActiveShardCount,
Map<String, String> expectedParams) {
if (randomBoolean()) {
int waitForActiveShardsInt = randomIntBetween(-1, 5);
String waitForActiveShardsString;
int waitForActiveShards = randomIntBetween(-1, 5);
if (waitForActiveShards == -1) {
if (waitForActiveShardsInt == -1) {
waitForActiveShardsString = "all";
} else {
waitForActiveShardsString = String.valueOf(waitForActiveShards);
waitForActiveShardsString = String.valueOf(waitForActiveShardsInt);
}
ActiveShardCount activeShardCount = ActiveShardCount.parseString(waitForActiveShardsString);
setter.accept(activeShardCount);
if (defaultActiveShardCount.equals(activeShardCount) == false) {
expectedParams.put("wait_for_active_shards", waitForActiveShardsString);
}
setter.accept(ActiveShardCount.parseString(waitForActiveShardsString));
expectedParams.put("wait_for_active_shards", waitForActiveShardsString);
} else if (defaultValue != null) {
expectedParams.put("wait_for_active_shards", defaultValue);
}
}

Expand Down