Skip to content

Commit

Permalink
Fix Watcher ExecuteWatchQueuedStatsTests (elastic#82134)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis authored and astefan committed Jan 7, 2022
1 parent 3c47de5 commit 3fc9d75
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package org.elasticsearch.xpack.watcher.execution;

import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.client.internal.Client;
Expand All @@ -22,7 +21,8 @@
import org.elasticsearch.xpack.core.watcher.transport.actions.put.PutWatchRequestBuilder;
import org.elasticsearch.xpack.core.watcher.transport.actions.stats.WatcherStatsRequestBuilder;
import org.elasticsearch.xpack.core.watcher.transport.actions.stats.WatcherStatsResponse;
import org.elasticsearch.xpack.watcher.actions.index.IndexAction;
import org.elasticsearch.xpack.watcher.actions.logging.LoggingAction;
import org.elasticsearch.xpack.watcher.common.text.TextTemplate;
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
import org.elasticsearch.xpack.watcher.trigger.manual.ManualTriggerEvent;
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTriggerEvent;
Expand All @@ -35,13 +35,14 @@
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static org.elasticsearch.xpack.watcher.input.InputBuilders.simpleInput;
import static org.elasticsearch.xpack.watcher.trigger.TriggerBuilders.schedule;
import static org.elasticsearch.xpack.watcher.trigger.schedule.Schedules.interval;
import static org.hamcrest.Matchers.empty;

@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/66392")
public class ExecuteWatchQueuedStatsTests extends AbstractWatcherIntegrationTestCase {

@Override
Expand All @@ -66,8 +67,12 @@ public void testQueuedStats() throws ExecutionException, InterruptedException {
new PutWatchRequestBuilder(client, "id").setActive(true)
.setSource(
new WatchSourceBuilder().input(simpleInput("payload", "yes"))
.trigger(schedule(interval("1s")))
.addAction("action", TimeValue.timeValueSeconds(1), IndexAction.builder("test_index").setDocId("id"))
.trigger(schedule(interval("1h")))
.addAction(
"action",
TimeValue.timeValueSeconds(1),
LoggingAction.builder(new TextTemplate("logging action for testQueuedStats"))
)
)
.get();

Expand Down Expand Up @@ -95,7 +100,7 @@ public void testQueuedStats() throws ExecutionException, InterruptedException {
fail(e.toString());
}
request.setActionMode("_all", ActionExecutionMode.EXECUTE);
request.setRecordExecution(true);
request.setRecordExecution(false);
futures.add(client.execute(ExecuteWatchAction.INSTANCE, request));
}
});
Expand All @@ -119,7 +124,11 @@ public void testQueuedStats() throws ExecutionException, InterruptedException {
watcherStatsThread.join();

for (final ActionFuture<ExecuteWatchResponse> future : futures) {
future.get();
try {
future.get(1, TimeUnit.MINUTES);
} catch (TimeoutException e) {
fail(e.toString());
}
}

assertThat(failures, empty());
Expand Down

0 comments on commit 3fc9d75

Please sign in to comment.