Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

@TestLogging("org.elasticsearch.xpack.watcher:DEBUG,org.elasticsearch.xpack.watcher.WatcherIndexingListener:TRACE")
@TestLogging("org.elasticsearch.xpack.watcher:DEBUG,org.elasticsearch.xpack.core.watcher:DEBUG," +
"org.elasticsearch.xpack.watcher.WatcherIndexingListener:TRACE")
public class ActivateWatchTests extends AbstractWatcherIntegrationTestCase {

@Override
protected boolean timeWarped() {
return false;
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/30699")
public void testDeactivateAndActivate() throws Exception {
PutWatchResponse putWatchResponse = watcherClient().preparePutWatch()
.setId("_id")
Expand Down Expand Up @@ -88,13 +88,9 @@ public void testDeactivateAndActivate() throws Exception {
refresh();
long count1 = docCount(".watcher-history*", matchAllQuery());

logger.info("Sleeping for 5 seconds, watch history count [{}]", count1);
Thread.sleep(5000);

refresh();
long count2 = docCount(".watcher-history*", matchAllQuery());

assertThat(count2, is(count1));
//ensure no new watch history
awaitBusy(() -> count1 != docCount(".watcher-history*", matchAllQuery()), 5, TimeUnit.SECONDS);

// lets activate it again
logger.info("Activating watch again");
Expand All @@ -107,11 +103,11 @@ public void testDeactivateAndActivate() throws Exception {
assertThat(getWatchResponse, notNullValue());
assertThat(getWatchResponse.getStatus().state().isActive(), is(true));

logger.info("Sleeping for another five seconds, ensuring that watch is executed");
Thread.sleep(5000);
refresh();
long count3 = docCount(".watcher-history*", matchAllQuery());
assertThat(count3, greaterThan(count1));
assertBusy(() -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed you added the 5s timeout to the first awaitBusy(), any reason it was not added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a subtle difference...

the call above on line 93 is awaitBusy, which in the happy case always take 5 seconds, so this test will always take at least 5 seconds (ensuring nothing changed in that time period).

the call just above on line 107 is assertBusy, which in the happiest case will not need any waiting at all, but can wait up to 10 seconds if needed. It's a subtle change from the min time the test will take to minor increase in the max time the test can take.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeesh, i didnt even see that. thanks for the explain.

long count2 = docCount(".watcher-history*", matchAllQuery());
assertThat(count2, greaterThan(count1));
});
}

public void testLoadWatchWithoutAState() throws Exception {
Expand Down