Skip to content

Commit 76c1469

Browse files
jan-elasticelasticsearchmachine
andauthored
[8.17] backport datafeeds test fixes (#120301)
* Clean up lingering tasks after DatafeedJobsIT. (#120040) * [8.x] backport datafeeds test fixes (#120289) * Fix(?) and unmute DatafeedJobsRestIT. (#119839) * Fix(?) and unmute DatafeedJobsRestIT. * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]> * Datafeed jobs it wait for task cancel (#120177) * Fix task cancellation in DatafeedJobsIT. * fix * unmute DatafeedJobsIT * unmute --------- Co-authored-by: elasticsearchmachine <[email protected]> --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent e916b17 commit 76c1469

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

muted-tests.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,9 @@ tests:
237237
issue: https://github.com/elastic/elasticsearch/issues/115664
238238
- class: org.elasticsearch.indices.mapping.UpdateMappingIntegrationIT
239239
issue: https://github.com/elastic/elasticsearch/issues/116126
240-
- class: org.elasticsearch.xpack.ml.integration.DatafeedJobsRestIT
241-
issue: https://github.com/elastic/elasticsearch/issues/111319
242240
- class: org.elasticsearch.upgrades.FullClusterRestartIT
243241
method: testSnapshotRestore {cluster=OLD}
244242
issue: https://github.com/elastic/elasticsearch/issues/111777
245-
- class: org.elasticsearch.xpack.ml.integration.DatafeedJobsRestIT
246-
method: testLookbackWithIndicesOptions
247-
issue: https://github.com/elastic/elasticsearch/issues/116127
248243
- class: org.elasticsearch.xpack.restart.CoreFullClusterRestartIT
249244
method: testSnapshotRestore {cluster=UPGRADED}
250245
issue: https://github.com/elastic/elasticsearch/issues/111799

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.elasticsearch.ElasticsearchException;
1212
import org.elasticsearch.ElasticsearchStatusException;
1313
import org.elasticsearch.ResourceNotFoundException;
14+
import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
15+
import org.elasticsearch.action.admin.cluster.node.tasks.cancel.TransportCancelTasksAction;
1416
import org.elasticsearch.action.search.SearchRequest;
1517
import org.elasticsearch.action.support.master.AcknowledgedResponse;
1618
import org.elasticsearch.common.ReferenceDocs;
@@ -80,6 +82,13 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase {
8082
public void cleanup() {
8183
updateClusterSettings(Settings.builder().putNull("logger.org.elasticsearch.xpack.ml.datafeed"));
8284
cleanUp();
85+
// Race conditions between closing and killing tasks in these tests,
86+
// sometimes result in lingering persistent close tasks, which cause
87+
// subsequent tests to fail. Therefore, they're explicitly cancelled.
88+
CancelTasksRequest cancelTasksRequest = new CancelTasksRequest();
89+
cancelTasksRequest.setActions("*close*");
90+
cancelTasksRequest.setWaitForCompletion(true);
91+
client().execute(TransportCancelTasksAction.TYPE, cancelTasksRequest).actionGet();
8392
}
8493

8594
public void testLookbackOnly() throws Exception {

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import static org.hamcrest.Matchers.anyOf;
3838
import static org.hamcrest.Matchers.containsString;
3939
import static org.hamcrest.Matchers.equalTo;
40-
import static org.hamcrest.Matchers.not;
4140

4241
public class DatafeedJobsRestIT extends ESRestTestCase {
4342

@@ -503,12 +502,12 @@ public void testLookbackWithIndicesOptions() throws Exception {
503502
}""");
504503
client().performRequest(createJobRequest);
505504
String datafeedId = jobId + "-datafeed";
506-
new DatafeedBuilder(datafeedId, jobId, "*hidden-*").setIndicesOptions("""
505+
new DatafeedBuilder(datafeedId, jobId, "hidden-*").setIndicesOptions("""
507506
{"expand_wildcards": ["all"],"allow_no_indices": true}""").build();
508507

509508
StringBuilder bulk = new StringBuilder();
510509

511-
Request createGeoData = new Request("PUT", "/.hidden-index");
510+
Request createGeoData = new Request("PUT", "/hidden-index");
512511
createGeoData.setJsonEntity("""
513512
{
514513
"mappings": {
@@ -528,23 +527,23 @@ public void testLookbackWithIndicesOptions() throws Exception {
528527
client().performRequest(createGeoData);
529528

530529
bulk.append("""
531-
{"index": {"_index": ".hidden-index", "_id": 1}}
530+
{"index": {"_index": "hidden-index", "_id": 1}}
532531
{"time":"2016-06-01T00:00:00Z","value": 1000}
533-
{"index": {"_index": ".hidden-index", "_id": 2}}
532+
{"index": {"_index": "hidden-index", "_id": 2}}
534533
{"time":"2016-06-01T00:05:00Z","value":1500}
535-
{"index": {"_index": ".hidden-index", "_id": 3}}
534+
{"index": {"_index": "hidden-index", "_id": 3}}
536535
{"time":"2016-06-01T00:10:00Z","value":1600}
537-
{"index": {"_index": ".hidden-index", "_id": 4}}
536+
{"index": {"_index": "hidden-index", "_id": 4}}
538537
{"time":"2016-06-01T00:15:00Z","value":100}
539-
{"index": {"_index": ".hidden-index", "_id": 5}}
538+
{"index": {"_index": "hidden-index", "_id": 5}}
540539
{"time":"2016-06-01T00:20:00Z","value":1}
541-
{"index": {"_index": ".hidden-index", "_id": 6}}
540+
{"index": {"_index": "hidden-index", "_id": 6}}
542541
{"time":"2016-06-01T00:25:00Z","value":1500}
543-
{"index": {"_index": ".hidden-index", "_id": 7}}
542+
{"index": {"_index": "hidden-index", "_id": 7}}
544543
{"time":"2016-06-01T00:30:00Z","value":1500}
545-
{"index": {"_index": ".hidden-index", "_id": 8}}
544+
{"index": {"_index": "hidden-index", "_id": 8}}
546545
{"time":"2016-06-01T00:40:00Z","value":2100}
547-
{"index": {"_index": ".hidden-index", "_id": 9}}
546+
{"index": {"_index": "hidden-index", "_id": 9}}
548547
{"time":"2016-06-01T00:41:00Z","value":0}
549548
""");
550549
bulkIndex(bulk.toString());
@@ -1802,7 +1801,7 @@ private void bulkIndex(String bulk) throws IOException {
18021801
bulkRequest.addParameter("refresh", "true");
18031802
bulkRequest.addParameter("pretty", null);
18041803
String bulkResponse = EntityUtils.toString(client().performRequest(bulkRequest).getEntity());
1805-
assertThat(bulkResponse, not(containsString("\"errors\": false")));
1804+
assertThat(bulkResponse, containsString("\"errors\" : false"));
18061805
}
18071806

18081807
private Response createJobAndDataFeed(String jobId, String datafeedId) throws IOException {

0 commit comments

Comments
 (0)