diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index ae22d9f6dac9..7334ee4ed0a1 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -567,7 +567,8 @@ protected void ensureLicenseEnabled() throws Exception { protected void stopWatcher() throws Exception { assertBusy(() -> { - WatcherStatsResponse watcherStatsResponse = new WatcherStatsRequestBuilder(client()).get(); + + WatcherStatsResponse watcherStatsResponse = new WatcherStatsRequestBuilder(client()).setIncludeCurrentWatches(true).get(); assertThat(watcherStatsResponse.hasFailures(), is(false)); List> currentStatesFromStatsRequest = watcherStatsResponse.getNodes() .stream() @@ -580,7 +581,8 @@ protected void stopWatcher() throws Exception { .collect(Collectors.toList()); List states = currentStatesFromStatsRequest.stream().map(Tuple::v2).collect(Collectors.toList()); - logger.info("waiting to stop watcher, current states {}", currentStatesFromStatsRequest); + long currentWatches = watcherStatsResponse.getNodes().stream().mapToLong(n -> n.getSnapshots().size()).sum(); + logger.info("waiting to stop watcher, current states {}, current watches [{}]", currentStatesFromStatsRequest, currentWatches); boolean isAllStateStarted = states.stream().allMatch(w -> w == WatcherState.STARTED); if (isAllStateStarted) { @@ -594,7 +596,7 @@ protected void stopWatcher() throws Exception { } boolean isAllStateStopped = states.stream().allMatch(w -> w == WatcherState.STOPPED); - if (isAllStateStopped) { + if (isAllStateStopped && currentWatches == 0) { return; } diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java index bce9aaf0187d..ec03215435fa 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java @@ -50,7 +50,6 @@ protected boolean timeWarped() { return false; } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/66495") public void testDeactivateAndActivate() throws Exception { PutWatchResponse putWatchResponse = new PutWatchRequestBuilder(client()).setId("_id") .setSource( @@ -107,7 +106,6 @@ public void testDeactivateAndActivate() throws Exception { }); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/66495") public void testLoadWatchWithoutAState() throws Exception { PutWatchResponse putWatchResponse = new PutWatchRequestBuilder(client()).setId("_id") .setSource(