test: increased logging and ensure update requests are acked

Original commit: elastic/x-pack-elasticsearch@b4cab02148
This commit is contained in:
Martijn van Groningen 2015-06-16 18:01:39 +02:00
parent e29df8dd60
commit f72f4807aa
1 changed files with 15 additions and 9 deletions

View File

@ -8,17 +8,19 @@ package org.elasticsearch.watcher.history;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.watcher.history.HistoryStore; import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests; import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
import org.junit.Test; import org.junit.Test;
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope.TEST; import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope.TEST;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
/** /**
*/ */
@TestLogging("cluster:DEBUG,action.admin.cluster.settings:DEBUG")
@ElasticsearchIntegrationTest.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1) @ElasticsearchIntegrationTest.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTests { public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTests {
@ -29,12 +31,14 @@ public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTests {
assertThat(response.getIndexTemplates().get(0).getSettings().get("index.number_of_replicas"), nullValue()); // this isn't defined in the template, so we rely on ES's default, which is zero assertThat(response.getIndexTemplates().get(0).getSettings().get("index.number_of_replicas"), nullValue()); // this isn't defined in the template, so we rely on ES's default, which is zero
assertThat(response.getIndexTemplates().get(0).getSettings().get("index.refresh_interval"), nullValue()); // this isn't defined in the template, so we rely on ES's default, which is 1s assertThat(response.getIndexTemplates().get(0).getSettings().get("index.refresh_interval"), nullValue()); // this isn't defined in the template, so we rely on ES's default, which is 1s
client().admin().cluster().prepareUpdateSettings() assertAcked(
.setTransientSettings(ImmutableSettings.builder() client().admin().cluster().prepareUpdateSettings()
.put("watcher.history.index.number_of_shards", "2") .setTransientSettings(ImmutableSettings.builder()
.put("watcher.history.index.number_of_replicas", "2") .put("watcher.history.index.number_of_shards", "2")
.put("watcher.history.index.refresh_interval", "5m")) .put("watcher.history.index.number_of_replicas", "2")
.get(); .put("watcher.history.index.refresh_interval", "5m"))
.get()
);
// use assertBusy(...) because we update the index template in an async manner // use assertBusy(...) because we update the index template in an async manner
assertBusy(new Runnable() { assertBusy(new Runnable() {
@ -54,11 +58,13 @@ public class HistoryStoreSettingsTests extends AbstractWatcherIntegrationTests {
assertThat(response.getIndexTemplates().get(0).getSettings().get("index.number_of_shards"), equalTo("1")); assertThat(response.getIndexTemplates().get(0).getSettings().get("index.number_of_shards"), equalTo("1"));
assertThat(response.getIndexTemplates().get(0).getSettings().getAsBoolean("index.mapper.dynamic", null), is(false)); assertThat(response.getIndexTemplates().get(0).getSettings().getAsBoolean("index.mapper.dynamic", null), is(false));
client().admin().cluster().prepareUpdateSettings() assertAcked(
client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(ImmutableSettings.builder() .setTransientSettings(ImmutableSettings.builder()
.put("watcher.history.index.number_of_shards", "2") .put("watcher.history.index.number_of_shards", "2")
.put("watcher.history.index.mapper.dynamic", true)) // forbidden setting, should not get updated .put("watcher.history.index.mapper.dynamic", true)) // forbidden setting, should not get updated
.get(); .get()
);
// use assertBusy(...) because we update the index template in an async manner // use assertBusy(...) because we update the index template in an async manner
assertBusy(new Runnable() { assertBusy(new Runnable() {