Skip to content

Commit c2a0be3

Browse files
authored
Fix DatafeedJobsIT.testDatafeedTimingStats_DatafeedRecreated (elastic#137928)
This commit fixes two separate issues in the test. Firstly, the assertion that search_count stats should be equal to zero may fail the second time the openAndRunJob runnable is invoked if the stats haven't been updated since the previous datafeed with the same ID was deleted. Wrapping the assertion in an assertBusy() call prevents this. Secondly, deleting the datafeed may fail if the master node which processes the delete datafeed action hasn't finished updating its state to reflect the fact that the datafeed has been stopped yet, but the node that processes the datafeed stats request has. Wrapping the datafeed deletion in an assertBusy() call allows it to be retried if this race condition is encountered. Closes elastic#137207 (cherry picked from commit 2bb729b)
1 parent 73ef18e commit c2a0be3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,6 @@ tests:
398398
- class: org.elasticsearch.xpack.esql.inference.rerank.RerankOperatorTests
399399
method: testSimpleCircuitBreaking
400400
issue: https://github.com/elastic/elasticsearch/issues/133619
401-
- class: org.elasticsearch.xpack.ml.integration.DatafeedJobsIT
402-
method: testDatafeedTimingStats_DatafeedRecreated
403-
issue: https://github.com/elastic/elasticsearch/issues/137207
404401
- class: org.elasticsearch.upgrades.SearchStatesIT
405402
method: testBWCSearchStates
406403
issue: https://github.com/elastic/elasticsearch/issues/137681

x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void testDatafeedTimingStats_DatafeedRecreated() throws Exception {
250250

251251
putDatafeed(datafeedConfig);
252252
// Datafeed did not do anything yet, hence search_count is equal to 0.
253-
assertDatafeedStats(datafeedId, DatafeedState.STOPPED, job.getId(), equalTo(0L));
253+
assertBusy(() -> assertDatafeedStats(datafeedId, DatafeedState.STOPPED, job.getId(), equalTo(0L)));
254254
startDatafeed(datafeedId, 0L, now.toEpochMilli());
255255

256256
// First, wait for data processing to complete
@@ -263,7 +263,14 @@ public void testDatafeedTimingStats_DatafeedRecreated() throws Exception {
263263
TimeUnit.SECONDS
264264
);
265265

266-
deleteDatafeed(datafeedId);
266+
DeleteDatafeedAction.Request request = new DeleteDatafeedAction.Request(datafeedId);
267+
assertBusy(() -> {
268+
try {
269+
client().execute(DeleteDatafeedAction.INSTANCE, request).actionGet();
270+
} catch (Exception e) {
271+
throw new AssertionError("Datafeed could not be deleted", e);
272+
}
273+
});
267274
waitUntilJobIsClosed(job.getId());
268275
};
269276

0 commit comments

Comments
 (0)