forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject setting index.optimize_auto_generated_id after version 7.0.0 (e…
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
server/src/test/java/org/elasticsearch/index/engine/EngineConfigTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |