Test that transient settings beat persistent ones
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.
@@ -28,6 +28,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;
@@ -733,4 +734,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"));
+ }
}
