}
@Test
public void testUpdateDiscoveryPublishTimeout() {
DiscoverySettings discoverySettings = internalCluster().getInstance(DiscoverySettings.class);
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.DEFAULT_PUBLISH_TIMEOUT));
ClusterUpdateSettingsResponse response = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(ImmutableSettings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT, "1s").build())
.get();
assertAcked(response);
assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT), equalTo("1s"));
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l));
response = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(ImmutableSettings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT, "whatever").build())
.get();
assertAcked(response);
assertThat(response.getTransientSettings().getAsMap().entrySet(), Matchers.emptyIterable());
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l));
response = client().admin().cluster()
.prepareUpdateSettings()
.setTransientSettings(ImmutableSettings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT, -1).build())
.get();
assertAcked(response);
assertThat(response.getTransientSettings().getAsMap().entrySet(), Matchers.emptyIterable());
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l));
}