public void testDeleteIsAppliedFirst() { DiscoverySettings discoverySettings = getDiscoverySettings(); assertEquals( discoverySettings.getPublishTimeout(), DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)); assertTrue(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)); ClusterUpdateSettingsResponse response = client() .admin() .cluster() .prepareUpdateSettings() .setTransientSettings( Settings.builder() .put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false) .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") .build()) .get(); assertAcked(response); assertEquals( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), "1s"); assertTrue(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)); assertFalse( response .getTransientSettings() .getAsBoolean(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), null)); response = client() .admin() .cluster() .prepareUpdateSettings() .setTransientSettings( Settings.builder() .putNull((randomBoolean() ? "discovery.zen.*" : "*")) .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "2s")) .get(); assertEquals( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), "2s"); assertNull( response .getTransientSettings() .getAsBoolean(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), null)); }
public void testResetClusterSetting() { DiscoverySettings discoverySettings = getDiscoverySettings(); assertThat( discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY))); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); ClusterUpdateSettingsResponse response = client() .admin() .cluster() .prepareUpdateSettings() .setTransientSettings( Settings.builder() .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") .build()) .get(); assertAcked(response); assertThat( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); response = client() .admin() .cluster() .prepareUpdateSettings() .setTransientSettings( Settings.builder().putNull(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())) .get(); assertAcked(response); assertNull( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())); assertThat( discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY))); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); response = client() .admin() .cluster() .prepareUpdateSettings() .setTransientSettings( Settings.builder() .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") .put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false) .build()) .get(); assertAcked(response); assertThat( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertFalse(discoverySettings.getPublishDiff()); response = client() .admin() .cluster() .prepareUpdateSettings() .setTransientSettings( Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*"))) .get(); assertNull( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())); assertNull( response .getTransientSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey())); assertThat( discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY))); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); // now persistent response = client() .admin() .cluster() .prepareUpdateSettings() .setPersistentSettings( Settings.builder() .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") .build()) .get(); assertAcked(response); assertThat( response .getPersistentSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); response = client() .admin() .cluster() .prepareUpdateSettings() .setPersistentSettings( Settings.builder().putNull((DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()))) .get(); assertAcked(response); assertNull( response .getPersistentSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())); assertThat( discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY))); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); response = client() .admin() .cluster() .prepareUpdateSettings() .setPersistentSettings( Settings.builder() .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") .put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false) .build()) .get(); assertAcked(response); assertThat( response .getPersistentSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertFalse(discoverySettings.getPublishDiff()); response = client() .admin() .cluster() .prepareUpdateSettings() .setPersistentSettings( Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*"))) .get(); assertNull( response .getPersistentSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())); assertNull( response .getPersistentSettings() .getAsMap() .get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey())); assertThat( discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY))); assertThat( discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); }