Fix UpdateSettingsIT and IndicesOptionsIntegrationIT to register strict settings
This commit is contained in:
parent
359475fb0d
commit
dbe76fb59b
|
@ -227,7 +227,7 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
|
||||
private class Updater implements AbstractScopedSettings.SettingUpdater<T> {
|
||||
private final class Updater implements AbstractScopedSettings.SettingUpdater<T> {
|
||||
private final Consumer<T> consumer;
|
||||
private final ESLogger logger;
|
||||
private final Consumer<T> accept;
|
||||
|
@ -267,8 +267,8 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void apply(T value, Settings current, Settings previous) {
|
||||
logger.info("update [{}] from [{}] to [{}]", key, getRaw(previous), getRaw(current));
|
||||
public final void apply(T value, Settings current, Settings previous) {
|
||||
logger.info("updating [{}] from [{}] to [{}]", key, getRaw(previous), getRaw(current));
|
||||
consumer.accept(value);
|
||||
}
|
||||
}
|
||||
|
@ -443,6 +443,7 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
|
||||
@Override
|
||||
public void apply(Settings value, Settings current, Settings previous) {
|
||||
logger.info("updating [{}] from [{}] to [{}]", key, getRaw(previous), getRaw(current));
|
||||
consumer.accept(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,17 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.action.suggest.SuggestRequestBuilder;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.search.suggest.SuggestBuilders;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
|
@ -60,6 +66,12 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
return pluginList(TestPlugin.class); //
|
||||
}
|
||||
|
||||
public void testSpecifiedIndexUnavailableMultipleIndices() throws Exception {
|
||||
createIndex("test1");
|
||||
ensureYellow();
|
||||
|
@ -619,6 +631,29 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
|
|||
assertThat(client().admin().indices().prepareGetMappings("barbaz").get().mappings().get("barbaz").get("type4"), notNullValue());
|
||||
}
|
||||
|
||||
public static final class TestPlugin extends Plugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "index-a-setting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "a plugin that adds a dynamic tst setting";
|
||||
}
|
||||
|
||||
private static final Setting<String> INDEX_A = new Setting<>("index.a", "", Function.identity(), true, Setting.Scope.INDEX);
|
||||
private static final Setting<String> INDEX_C = new Setting<>("index.c", "", Function.identity(), true, Setting.Scope.INDEX);
|
||||
private static final Setting<String> INDEX_E = new Setting<>("index.e", "", Function.identity(), false, Setting.Scope.INDEX);
|
||||
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSetting(INDEX_A);
|
||||
module.registerSetting(INDEX_C);
|
||||
module.registerSetting(INDEX_E);
|
||||
}
|
||||
}
|
||||
|
||||
public void testUpdateSettings() throws Exception {
|
||||
verify(client().admin().indices().prepareUpdateSettings("foo").setSettings(Settings.builder().put("a", "b")), true);
|
||||
verify(client().admin().indices().prepareUpdateSettings("_all").setSettings(Settings.builder().put("a", "b")), true);
|
||||
|
|
|
@ -279,10 +279,10 @@ public class UpdateSettingsIT extends ESIntegTestCase {
|
|||
if (event.getLevel() == Level.TRACE &&
|
||||
event.getLoggerName().endsWith("lucene.iw")) {
|
||||
}
|
||||
if (event.getLevel() == Level.INFO && message.contains("update [index.merge.scheduler.max_thread_count] from [10000] to [1]")) {
|
||||
if (event.getLevel() == Level.INFO && message.contains("updating [index.merge.scheduler.max_thread_count] from [10000] to [1]")) {
|
||||
sawUpdateMaxThreadCount = true;
|
||||
}
|
||||
if (event.getLevel() == Level.INFO && message.contains("update [index.merge.scheduler.auto_throttle] from [true] to [false]")) {
|
||||
if (event.getLevel() == Level.INFO && message.contains("updating [index.merge.scheduler.auto_throttle] from [true] to [false]")) {
|
||||
sawUpdateAutoThrottle = true;
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
|
|||
.indices()
|
||||
.prepareUpdateSettings("test")
|
||||
.setSettings(Settings.builder()
|
||||
.put(MergeSchedulerConfig.AUTO_THROTTLE_SETTING.getKey(), "no"))
|
||||
.put(MergeSchedulerConfig.AUTO_THROTTLE_SETTING.getKey(), "false"))
|
||||
.get();
|
||||
|
||||
// Make sure we log the change:
|
||||
|
@ -331,7 +331,7 @@ public class UpdateSettingsIT extends ESIntegTestCase {
|
|||
|
||||
// Make sure setting says it is in fact changed:
|
||||
GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings("test").get();
|
||||
assertThat(getSettingsResponse.getSetting("test", MergeSchedulerConfig.AUTO_THROTTLE_SETTING.getKey()), equalTo("no"));
|
||||
assertThat(getSettingsResponse.getSetting("test", MergeSchedulerConfig.AUTO_THROTTLE_SETTING.getKey()), equalTo("false"));
|
||||
} finally {
|
||||
rootLogger.removeAppender(mockAppender);
|
||||
rootLogger.setLevel(savedLevel);
|
||||
|
|
Loading…
Reference in New Issue