From 735369b5f41ca02bdcdafeee66b9b2448efa700d Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 28 Apr 2015 15:26:20 +0200 Subject: [PATCH] test: use put watch api to insert watches test: verify that the exection queue size is 0 when Watcher isn't running Original commit: elastic/x-pack-elasticsearch@ea16d066e5d0b370bdef503247b7bff14a0441ab --- .../watcher/test/integration/NoMasterNodeTests.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/watcher/test/integration/NoMasterNodeTests.java b/src/test/java/org/elasticsearch/watcher/test/integration/NoMasterNodeTests.java index 8d3b214b733..6ec49477252 100644 --- a/src/test/java/org/elasticsearch/watcher/test/integration/NoMasterNodeTests.java +++ b/src/test/java/org/elasticsearch/watcher/test/integration/NoMasterNodeTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.watcher.WatcherService; import org.elasticsearch.watcher.client.WatchSourceBuilder; import org.elasticsearch.watcher.client.WatchSourceBuilders; +import org.elasticsearch.watcher.execution.ExecutionService; import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests; import org.elasticsearch.watcher.test.WatcherTestUtils; import org.elasticsearch.watcher.transport.actions.delete.DeleteWatchResponse; @@ -181,11 +182,12 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTests { // watcher starts in the background, it can happen we get here too soon, so wait until watcher has started. ensureWatcherStarted(false); + ensureLicenseEnabled(); for (int i = 1; i <= numberOfWatches; i++) { String watchName = "watch" + i; SearchRequest searchRequest = WatcherTestUtils.newInputSearchRequest("my-index").source(searchSource().query(termQuery("field", "value"))); BytesReference watchSource = createWatchSource("0/5 * * * * ? *", searchRequest, "ctx.payload.hits.total == 1"); - watchService().putWatch(watchName, watchSource); + watcherClient().preparePutWatch(watchName).setSource(watchSource).get(); } ensureGreen(); @@ -223,6 +225,9 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTests { for (WatcherService watcherService : internalTestCluster().getInstances(WatcherService.class)) { assertThat(watcherService.state(), is(WatcherService.State.STOPPED)); } + for (ExecutionService executionService : internalTestCluster().getInstances(ExecutionService.class)) { + assertThat(executionService.queueSize(), equalTo(0l)); + } } private void startElectedMasterNodeAndWait() throws Exception {