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.
This commit is contained in:
David Turner 2018-09-20 11:17:19 +01:00 committed by GitHub
parent 6d3a7910f8
commit c041e94349
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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"));
}
}