From 5aaebb6d8303c1b99d509676f560cd40b078fdb3 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 25 May 2015 06:48:34 -0400 Subject: [PATCH] add missing units to tests --- rest-api-spec/test/create/75_ttl.yaml | 2 +- rest-api-spec/test/index/75_ttl.yaml | 2 +- rest-api-spec/test/update/75_ttl.yaml | 2 +- .../common/settings/ImmutableSettings.java | 2 +- .../elasticsearch/common/unit/TimeValue.java | 2 ++ .../bucket/histogram/DateHistogramInterval.java | 2 +- .../pipeline/derivative/DerivativeParser.java | 2 +- .../org/elasticsearch/cluster/ack/AckTests.java | 14 ++++++++------ .../common/unit/FuzzinessTests.java | 2 +- .../common/unit/TimeValueTests.java | 16 ++++++++-------- .../engine/InternalEngineSettingsTest.java | 15 +++++++++++---- .../percolator/TTLPercolatorTests.java | 6 +++--- .../recovery/RecoverySettingsTest.java | 17 ++++++++++++----- .../aggregations/bucket/DateHistogramTests.java | 4 ++-- .../aggregations/pipeline/DerivativeTests.java | 4 ++-- .../SharedClusterSnapshotRestoreTests.java | 6 +++--- .../elasticsearch/test/InternalTestCluster.java | 2 +- .../org/elasticsearch/ttl/SimpleTTLTests.java | 2 +- 18 files changed, 60 insertions(+), 42 deletions(-) diff --git a/rest-api-spec/test/create/75_ttl.yaml b/rest-api-spec/test/create/75_ttl.yaml index 3354e3b0517..26561c22155 100644 --- a/rest-api-spec/test/create/75_ttl.yaml +++ b/rest-api-spec/test/create/75_ttl.yaml @@ -45,7 +45,7 @@ type: test id: 1 body: { foo: bar } - ttl: 100000 + ttl: 100000ms - do: get: index: test_1 diff --git a/rest-api-spec/test/index/75_ttl.yaml b/rest-api-spec/test/index/75_ttl.yaml index 554933654fb..6d55e307e19 100644 --- a/rest-api-spec/test/index/75_ttl.yaml +++ b/rest-api-spec/test/index/75_ttl.yaml @@ -40,7 +40,7 @@ type: test id: 1 body: { foo: bar } - ttl: 100000 + ttl: 100000ms - do: get: index: test_1 diff --git a/rest-api-spec/test/update/75_ttl.yaml b/rest-api-spec/test/update/75_ttl.yaml index 8072c4d400f..92c4a5049a4 100644 --- a/rest-api-spec/test/update/75_ttl.yaml +++ b/rest-api-spec/test/update/75_ttl.yaml @@ -44,7 +44,7 @@ body: doc: { foo: baz } upsert: { foo: bar } - ttl: 100000 + ttl: 100000ms - do: get: diff --git a/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java b/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java index 0a7e9e14329..e8e0b0ed687 100644 --- a/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java +++ b/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java @@ -806,7 +806,7 @@ public class ImmutableSettings implements Settings { * @return The builder */ public Builder put(String setting, long value, TimeUnit timeUnit) { - put(setting, timeUnit.toMillis(value)); + put(setting, timeUnit.toMillis(value) + "ms"); return this; } diff --git a/src/main/java/org/elasticsearch/common/unit/TimeValue.java b/src/main/java/org/elasticsearch/common/unit/TimeValue.java index 3883e021cc1..9da093a62fb 100644 --- a/src/main/java/org/elasticsearch/common/unit/TimeValue.java +++ b/src/main/java/org/elasticsearch/common/unit/TimeValue.java @@ -255,6 +255,8 @@ public class TimeValue implements Serializable, Streamable { millis = 0; } else { // Missing units: + // nocommit + System.out.println("MKM: Failed to parse setting [" + settingName + "] with value [" + sValue + "] as a time value: unit is missing or unrecognized"); throw new ElasticsearchParseException("Failed to parse setting [" + settingName + "] with value [" + sValue + "] as a time value: unit is missing or unrecognized"); } return new TimeValue(millis, TimeUnit.MILLISECONDS); diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramInterval.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramInterval.java index 07dd6dc21fa..7e99b389ba0 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramInterval.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramInterval.java @@ -63,4 +63,4 @@ public class DateHistogramInterval { public String toString() { return expression; } -} \ No newline at end of file +} diff --git a/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java index 46b10162033..860d918d526 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java @@ -106,7 +106,7 @@ public class DerivativeParser implements PipelineAggregator.Parser { if (dateTimeUnit != null) { xAxisUnits = dateTimeUnit.field().getDurationField().getUnitMillis(); } else { - TimeValue timeValue = TimeValue.parseTimeValue(units, null, "DerivativeParser.units"); + TimeValue timeValue = TimeValue.parseTimeValue(units, null, "DerivativeParser.unit"); if (timeValue != null) { xAxisUnits = timeValue.getMillis(); } diff --git a/src/test/java/org/elasticsearch/cluster/ack/AckTests.java b/src/test/java/org/elasticsearch/cluster/ack/AckTests.java index 00724aada21..29adf66953f 100644 --- a/src/test/java/org/elasticsearch/cluster/ack/AckTests.java +++ b/src/test/java/org/elasticsearch/cluster/ack/AckTests.java @@ -19,9 +19,6 @@ package org.elasticsearch.cluster.ack; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; @@ -47,6 +44,11 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.warmer.IndexWarmersMetaData; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; +import com.carrotsearch.hppc.cursors.ObjectObjectCursor; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; + +import java.util.concurrent.TimeUnit; import static org.elasticsearch.cluster.metadata.IndexMetaData.*; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; @@ -70,11 +72,11 @@ public class AckTests extends ElasticsearchIntegrationTest { createIndex("test"); assertAcked(client().admin().indices().prepareUpdateSettings("test") - .setSettings(ImmutableSettings.builder().put("refresh_interval", 9999))); + .setSettings(ImmutableSettings.builder().put("refresh_interval", 9999, TimeUnit.MILLISECONDS))); for (Client client : clients()) { String refreshInterval = getLocalClusterState(client).metaData().index("test").settings().get("index.refresh_interval"); - assertThat(refreshInterval, equalTo("9999")); + assertThat(refreshInterval, equalTo("9999ms")); } } @@ -82,7 +84,7 @@ public class AckTests extends ElasticsearchIntegrationTest { public void testUpdateSettingsNoAcknowledgement() { createIndex("test"); UpdateSettingsResponse updateSettingsResponse = client().admin().indices().prepareUpdateSettings("test").setTimeout("0s") - .setSettings(ImmutableSettings.builder().put("refresh_interval", 9999)).get(); + .setSettings(ImmutableSettings.builder().put("refresh_interval", 9999, TimeUnit.MILLISECONDS)).get(); assertThat(updateSettingsResponse.isAcknowledged(), equalTo(false)); } diff --git a/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java b/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java index e09827d9fc8..74ed24a5ec4 100644 --- a/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java +++ b/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java @@ -159,7 +159,7 @@ public class FuzzinessTests extends ElasticsearchTestCase { assertThat(Fuzziness.AUTO.asDouble(), equalTo(1d)); assertThat(Fuzziness.AUTO.asLong(), equalTo(1l)); assertThat(Fuzziness.AUTO.asShort(), equalTo((short) 1)); - assertThat(Fuzziness.AUTO.asTimeValue(), equalTo(TimeValue.parseTimeValue("1", TimeValue.timeValueMillis(1), "fuzziness"))); + assertThat(Fuzziness.AUTO.asTimeValue(), equalTo(TimeValue.parseTimeValue("1ms", TimeValue.timeValueMillis(1), "fuzziness"))); } diff --git a/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java index 90fa0b747ed..ff10532d773 100644 --- a/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java +++ b/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java @@ -31,12 +31,8 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; -/** - * - */ public class TimeValueTests extends ElasticsearchTestCase { - @Test public void testSimple() { assertThat(TimeUnit.MILLISECONDS.toMillis(10), equalTo(new TimeValue(10, TimeUnit.MILLISECONDS).millis())); assertThat(TimeUnit.MICROSECONDS.toMicros(10), equalTo(new TimeValue(10, TimeUnit.MICROSECONDS).micros())); @@ -46,7 +42,6 @@ public class TimeValueTests extends ElasticsearchTestCase { assertThat(TimeUnit.DAYS.toDays(10), equalTo(new TimeValue(10, TimeUnit.DAYS).days())); } - @Test public void testToString() { assertThat("10ms", equalTo(new TimeValue(10, TimeUnit.MILLISECONDS).toString())); assertThat("1.5s", equalTo(new TimeValue(1533, TimeUnit.MILLISECONDS).toString())); @@ -56,7 +51,6 @@ public class TimeValueTests extends ElasticsearchTestCase { assertThat("1000d", equalTo(new TimeValue(1000, TimeUnit.DAYS).toString())); } - @Test public void testFormat() { assertThat(new TimeValue(1025, TimeUnit.MILLISECONDS).format(PeriodType.dayTime()), equalTo("1 second and 25 milliseconds")); assertThat(new TimeValue(1, TimeUnit.MINUTES).format(PeriodType.dayTime()), equalTo("1 minute")); @@ -64,11 +58,18 @@ public class TimeValueTests extends ElasticsearchTestCase { assertThat(new TimeValue(24 * 600 + 85, TimeUnit.MINUTES).format(PeriodType.dayTime()), equalTo("241 hours and 25 minutes")); } - @Test public void testMinusOne() { assertThat(new TimeValue(-1).nanos(), lessThan(0l)); } + public void testParseTimeValue() { + // Space is allowed before unit + assertEquals(new TimeValue(10, TimeUnit.SECONDS), + TimeValue.parseTimeValue("10 s", null, "ten seconds")); + assertEquals(new TimeValue(10, TimeUnit.SECONDS), + TimeValue.parseTimeValue("10s", null, "ten seconds")); + } + private void assertEqualityAfterSerialize(TimeValue value) throws IOException { BytesStreamOutput out = new BytesStreamOutput(); value.writeTo(out); @@ -79,7 +80,6 @@ public class TimeValueTests extends ElasticsearchTestCase { assertThat(inValue, equalTo(value)); } - @Test public void testSerialize() throws Exception { assertEqualityAfterSerialize(new TimeValue(100, TimeUnit.DAYS)); assertEqualityAfterSerialize(new TimeValue(-1)); diff --git a/src/test/java/org/elasticsearch/index/engine/InternalEngineSettingsTest.java b/src/test/java/org/elasticsearch/index/engine/InternalEngineSettingsTest.java index 1dd88a83a1e..69d72c8a06f 100644 --- a/src/test/java/org/elasticsearch/index/engine/InternalEngineSettingsTest.java +++ b/src/test/java/org/elasticsearch/index/engine/InternalEngineSettingsTest.java @@ -24,6 +24,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; +import java.util.concurrent.TimeUnit; + import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -48,7 +50,11 @@ public class InternalEngineSettingsTest extends ElasticsearchSingleNodeTest { final int iters = between(1, 20); for (int i = 0; i < iters; i++) { boolean compoundOnFlush = randomBoolean(); - long gcDeletes = Math.max(0, randomLong()); + + // Tricky: TimeValue.parseTimeValue casts this long to a double, which steals 11 of the 64 bits for exponent, so we can't use + // the full long range here else the assert below fails: + long gcDeletes = random().nextLong() & (Long.MAX_VALUE >> 11); + boolean versionMapAsPercent = randomBoolean(); double versionMapPercent = randomIntBetween(0, 100); long versionMapSizeInMB = randomIntBetween(10, 20); @@ -56,9 +62,10 @@ public class InternalEngineSettingsTest extends ElasticsearchSingleNodeTest { Settings build = ImmutableSettings.builder() .put(EngineConfig.INDEX_COMPOUND_ON_FLUSH, compoundOnFlush) - .put(EngineConfig.INDEX_GC_DELETES_SETTING, gcDeletes) + .put(EngineConfig.INDEX_GC_DELETES_SETTING, gcDeletes, TimeUnit.MILLISECONDS) .put(EngineConfig.INDEX_VERSION_MAP_SIZE, versionMapString) .build(); + assertEquals(gcDeletes, build.getAsTime(EngineConfig.INDEX_GC_DELETES_SETTING, null).millis()); client().admin().indices().prepareUpdateSettings("foo").setSettings(build).get(); LiveIndexWriterConfig currentIndexWriterConfig = engine.getCurrentIndexWriterConfig(); @@ -79,7 +86,7 @@ public class InternalEngineSettingsTest extends ElasticsearchSingleNodeTest { } Settings settings = ImmutableSettings.builder() - .put(EngineConfig.INDEX_GC_DELETES_SETTING, 1000) + .put(EngineConfig.INDEX_GC_DELETES_SETTING, 1000, TimeUnit.MILLISECONDS) .build(); client().admin().indices().prepareUpdateSettings("foo").setSettings(settings).get(); assertEquals(engine.getGcDeletesInMillis(), 1000); @@ -95,7 +102,7 @@ public class InternalEngineSettingsTest extends ElasticsearchSingleNodeTest { assertTrue(engine.config().isEnableGcDeletes()); settings = ImmutableSettings.builder() - .put(EngineConfig.INDEX_GC_DELETES_SETTING, 1000) + .put(EngineConfig.INDEX_GC_DELETES_SETTING, 1000, TimeUnit.MILLISECONDS) .build(); client().admin().indices().prepareUpdateSettings("foo").setSettings(settings).get(); assertEquals(engine.getGcDeletesInMillis(), 1000); diff --git a/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java b/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java index af800643e8f..d7b9fa1f23e 100644 --- a/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java +++ b/src/test/java/org/elasticsearch/percolator/TTLPercolatorTests.java @@ -59,7 +59,7 @@ public class TTLPercolatorTests extends ElasticsearchIntegrationTest { protected Settings nodeSettings(int nodeOrdinal) { return settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) - .put("indices.ttl.interval", PURGE_INTERVAL) + .put("indices.ttl.interval", PURGE_INTERVAL, TimeUnit.MILLISECONDS) .build(); } @@ -163,7 +163,7 @@ public class TTLPercolatorTests extends ElasticsearchIntegrationTest { public void testEnsureTTLDoesNotCreateIndex() throws IOException, InterruptedException { ensureGreen(); client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder() - .put("indices.ttl.interval", 60) // 60 sec + .put("indices.ttl.interval", 60, TimeUnit.SECONDS) // 60 sec .build()).get(); String typeMapping = XContentFactory.jsonBuilder().startObject().startObject("type1") @@ -176,7 +176,7 @@ public class TTLPercolatorTests extends ElasticsearchIntegrationTest { .execute().actionGet(); ensureGreen(); client().admin().cluster().prepareUpdateSettings().setTransientSettings(settingsBuilder() - .put("indices.ttl.interval", 1) // 60 sec + .put("indices.ttl.interval", 1, TimeUnit.SECONDS) .build()).get(); for (int i = 0; i < 100; i++) { diff --git a/src/test/java/org/elasticsearch/recovery/RecoverySettingsTest.java b/src/test/java/org/elasticsearch/recovery/RecoverySettingsTest.java index 1afeea039d6..50887bea2c1 100644 --- a/src/test/java/org/elasticsearch/recovery/RecoverySettingsTest.java +++ b/src/test/java/org/elasticsearch/recovery/RecoverySettingsTest.java @@ -23,6 +23,8 @@ import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; +import java.util.concurrent.TimeUnit; + public class RecoverySettingsTest extends ElasticsearchSingleNodeTest { @Override @@ -68,31 +70,31 @@ public class RecoverySettingsTest extends ElasticsearchSingleNodeTest { assertEquals(null, recoverySettings.rateLimiter()); } }); - innerTestSettings(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC, randomIntBetween(1, 200), new Validator() { + innerTestSettings(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC, randomIntBetween(1, 200), TimeUnit.MILLISECONDS, new Validator() { @Override public void validate(RecoverySettings recoverySettings, int expectedValue) { assertEquals(expectedValue, recoverySettings.retryDelayStateSync().millis()); } }); - innerTestSettings(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK, randomIntBetween(1, 200), new Validator() { + innerTestSettings(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK, randomIntBetween(1, 200), TimeUnit.MILLISECONDS, new Validator() { @Override public void validate(RecoverySettings recoverySettings, int expectedValue) { assertEquals(expectedValue, recoverySettings.retryDelayNetwork().millis()); } }); - innerTestSettings(RecoverySettings.INDICES_RECOVERY_ACTIVITY_TIMEOUT, randomIntBetween(1, 200), new Validator() { + innerTestSettings(RecoverySettings.INDICES_RECOVERY_ACTIVITY_TIMEOUT, randomIntBetween(1, 200), TimeUnit.MILLISECONDS, new Validator() { @Override public void validate(RecoverySettings recoverySettings, int expectedValue) { assertEquals(expectedValue, recoverySettings.activityTimeout().millis()); } }); - innerTestSettings(RecoverySettings.INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT, randomIntBetween(1, 200), new Validator() { + innerTestSettings(RecoverySettings.INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT, randomIntBetween(1, 200), TimeUnit.MILLISECONDS, new Validator() { @Override public void validate(RecoverySettings recoverySettings, int expectedValue) { assertEquals(expectedValue, recoverySettings.internalActionTimeout().millis()); } }); - innerTestSettings(RecoverySettings.INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT, randomIntBetween(1, 200), new Validator() { + innerTestSettings(RecoverySettings.INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT, randomIntBetween(1, 200), TimeUnit.MILLISECONDS, new Validator() { @Override public void validate(RecoverySettings recoverySettings, int expectedValue) { assertEquals(expectedValue, recoverySettings.internalActionLongTimeout().millis()); @@ -120,6 +122,11 @@ public class RecoverySettingsTest extends ElasticsearchSingleNodeTest { validator.validate(getInstanceFromNode(RecoverySettings.class), newValue); } + private void innerTestSettings(String key, int newValue, TimeUnit timeUnit, Validator validator) { + client().admin().cluster().prepareUpdateSettings().setTransientSettings(ImmutableSettings.builder().put(key, newValue, timeUnit)).get(); + validator.validate(getInstanceFromNode(RecoverySettings.class), newValue); + } + private void innerTestSettings(String key, boolean newValue, Validator validator) { client().admin().cluster().prepareUpdateSettings().setTransientSettings(ImmutableSettings.builder().put(key, newValue)).get(); validator.validate(getInstanceFromNode(RecoverySettings.class), newValue); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java index d3114d20283..2867da1ab8b 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java @@ -1307,14 +1307,14 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest { /** * see issue #9634, negative interval in date_histogram should raise exception */ - public void testExeptionOnNegativerInterval() { + public void testExeptionOnNegativeInterval() { try { client().prepareSearch("idx") .addAggregation(dateHistogram("histo").field("date").interval(-TimeUnit.DAYS.toMillis(1)).minDocCount(0)).execute() .actionGet(); fail(); } catch (SearchPhaseExecutionException e) { - assertThat(e.toString(), containsString("IllegalArgumentException")); + assertThat(e.toString(), containsString("ElasticsearchParseException")); } } } diff --git a/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java index 78a763ac13e..a95364393aa 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java @@ -211,8 +211,8 @@ public class DerivativeTests extends ElasticsearchIntegrationTest { .prepareSearch("idx") .addAggregation( histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).minDocCount(0) - .subAggregation(derivative("deriv").setBucketsPaths("_count").unit("1")) - .subAggregation(derivative("2nd_deriv").setBucketsPaths("deriv").unit("10"))).execute().actionGet(); + .subAggregation(derivative("deriv").setBucketsPaths("_count").unit("1ms")) + .subAggregation(derivative("2nd_deriv").setBucketsPaths("deriv").unit("10ms"))).execute().actionGet(); assertSearchResponse(response); diff --git a/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java b/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java index 7137ed5620c..b3f8a448b42 100644 --- a/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java +++ b/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java @@ -286,7 +286,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests { logger.info("--> create index with foo type"); assertAcked(prepareCreate("test-idx", 2, ImmutableSettings.builder() - .put(indexSettings()).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)).put("refresh_interval", 10))); + .put(indexSettings()).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)).put("refresh_interval", 10, TimeUnit.SECONDS))); NumShards numShards = getNumShards("test-idx"); @@ -301,7 +301,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests { logger.info("--> delete the index and recreate it with bar type"); cluster().wipeIndices("test-idx"); assertAcked(prepareCreate("test-idx", 2, ImmutableSettings.builder() - .put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)).put("refresh_interval", 5))); + .put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)).put("refresh_interval", 5, TimeUnit.SECONDS))); assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("bar").setSource("baz", "type=string")); ensureGreen(); @@ -319,7 +319,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests { logger.info("--> assert that old settings are restored"); GetSettingsResponse getSettingsResponse = client.admin().indices().prepareGetSettings("test-idx").execute().actionGet(); - assertThat(getSettingsResponse.getSetting("test-idx", "index.refresh_interval"), equalTo("10")); + assertThat(getSettingsResponse.getSetting("test-idx", "index.refresh_interval"), equalTo("10000ms")); } @Test diff --git a/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/src/test/java/org/elasticsearch/test/InternalTestCluster.java index 0ca7ae60ff6..3ca711db0c2 100644 --- a/src/test/java/org/elasticsearch/test/InternalTestCluster.java +++ b/src/test/java/org/elasticsearch/test/InternalTestCluster.java @@ -451,7 +451,7 @@ public final class InternalTestCluster extends TestCluster { if (rarely(random)) { builder.put(TranslogConfig.INDEX_TRANSLOG_SYNC_INTERVAL, 0); // 0 has special meaning to sync each op } else { - builder.put(TranslogConfig.INDEX_TRANSLOG_SYNC_INTERVAL, RandomInts.randomIntBetween(random, 100, 5000)); + builder.put(TranslogConfig.INDEX_TRANSLOG_SYNC_INTERVAL, RandomInts.randomIntBetween(random, 100, 5000), TimeUnit.MILLISECONDS); } } diff --git a/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java b/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java index 70435ea6750..1b8bc23ca9b 100644 --- a/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java +++ b/src/test/java/org/elasticsearch/ttl/SimpleTTLTests.java @@ -58,7 +58,7 @@ public class SimpleTTLTests extends ElasticsearchIntegrationTest { protected Settings nodeSettings(int nodeOrdinal) { return settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) - .put("indices.ttl.interval", PURGE_INTERVAL) + .put("indices.ttl.interval", PURGE_INTERVAL, TimeUnit.MILLISECONDS) .put("cluster.routing.operation.use_type", false) // make sure we control the shard computation .put("cluster.routing.operation.hash.type", "djb") .build();