Skip to content

Commit fea9217

Browse files
authored
[ML] Account for service being triggered twice in tests (#80000)
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
1 parent cdbb5ef commit fea9217

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlDailyMaintenanceServiceTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.elasticsearch.xpack.core.ml.job.config.Job;
3535
import org.junit.After;
3636
import org.junit.Before;
37+
import org.mockito.Mockito;
3738
import org.mockito.stubbing.Answer;
3839

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

152-
verify(client, times(2)).threadPool();
153-
verify(client).execute(same(DeleteExpiredDataAction.INSTANCE), any(), any());
154-
verify(client).execute(same(GetJobsAction.INSTANCE), any(), any());
155-
verify(mlAssignmentNotifier).auditUnassignedMlTasks(any(), any());
153+
verify(client, Mockito.atLeast(2)).threadPool();
154+
verify(client, Mockito.atLeast(1)).execute(same(DeleteExpiredDataAction.INSTANCE), any(), any());
155+
verify(client, Mockito.atLeast(1)).execute(same(GetJobsAction.INSTANCE), any(), any());
156+
verify(mlAssignmentNotifier, Mockito.atLeast(1)).auditUnassignedMlTasks(any(), any());
156157
verifyNoMoreInteractions(client, mlAssignmentNotifier);
157158
}
158159

0 commit comments

Comments
 (0)