Skip to content

Commit

Permalink
Test that transient settings beat persistent ones (elastic#33818)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DaveCTurner authored Sep 20, 2018
1 parent 6d3a791 commit c041e94
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -794,4 +795,12 @@ public static void assertMultiField(Map<String, Object> properties, String field
" }\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"));
}
}

0 comments on commit c041e94

Please sign in to comment.