Skip to content

Commit fc07dc8

Browse files
authored
[TEST] Force close failed job before skipping test (elastic#53128)
The assumption added in elastic#52631 skips a problematic test if it fails to create the required conditions for the scenario it is supposed to be testing. (This happens very rarely.) However, before skipping the test it needs to remove the failed job it has created because the standard test cleanup code treats failed jobs as fatal errors. Closes elastic#52608
1 parent 40bd334 commit fc07dc8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,15 @@ public void testCloseUnassignedFailedJobAndStopUnassignedStoppingDatafeed() thro
248248

249249
// It is possible that the datafeed has already detected the job failure and
250250
// terminated itself. In this happens there is no persistent task to stop
251-
assumeFalse("The datafeed task is null most likely because the datafeed detected the job had failed. " +
251+
if (task == null) {
252+
// We have to force close the job, because the standard cleanup
253+
// will treat a leftover failed job as a fatal error
254+
CloseJobAction.Request closeJobRequest = new CloseJobAction.Request(jobId);
255+
closeJobRequest.setForce(true);
256+
client().execute(CloseJobAction.INSTANCE, closeJobRequest).actionGet();
257+
assumeFalse("The datafeed task is null most likely because the datafeed detected the job had failed. " +
252258
"This is expected to happen extremely rarely but the test cannot continue in these circumstances.", task == null);
259+
}
253260

254261
UpdatePersistentTaskStatusAction.Request updatePersistentTaskStatusRequest =
255262
new UpdatePersistentTaskStatusAction.Request(task.getId(), task.getAllocationId(), DatafeedState.STOPPING);

0 commit comments

Comments
 (0)