From 3b9545848f4e1749d55112a034ba3250c66971b0 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 13 Mar 2020 15:13:26 +0100 Subject: [PATCH] Reenable watcher rest tests (#53532) Also log a message instead of failing if there are active watches at a beginning of a test. Relates to #53177 --- .../org/elasticsearch/smoketest/WatcherYamlRestIT.java | 2 -- .../xpack/watcher/WatcherYamlSuiteTestCase.java | 10 ++++++++-- ...keTestWatcherWithSecurityClientYamlTestSuiteIT.java | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/smoketest/WatcherYamlRestIT.java b/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/smoketest/WatcherYamlRestIT.java index 8f94e7c61d3..5ec99c01b97 100644 --- a/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/smoketest/WatcherYamlRestIT.java +++ b/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/smoketest/WatcherYamlRestIT.java @@ -5,14 +5,12 @@ */ package org.elasticsearch.smoketest; -import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.xpack.watcher.WatcherYamlSuiteTestCase; /** * Runs the YAML rest tests against an external cluster */ -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/53177") public class WatcherYamlRestIT extends WatcherYamlSuiteTestCase { public WatcherYamlRestIT(ClientYamlTestCandidate testCandidate) { super(testCandidate); diff --git a/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/xpack/watcher/WatcherYamlSuiteTestCase.java b/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/xpack/watcher/WatcherYamlSuiteTestCase.java index 96dde81bf8a..7dd064f7dbc 100644 --- a/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/xpack/watcher/WatcherYamlSuiteTestCase.java +++ b/x-pack/plugin/watcher/qa/rest/src/test/java/org/elasticsearch/xpack/watcher/WatcherYamlSuiteTestCase.java @@ -14,11 +14,11 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.junit.After; import org.junit.Before; +import java.io.IOException; import java.util.concurrent.TimeUnit; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; /** @@ -54,7 +54,10 @@ public abstract class WatcherYamlSuiteTestCase extends ESClientYamlSuiteTestCase throw new AssertionError("waiting until starting state reached started state"); case "started": int watcherCount = (int) response.evaluate("stats.0.watch_count"); - assertThat(watcherCount, equalTo(0)); + if (watcherCount > 0) { + logger.info("expected 0 active watches, but got [{}], deleting watcher indices again", watcherCount); + deleteWatcherIndices(); + } // all good here, we are done break; default: @@ -88,7 +91,10 @@ public abstract class WatcherYamlSuiteTestCase extends ESClientYamlSuiteTestCase throw new AssertionError("unknown state[" + state + "]"); } }, 60, TimeUnit.SECONDS); + deleteWatcherIndices(); + } + private static void deleteWatcherIndices() throws IOException { Request deleteWatchesIndexRequest = new Request("DELETE", ".watches"); deleteWatchesIndexRequest.addParameter("ignore_unavailable", "true"); adminClient().performRequest(deleteWatchesIndexRequest); diff --git a/x-pack/plugin/watcher/qa/with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java b/x-pack/plugin/watcher/qa/with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java index e16ccc70ca9..5bebf4ebc23 100644 --- a/x-pack/plugin/watcher/qa/with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java +++ b/x-pack/plugin/watcher/qa/with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java @@ -7,7 +7,6 @@ package org.elasticsearch.smoketest; import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; -import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.client.Request; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; @@ -19,7 +18,6 @@ import org.junit.Before; import static org.elasticsearch.xpack.test.SecuritySettingsSourceField.basicAuthHeaderValue; -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/53177") public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends WatcherYamlSuiteTestCase { private static final String TEST_ADMIN_USERNAME = "test_admin";