@@ -208,7 +208,9 @@ public void testCreateJobsWithIndexNameOption() throws Exception {
208
208
}
209
209
});
210
210
211
- String responseAsString = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
211
+ // Use _cat/indices/.ml-anomalies-* instead of _cat/indices/_all to workaround https://github.com/elastic/elasticsearch/issues/45652
212
+ String responseAsString = EntityUtils .toString (client ().performRequest (
213
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
212
214
assertThat (responseAsString ,
213
215
containsString (AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "custom-" + indexName ));
214
216
assertThat (responseAsString , not (containsString (AnomalyDetectorsIndex .jobResultsAliasedName (jobId1 ))));
@@ -272,7 +274,8 @@ public void testCreateJobsWithIndexNameOption() throws Exception {
272
274
assertThat (responseAsString , not (containsString (AnomalyDetectorsIndex .jobResultsAliasedName (jobId1 ))));
273
275
assertThat (responseAsString , containsString (AnomalyDetectorsIndex .jobResultsAliasedName (jobId2 ))); //job2 still exists
274
276
275
- responseAsString = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
277
+ responseAsString = EntityUtils .toString (client ().performRequest (
278
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
276
279
assertThat (responseAsString , containsString (AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "custom-" + indexName ));
277
280
278
281
client ().performRequest (new Request ("POST" , "/_refresh" ));
@@ -287,7 +290,8 @@ public void testCreateJobsWithIndexNameOption() throws Exception {
287
290
assertThat (responseAsString , not (containsString (AnomalyDetectorsIndex .jobResultsAliasedName (jobId2 ))));
288
291
289
292
client ().performRequest (new Request ("POST" , "/_refresh" ));
290
- responseAsString = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
293
+ responseAsString = EntityUtils .toString (client ().performRequest (
294
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
291
295
assertThat (responseAsString , not (containsString (AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "custom-" + indexName )));
292
296
}
293
297
@@ -394,19 +398,21 @@ public void testCreateJob_WithClashingFieldMappingsFails() throws Exception {
394
398
"avoid the clash by assigning a dedicated results index" ));
395
399
}
396
400
397
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/45652" )
398
401
public void testDeleteJob () throws Exception {
399
402
String jobId = "delete-job-job" ;
400
403
String indexName = AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields .RESULTS_INDEX_DEFAULT ;
401
404
createFarequoteJob (jobId );
402
405
403
- String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
406
+ // Use _cat/indices/.ml-anomalies-* instead of _cat/indices/_all to workaround https://github.com/elastic/elasticsearch/issues/45652
407
+ String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (
408
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
404
409
assertThat (indicesBeforeDelete , containsString (indexName ));
405
410
406
411
client ().performRequest (new Request ("DELETE" , MachineLearning .BASE_PATH + "anomaly_detectors/" + jobId ));
407
412
408
413
// check that the index still exists (it's shared by default)
409
- String indicesAfterDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
414
+ String indicesAfterDelete = EntityUtils .toString (client ().performRequest (
415
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
410
416
assertThat (indicesAfterDelete , containsString (indexName ));
411
417
412
418
waitUntilIndexIsEmpty (indexName );
@@ -465,13 +471,14 @@ public void testDeleteJob_TimingStatsDocumentIsDeleted() throws Exception {
465
471
assertThat (exception .getResponse ().getStatusLine ().getStatusCode (), equalTo (404 ));
466
472
}
467
473
468
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/45652" )
469
474
public void testDeleteJobAsync () throws Exception {
470
475
String jobId = "delete-job-async-job" ;
471
476
String indexName = AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields .RESULTS_INDEX_DEFAULT ;
472
477
createFarequoteJob (jobId );
473
478
474
- String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
479
+ // Use _cat/indices/.ml-anomalies-* instead of _cat/indices/_all to workaround https://github.com/elastic/elasticsearch/issues/45652
480
+ String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (
481
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
475
482
assertThat (indicesBeforeDelete , containsString (indexName ));
476
483
477
484
Response response = client ().performRequest (new Request ("DELETE" , MachineLearning .BASE_PATH + "anomaly_detectors/" + jobId
@@ -483,7 +490,8 @@ public void testDeleteJobAsync() throws Exception {
483
490
assertThat (EntityUtils .toString (taskResponse .getEntity ()), containsString ("\" acknowledged\" :true" ));
484
491
485
492
// check that the index still exists (it's shared by default)
486
- String indicesAfterDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
493
+ String indicesAfterDelete = EntityUtils .toString (client ().performRequest (
494
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
487
495
assertThat (indicesAfterDelete , containsString (indexName ));
488
496
489
497
waitUntilIndexIsEmpty (indexName );
@@ -518,7 +526,9 @@ public void testDeleteJobAfterMissingIndex() throws Exception {
518
526
String indexName = AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields .RESULTS_INDEX_DEFAULT ;
519
527
createFarequoteJob (jobId );
520
528
521
- String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
529
+ // Use _cat/indices/.ml-anomalies-* instead of _cat/indices/_all to workaround https://github.com/elastic/elasticsearch/issues/45652
530
+ String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (
531
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
522
532
assertThat (indicesBeforeDelete , containsString (indexName ));
523
533
524
534
// Manually delete the index so that we can test that deletion proceeds
@@ -528,7 +538,8 @@ public void testDeleteJobAfterMissingIndex() throws Exception {
528
538
client ().performRequest (new Request ("DELETE" , MachineLearning .BASE_PATH + "anomaly_detectors/" + jobId ));
529
539
530
540
// check index was deleted
531
- String indicesAfterDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
541
+ String indicesAfterDelete = EntityUtils .toString (client ().performRequest (
542
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
532
543
assertThat (indicesAfterDelete , not (containsString (aliasName )));
533
544
assertThat (indicesAfterDelete , not (containsString (indexName )));
534
545
@@ -598,7 +609,9 @@ public void testMultiIndexDelete() throws Exception {
598
609
"}" );
599
610
client ().performRequest (extraIndex2 );
600
611
601
- String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
612
+ // Use _cat/indices/.ml-anomalies-* instead of _cat/indices/_all to workaround https://github.com/elastic/elasticsearch/issues/45652
613
+ String indicesBeforeDelete = EntityUtils .toString (client ().performRequest (
614
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
602
615
assertThat (indicesBeforeDelete , containsString (indexName ));
603
616
assertThat (indicesBeforeDelete , containsString (indexName + "-001" ));
604
617
assertThat (indicesBeforeDelete , containsString (indexName + "-002" ));
@@ -637,7 +650,8 @@ public void testMultiIndexDelete() throws Exception {
637
650
client ().performRequest (new Request ("POST" , "/_refresh" ));
638
651
639
652
// check that the indices still exist but are empty
640
- String indicesAfterDelete = EntityUtils .toString (client ().performRequest (new Request ("GET" , "/_cat/indices" )).getEntity ());
653
+ String indicesAfterDelete = EntityUtils .toString (client ().performRequest (
654
+ new Request ("GET" , "/_cat/indices/" + AnomalyDetectorsIndexFields .RESULTS_INDEX_PREFIX + "*" )).getEntity ());
641
655
assertThat (indicesAfterDelete , containsString (indexName ));
642
656
assertThat (indicesAfterDelete , containsString (indexName + "-001" ));
643
657
assertThat (indicesAfterDelete , containsString (indexName + "-002" ));
0 commit comments