[TEST] Fix ChunkingConfigTests due to time value randomization
Original commit: elastic/x-pack-elasticsearch@c145b399b65de152ace55dd3bb7a81f12264f62c
@@ -10,6 +10,9 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+
import static org.hamcrest.Matchers.is;
public class ChunkingConfigTests extends AbstractSerializingTestCase<ChunkingConfig> {
@@ -51,8 +54,12 @@ public class ChunkingConfigTests extends AbstractSerializingTestCase<ChunkingCon
ChunkingConfig.Mode mode = randomFrom(ChunkingConfig.Mode.values());
TimeValue timeSpan = null;
if (mode == ChunkingConfig.Mode.MANUAL) {
- timeSpan = TimeValue.parseTimeValue(randomPositiveTimeValue(), "test");
+ timeSpan = randomPositiveSecondsMinutesHours();
}
return new ChunkingConfig(mode, timeSpan);
}
+
+ private static TimeValue randomPositiveSecondsMinutesHours() {
+ return new TimeValue(randomIntBetween(1, 1000), randomFrom(Arrays.asList(TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS)));
+ }
}
\ No newline at end of file
