|
@@ -649,7 +649,15 @@ public class UpdateSettingsIT extends ESIntegTestCase {
|
|
|
/*
|
|
|
* Test that we are able to set the setting index.number_of_replicas to the default.
|
|
|
*/
|
|
|
- public void testDefaultNumberOfReplicas() {
|
|
|
+ public void testDefaultNumberOfReplicasOnOpenIndices() {
|
|
|
+ runTestDefaultNumberOfReplicasTest(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testDefaultNumberOfReplicasOnClosedIndices() {
|
|
|
+ runTestDefaultNumberOfReplicasTest(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void runTestDefaultNumberOfReplicasTest(final boolean closeIndex) {
|
|
|
if (randomBoolean()) {
|
|
|
assertAcked(client().admin()
|
|
|
.indices()
|
|
@@ -659,6 +667,10 @@ public class UpdateSettingsIT extends ESIntegTestCase {
|
|
|
assertAcked(client().admin().indices().prepareCreate("test"));
|
|
|
}
|
|
|
|
|
|
+ if (closeIndex) {
|
|
|
+ assertAcked(client().admin().indices().prepareClose("test"));
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* Previous versions of Elasticsearch would throw an exception that the number of replicas had to have a value, and could not be
|
|
|
* null. In the update settings logic, we ensure this by providing an explicit default value if the setting is set to null.
|
|
@@ -668,6 +680,11 @@ public class UpdateSettingsIT extends ESIntegTestCase {
|
|
|
.prepareUpdateSettings("test")
|
|
|
.setSettings(Settings.builder().putNull(IndexMetadata.SETTING_NUMBER_OF_REPLICAS)));
|
|
|
|
|
|
+ final GetSettingsResponse response = client().admin().indices().prepareGetSettings("test").get();
|
|
|
+
|
|
|
+ // we removed the setting but it should still have an explicit value since index metadata requires this
|
|
|
+ assertTrue(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.exists(response.getIndexToSettings().get("test")));
|
|
|
+ assertThat(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.get(response.getIndexToSettings().get("test")), equalTo(1));
|
|
|
}
|
|
|
|
|
|
}
|