Skip to content

Commit

Permalink
[ML][Transform] fixing testFailureCounterIsResetOnSuccess test failure
Browse files Browse the repository at this point in the history
…#76397 (#76417) (#76422)

There are two possible race conditions that were not
previously handled in this test.

- Since the syncconfig was null, it may be that the
  transform actually gets set to stopping/stopped
  and its unable to kick off another indexing pass
- It may also be that the indexer thread is still
  finishing up work when the second execution is
  requested, so it returns false.

Adding a sync config and assertBusy handles these
cases. Ran 1k+ times locally with this change
and it never failed. Without, it failed ~10 runs.

closes #76397
  • Loading branch information
benwtrent authored Aug 12, 2021
1 parent 96ed07f commit 874e77b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.elasticsearch.xpack.core.scheduler.SchedulerEngine;
import org.elasticsearch.xpack.core.transform.transforms.SettingsConfig;
import org.elasticsearch.xpack.core.transform.transforms.TimeRetentionPolicyConfig;
import org.elasticsearch.xpack.core.transform.transforms.TimeSyncConfig;
import org.elasticsearch.xpack.core.transform.transforms.TransformCheckpoint;
import org.elasticsearch.xpack.core.transform.transforms.TransformConfig;
import org.elasticsearch.xpack.core.transform.transforms.TransformIndexerPosition;
Expand Down Expand Up @@ -717,7 +718,7 @@ public void testFailureCounterIsResetOnSuccess() throws Exception {
randomSourceConfig(),
randomDestConfig(),
null,
null,
new TimeSyncConfig("time", TimeSyncConfig.DEFAULT_DELAY),
null,
randomPivotConfig(),
null,
Expand Down Expand Up @@ -809,7 +810,7 @@ public SearchResponse apply(SearchRequest searchRequest) {

indexer.start();
assertThat(indexer.getState(), equalTo(IndexerState.STARTED));
assertTrue(indexer.maybeTriggerAsyncJob(System.currentTimeMillis()));
assertBusy(() -> assertTrue(indexer.maybeTriggerAsyncJob(System.currentTimeMillis())));
assertThat(indexer.getState(), equalTo(IndexerState.INDEXING));

secondLatch.countDown();
Expand Down

0 comments on commit 874e77b

Please sign in to comment.