[ML] Wait for job to close in test (elastic/x-pack-elasticsearch#1825)
Original commit: elastic/x-pack-elasticsearch@3dbeed58f3f646cc0fe664795a3b9985ad5cadba
@@ -406,6 +406,15 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
} else {
listener.actionGet();
}
+
+ if (invalidLicense) {
+ // the close due to invalid license happens async, so check if the job turns into closed state:
+ assertBusy(() -> {
+ GetJobsStatsAction.Response response =
+ new MachineLearningClient(client).getJobsStats(new GetJobsStatsAction.Request(jobId)).actionGet();
+ assertEquals(JobState.CLOSED, response.getResponse().results().get(0).getState());
+ });
+ }
}
}
