Skip to content

Commit

Permalink
[ML] Account for service being triggered twice in tests (#80000) (#80006
Browse files Browse the repository at this point in the history
)

A race can cause the service under test to be triggered twice.
As the test is asserting that the trigger occurs at least once multiple
invocations should not be considered a failure
  • Loading branch information
davidkyle committed Oct 28, 2021
1 parent 88c89f3 commit 46f251d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.junit.After;
import org.junit.Before;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;

import java.util.Collections;
Expand Down Expand Up @@ -149,10 +150,10 @@ private void assertThatBothTasksAreTriggered(Answer<?> deleteExpiredDataAnswer,
latch.await(5, TimeUnit.SECONDS);
}

verify(client, times(2)).threadPool();
verify(client).execute(same(DeleteExpiredDataAction.INSTANCE), any(), any());
verify(client).execute(same(GetJobsAction.INSTANCE), any(), any());
verify(mlAssignmentNotifier).auditUnassignedMlTasks(any(), any());
verify(client, Mockito.atLeast(2)).threadPool();
verify(client, Mockito.atLeast(1)).execute(same(DeleteExpiredDataAction.INSTANCE), any(), any());
verify(client, Mockito.atLeast(1)).execute(same(GetJobsAction.INSTANCE), any(), any());
verify(mlAssignmentNotifier, Mockito.atLeast(1)).auditUnassignedMlTasks(any(), any());
verifyNoMoreInteractions(client, mlAssignmentNotifier);
}

Expand Down

0 comments on commit 46f251d

Please sign in to comment.