From c041e943494dbf42081f4c56e306263688bae569 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 20 Sep 2018 11:17:19 +0100 Subject: [PATCH] Test that transient settings beat persistent ones (#33818) Transient settings override persistent settings, but in fact all of the tests that run as part of `:server:test` and `:server:integTest` will pass if the precedence is changed to be the other way round. This change adds a test that verifies the precedence is as documented. --- .../elasticsearch/cluster/metadata/MetaDataTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java index da50e99705d..a929028a34e 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -794,4 +795,12 @@ public class MetaDataTests extends ESTestCase { " }\n" + " }\n" + "}"; + + public void testTransientSettingsOverridePersistentSettings() { + final Setting setting = Setting.simpleString("key"); + final MetaData metaData = MetaData.builder() + .persistentSettings(Settings.builder().put(setting.getKey(), "persistent-value").build()) + .transientSettings(Settings.builder().put(setting.getKey(), "transient-value").build()).build(); + assertThat(setting.get(metaData.settings()), equalTo("transient-value")); + } }