Skip to content

Commit b9b46fd

Browse files
authored
fix UpdateSettingsRequestStreamableTests.mutateInstance (#39386) (#39477)
Mutations of the timeout values were using string-representations. This resulted in very rare cases where the original timeout value was represented as something like "0ms" and the new random time-value generated was "0s". Although their string representations differ, their underlying TimeValue does not. This resulted in `-Dtests.seed=7F4C034C43C22B1B` to fail.
1 parent 609118c commit b9b46fd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/src/test/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequestStreamableTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.elasticsearch.action.support.IndicesOptions;
2323
import org.elasticsearch.common.settings.Settings;
2424
import org.elasticsearch.common.settings.Settings.Builder;
25+
import org.elasticsearch.common.unit.TimeValue;
2526
import org.elasticsearch.common.util.CollectionUtils;
2627
import org.elasticsearch.test.AbstractStreamableTestCase;
2728
import org.elasticsearch.test.ESTestCase;
@@ -32,16 +33,18 @@
3233
import java.util.Locale;
3334
import java.util.Set;
3435
import java.util.StringJoiner;
36+
import java.util.function.Supplier;
3537

3638
public class UpdateSettingsRequestStreamableTests extends AbstractStreamableTestCase<UpdateSettingsRequest> {
3739

3840
@Override
3941
protected UpdateSettingsRequest mutateInstance(UpdateSettingsRequest request) {
4042
UpdateSettingsRequest mutation = copyRequest(request);
4143
List<Runnable> mutators = new ArrayList<>();
44+
Supplier<TimeValue> timeValueSupplier = () -> TimeValue.parseTimeValue(ESTestCase.randomTimeValue(), "_setting");
4245
mutators.add(() -> mutation
43-
.masterNodeTimeout(randomValueOtherThan(request.masterNodeTimeout().getStringRep(), ESTestCase::randomTimeValue)));
44-
mutators.add(() -> mutation.timeout(randomValueOtherThan(request.timeout().getStringRep(), ESTestCase::randomTimeValue)));
46+
.masterNodeTimeout(randomValueOtherThan(request.masterNodeTimeout(), timeValueSupplier)));
47+
mutators.add(() -> mutation.timeout(randomValueOtherThan(request.timeout(), timeValueSupplier)));
4548
mutators.add(() -> mutation.settings(mutateSettings(request.settings())));
4649
mutators.add(() -> mutation.indices(mutateIndices(request.indices())));
4750
mutators.add(() -> mutation.indicesOptions(randomValueOtherThan(request.indicesOptions(),

0 commit comments

Comments
 (0)