Improved ClusterSettingsTests
more assertAcked, checked that the `discovery.zen.publish_timeout` has been changed in `DiscoverySettings`, removed restriction on number of nodes, doesn't seem needed.
This commit is contained in:
parent
16e4ac8713
commit
129c0a3a3f
|
@ -32,7 +32,7 @@ public class DiscoverySettings extends AbstractComponent {
|
|||
|
||||
public static final String PUBLISH_TIMEOUT = "discovery.zen.publish_timeout";
|
||||
|
||||
private static final TimeValue DEFAULT_PUBLISH_TIMEOUT = TimeValue.timeValueSeconds(30);
|
||||
public static final TimeValue DEFAULT_PUBLISH_TIMEOUT = TimeValue.timeValueSeconds(30);
|
||||
|
||||
private volatile TimeValue publishTimeout = DEFAULT_PUBLISH_TIMEOUT;
|
||||
|
||||
|
|
|
@ -28,9 +28,12 @@ import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
|||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.test.ElasticsearchIntegrationTest.*;
|
||||
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope.TEST;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numNodes = 1)
|
||||
@ClusterScope(scope = TEST)
|
||||
public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
||||
|
||||
@Test
|
||||
|
@ -43,6 +46,7 @@ public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
|||
.setTransientSettings(ImmutableSettings.builder().put(key1, value1).build())
|
||||
.get();
|
||||
|
||||
assertAcked(response);
|
||||
assertThat(response.getTransientSettings().getAsMap().entrySet(), Matchers.emptyIterable());
|
||||
}
|
||||
|
||||
|
@ -64,6 +68,7 @@ public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
|||
.execute()
|
||||
.actionGet();
|
||||
|
||||
assertAcked(response1);
|
||||
assertThat(response1.getTransientSettings().get(key1), notNullValue());
|
||||
assertThat(response1.getTransientSettings().get(key2), nullValue());
|
||||
assertThat(response1.getPersistentSettings().get(key1), nullValue());
|
||||
|
@ -79,6 +84,7 @@ public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
|||
.execute()
|
||||
.actionGet();
|
||||
|
||||
assertAcked(response2);
|
||||
assertThat(response2.getTransientSettings().get(key1), notNullValue());
|
||||
assertThat(response2.getTransientSettings().get(key2), notNullValue());
|
||||
assertThat(response2.getPersistentSettings().get(key1), nullValue());
|
||||
|
@ -94,6 +100,7 @@ public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
|||
.execute()
|
||||
.actionGet();
|
||||
|
||||
assertAcked(response3);
|
||||
assertThat(response3.getTransientSettings().get(key1), nullValue());
|
||||
assertThat(response3.getTransientSettings().get(key2), nullValue());
|
||||
assertThat(response3.getPersistentSettings().get(key1), notNullValue());
|
||||
|
@ -102,25 +109,36 @@ public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void testUpdateDiscoveryPublishTimeout() {
|
||||
|
||||
DiscoverySettings discoverySettings = cluster().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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue