Skip to content

Commit e08ca55

Browse files
committed
[TEST] Fix backport of elastic#30941
The implementation of elastic#30941 used functionality that is only available in 6.4 and higher. This changes the implementation in 6.3 to one that is less elegant but still uses ML endpoints rather than retrieving the cluster state directly.
1 parent 6a74eb6 commit e08ca55

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
package org.elasticsearch.xpack.core.ml.integration;
77

88
import org.apache.logging.log4j.Logger;
9-
import org.elasticsearch.client.Request;
10-
import org.elasticsearch.client.Response;
119
import org.elasticsearch.client.RestClient;
1210
import org.elasticsearch.common.xcontent.support.XContentMapValues;
1311
import org.elasticsearch.test.rest.ESRestTestCase;
@@ -37,12 +35,9 @@ public void clearMlMetadata() throws IOException {
3735

3836
@SuppressWarnings("unchecked")
3937
private void deleteAllDatafeeds() throws IOException {
40-
final Request datafeedsRequest = new Request("GET", "/_xpack/ml/datafeeds");
41-
datafeedsRequest.addParameter("filter_path", "datafeeds");
42-
final Response datafeedsResponse = adminClient.performRequest(datafeedsRequest);
43-
@SuppressWarnings("unchecked")
38+
final Map<String, Object> datafeedsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/datafeeds"));
4439
final List<Map<String, Object>> datafeeds =
45-
(List<Map<String, Object>>) XContentMapValues.extractValue("datafeeds", testCase.entityAsMap(datafeedsResponse));
40+
(List<Map<String, Object>>) XContentMapValues.extractValue("datafeeds", datafeedsAsMap);
4641
if (datafeeds == null) {
4742
return;
4843
}
@@ -79,12 +74,10 @@ private void deleteAllDatafeeds() throws IOException {
7974
}
8075

8176
private void deleteAllJobs() throws IOException {
82-
final Request jobsRequest = new Request("GET", "/_xpack/ml/anomaly_detectors");
83-
jobsRequest.addParameter("filter_path", "jobs");
84-
final Response response = adminClient.performRequest(jobsRequest);
77+
final Map<String, Object> jobsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/anomaly_detectors"));
8578
@SuppressWarnings("unchecked")
8679
final List<Map<String, Object>> jobConfigs =
87-
(List<Map<String, Object>>) XContentMapValues.extractValue("jobs", testCase.entityAsMap(response));
80+
(List<Map<String, Object>>) XContentMapValues.extractValue("jobs", jobsAsMap);
8881
if (jobConfigs == null) {
8982
return;
9083
}

0 commit comments

Comments
 (0)