From 2c7fe6ac258bd5cdcf5332cd2869b4464c0ca2bc Mon Sep 17 00:00:00 2001 From: liketic Date: Sun, 4 Mar 2018 16:38:11 +0800 Subject: [PATCH 1/5] Reject setting index.optimize_auto_generated_id after version 7.0.0 (#27583) --- .../index/engine/EngineConfig.java | 6 ++ .../index/engine/EngineConfigTests.java | 69 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java diff --git a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java index 30743c18cfe10..5bec1c113ebb5 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java @@ -26,6 +26,7 @@ import org.apache.lucene.search.ReferenceManager; import org.apache.lucene.search.Sort; import org.apache.lucene.search.similarities.Similarity; +import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -131,6 +132,11 @@ public EngineConfig(OpenMode openMode, ShardId shardId, String allocationId, Thr if (openMode == null) { throw new IllegalArgumentException("openMode must not be null"); } + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1) + && INDEX_OPTIMIZE_AUTO_GENERATED_IDS.exists(indexSettings.getSettings())) { + throw new IllegalArgumentException( + "Setting [" + INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0"); + } this.shardId = shardId; this.allocationId = allocationId; this.indexSettings = indexSettings; diff --git a/server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java b/server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java new file mode 100644 index 0000000000000..caea9ae7e2688 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java @@ -0,0 +1,69 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.index.engine; + +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.IndexSettingsModule; + + +public class EngineConfigTests extends ESTestCase { + + + private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) { + return new EngineConfig(EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG, null, null, null, + indexSettings, null, null, null, null, + null, null, null, null, null, + true, null, null, null, null, null, + null, null, null); + } + + public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { + Version version = Version.V_7_0_0_alpha1; + boolean optimizeAutoGeneratedIds = randomBoolean(); + Settings.Builder builder = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, version) + .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); + IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index1", builder.build()); + + IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, + () -> createEngineConfigWithSettings(indexSettings)); + assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", + exception.getMessage()); + + version = randomFrom(Version.V_5_0_0, Version.V_5_0_0_alpha1, Version.V_5_6_9, Version.V_6_0_0_rc1, + Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0); + optimizeAutoGeneratedIds = randomBoolean(); + builder = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, version) + .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); + IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings("index2", builder.build()); + EngineConfig config = createEngineConfigWithSettings(indexSettings2); + assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled()); + + version = Version.V_7_0_0_alpha1; + builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version); + indexSettings2 = IndexSettingsModule.newIndexSettings("index3", builder.build()); + config = createEngineConfigWithSettings(indexSettings2); + assertTrue(config.isAutoGeneratedIDsOptimizationEnabled()); + } +} From 7276da9f3d3cabd17ce956803da830ecd6ceefb5 Mon Sep 17 00:00:00 2001 From: liketic Date: Mon, 12 Mar 2018 18:16:11 +0800 Subject: [PATCH 2/5] Move test to existing class --- .../index/engine/EngineConfigTests.java | 69 ------------------- .../index/engine/InternalEngineTests.java | 39 +++++++++++ 2 files changed, 39 insertions(+), 69 deletions(-) delete mode 100644 server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java diff --git a/server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java b/server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java deleted file mode 100644 index caea9ae7e2688..0000000000000 --- a/server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.index.engine; - -import org.elasticsearch.Version; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.IndexSettingsModule; - - -public class EngineConfigTests extends ESTestCase { - - - private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) { - return new EngineConfig(EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG, null, null, null, - indexSettings, null, null, null, null, - null, null, null, null, null, - true, null, null, null, null, null, - null, null, null); - } - - public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { - Version version = Version.V_7_0_0_alpha1; - boolean optimizeAutoGeneratedIds = randomBoolean(); - Settings.Builder builder = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, version) - .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); - IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index1", builder.build()); - - IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, - () -> createEngineConfigWithSettings(indexSettings)); - assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", - exception.getMessage()); - - version = randomFrom(Version.V_5_0_0, Version.V_5_0_0_alpha1, Version.V_5_6_9, Version.V_6_0_0_rc1, - Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0); - optimizeAutoGeneratedIds = randomBoolean(); - builder = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, version) - .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); - IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings("index2", builder.build()); - EngineConfig config = createEngineConfigWithSettings(indexSettings2); - assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled()); - - version = Version.V_7_0_0_alpha1; - builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version); - indexSettings2 = IndexSettingsModule.newIndexSettings("index3", builder.build()); - config = createEngineConfigWithSettings(indexSettings2); - assertTrue(config.isAutoGeneratedIDsOptimizationEnabled()); - } -} diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 7d74946b60421..345b5a28a32dd 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -4572,4 +4572,43 @@ public void testStressUpdateSameDocWhileGettingIt() throws IOException, Interrup } } } + + private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) { + EngineConfig.OpenMode openMode = randomFrom(EngineConfig.OpenMode.values()); + return new EngineConfig(openMode, shardId, null, threadPool, + indexSettings, null, store, null, null, + null, null, null, null, null, + true, null, null, null, null, + null, null, null, null); + } + + public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { + Version version = Version.V_7_0_0_alpha1; + boolean optimizeAutoGeneratedIds = randomBoolean(); + Settings.Builder builder = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, version) + .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); + IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index1", builder.build()); + + IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, + () -> createEngineConfigWithSettings(indexSettings)); + assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", + exception.getMessage()); + + version = randomFrom(Version.V_5_0_0, Version.V_5_0_0_alpha1, Version.V_5_6_9, Version.V_6_0_0_rc1, + Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0); + optimizeAutoGeneratedIds = randomBoolean(); + builder = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, version) + .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); + IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings("index2", builder.build()); + EngineConfig config = createEngineConfigWithSettings(indexSettings2); + assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled()); + + version = Version.V_7_0_0_alpha1; + builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version); + indexSettings2 = IndexSettingsModule.newIndexSettings("index3", builder.build()); + config = createEngineConfigWithSettings(indexSettings2); + assertTrue(config.isAutoGeneratedIDsOptimizationEnabled()); + } } From a21095e430b44aef393c1c5b754ddcf50788600d Mon Sep 17 00:00:00 2001 From: liketic Date: Thu, 13 Dec 2018 23:34:16 +0800 Subject: [PATCH 3/5] Fix tests --- .../elasticsearch/index/engine/InternalEngineTests.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 652b840f741b3..1413f086b29a6 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -4984,7 +4984,7 @@ private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) } public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { - Version version = Version.V_7_0_0_alpha1; + Version version = Version.V_7_0_0; boolean optimizeAutoGeneratedIds = randomBoolean(); Settings.Builder builder = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, version) @@ -4996,8 +4996,7 @@ public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", exception.getMessage()); - version = randomFrom(Version.V_5_0_0, Version.V_5_0_0_alpha1, Version.V_5_6_9, Version.V_6_0_0_rc1, - Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0); + version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0); optimizeAutoGeneratedIds = randomBoolean(); builder = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, version) @@ -5006,7 +5005,7 @@ public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { EngineConfig config = createEngineConfigWithSettings(indexSettings2); assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled()); - version = Version.V_7_0_0_alpha1; + version = Version.V_7_0_0; builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version); indexSettings2 = IndexSettingsModule.newIndexSettings("index3", builder.build()); config = createEngineConfigWithSettings(indexSettings2); From c225cc85cea65f41fa064850808765f19fc35be0 Mon Sep 17 00:00:00 2001 From: liketic Date: Sun, 23 Dec 2018 22:26:49 +0800 Subject: [PATCH 4/5] Reject index setting when creating index --- .../index/engine/EngineConfig.java | 6 --- .../elasticsearch/indices/IndicesService.java | 7 +++ .../index/engine/InternalEngineTests.java | 29 ------------- .../indices/IndicesServiceTests.java | 43 +++++++++++++++++++ 4 files changed, 50 insertions(+), 35 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java index ef6b1cd74bd6e..f95ba96d343c9 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java @@ -26,7 +26,6 @@ import org.apache.lucene.search.ReferenceManager; import org.apache.lucene.search.Sort; import org.apache.lucene.search.similarities.Similarity; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -127,11 +126,6 @@ public EngineConfig(ShardId shardId, String allocationId, ThreadPool threadPool, List internalRefreshListener, Sort indexSort, CircuitBreakerService circuitBreakerService, LongSupplier globalCheckpointSupplier, LongSupplier primaryTermSupplier, TombstoneDocSupplier tombstoneDocSupplier) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0) - && INDEX_OPTIMIZE_AUTO_GENERATED_IDS.exists(indexSettings.getSettings())) { - throw new IllegalArgumentException( - "Setting [" + INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0"); - } this.shardId = shardId; this.allocationId = allocationId; this.indexSettings = indexSettings; diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesService.java b/server/src/main/java/org/elasticsearch/indices/IndicesService.java index 19388a2b63d4d..07038a03b2cda 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -29,6 +29,7 @@ import org.apache.lucene.util.RamUsageEstimator; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ResourceAlreadyExistsException; +import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; @@ -82,6 +83,7 @@ import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.cache.request.ShardRequestCache; import org.elasticsearch.index.engine.CommitStats; +import org.elasticsearch.index.engine.EngineConfig; import org.elasticsearch.index.engine.EngineFactory; import org.elasticsearch.index.engine.InternalEngineFactory; import org.elasticsearch.index.fielddata.IndexFieldDataCache; @@ -499,6 +501,11 @@ private synchronized IndexService createIndexService(final String reason, List builtInListeners, IndexingOperationListener... indexingOperationListeners) throws IOException { final IndexSettings idxSettings = new IndexSettings(indexMetaData, settings, indexScopedSettings); + if (idxSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0) + && EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.exists(idxSettings.getSettings())) { + throw new IllegalArgumentException( + "Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0"); + } // we ignore private settings since they are not registered settings indexScopedSettings.validate(indexMetaData.getSettings(), true, true, true); logger.debug("creating Index [{}], shards [{}]/[{}] - reason [{}]", diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 1413f086b29a6..244033623aaba 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -4983,35 +4983,6 @@ private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) null, null, null, null); } - public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { - Version version = Version.V_7_0_0; - boolean optimizeAutoGeneratedIds = randomBoolean(); - Settings.Builder builder = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, version) - .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); - IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index1", builder.build()); - - IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, - () -> createEngineConfigWithSettings(indexSettings)); - assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", - exception.getMessage()); - - version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0); - optimizeAutoGeneratedIds = randomBoolean(); - builder = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, version) - .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds); - IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings("index2", builder.build()); - EngineConfig config = createEngineConfigWithSettings(indexSettings2); - assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled()); - - version = Version.V_7_0_0; - builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version); - indexSettings2 = IndexSettingsModule.newIndexSettings("index3", builder.build()); - config = createEngineConfigWithSettings(indexSettings2); - assertTrue(config.isAutoGeneratedIDsOptimizationEnabled()); - } - public void testPruneOnlyDeletesAtMostLocalCheckpoint() throws Exception { final AtomicLong clock = new AtomicLong(0); threadPool = spy(threadPool); diff --git a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java index b68ec6d0598e5..1ad5b2f9087ff 100644 --- a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java @@ -640,5 +640,48 @@ public static ClusterState createClusterForShardLimitTest(int nodesInCluster, in .build(); } + public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { + final IndicesService indicesService = getIndicesService(); + + final Index index = new Index("foo-index", UUIDs.randomBase64UUID()); + Settings.Builder builder = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_7_0_0) + .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()); + IndexMetaData indexMetaData = new IndexMetaData.Builder(index.getName()) + .settings(builder.build()) + .numberOfShards(1) + .numberOfReplicas(0) + .build(); + IndexService indexService = indicesService.createIndex(indexMetaData, Collections.emptyList()); + assertNotNull(indexService); + + final Index index2 = new Index("bar-index", UUIDs.randomBase64UUID()); + Settings.Builder builder2 = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_7_0_0) + .put(IndexMetaData.SETTING_INDEX_UUID, index2.getUUID()) + .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), randomBoolean()); + IndexMetaData indexMetaData2 = new IndexMetaData.Builder(index2.getName()) + .settings(builder2.build()) + .numberOfShards(1) + .numberOfReplicas(0) + .build(); + IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, + () -> indicesService.createIndex(indexMetaData2, Collections.emptyList())); + assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", + ex.getMessage()); + + Version version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0, Version.V_6_4_0); + builder = Settings.builder() + .put(IndexMetaData.SETTING_VERSION_CREATED, version) + .put(IndexMetaData.SETTING_INDEX_UUID, index2.getUUID()) + .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), randomBoolean()); + IndexMetaData indexMetaData3 = new IndexMetaData.Builder(index2.getName()) + .settings(builder.build()) + .numberOfShards(1) + .numberOfReplicas(0) + .build(); + IndexService indexService2 = indicesService.createIndex(indexMetaData3, Collections.emptyList()); + assertNotNull(indexService2); + } } From 2aec530715e6a049cf9088d95b7a55e08c513a87 Mon Sep 17 00:00:00 2001 From: liketic Date: Sun, 23 Dec 2018 22:39:01 +0800 Subject: [PATCH 5/5] Remove test --- .../elasticsearch/index/engine/InternalEngineTests.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 244033623aaba..c0156d54cc88c 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -4975,14 +4975,6 @@ public void testStressUpdateSameDocWhileGettingIt() throws IOException, Interrup } } - private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) { - return new EngineConfig(shardId, null, threadPool, - indexSettings, null, store, null, null, - null, null, null, null, null, - null, null, null, null, null, - null, null, null, null); - } - public void testPruneOnlyDeletesAtMostLocalCheckpoint() throws Exception { final AtomicLong clock = new AtomicLong(0); threadPool = spy(threadPool);