Skip to content

Commit

Permalink
[TEST] Fix backport of #30941 (#30954)
Browse files Browse the repository at this point in the history
The implementation of #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.
  • Loading branch information
droberts195 authored May 30, 2018
1 parent 6f224f3 commit f51c497
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package org.elasticsearch.xpack.core.ml.integration;

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

@SuppressWarnings("unchecked")
private void deleteAllDatafeeds() throws IOException {
final Request datafeedsRequest = new Request("GET", "/_xpack/ml/datafeeds");
datafeedsRequest.addParameter("filter_path", "datafeeds");
final Response datafeedsResponse = adminClient.performRequest(datafeedsRequest);
@SuppressWarnings("unchecked")
final Map<String, Object> datafeedsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/datafeeds"));
final List<Map<String, Object>> datafeeds =
(List<Map<String, Object>>) XContentMapValues.extractValue("datafeeds", testCase.entityAsMap(datafeedsResponse));
(List<Map<String, Object>>) XContentMapValues.extractValue("datafeeds", datafeedsAsMap);
if (datafeeds == null) {
return;
}
Expand Down Expand Up @@ -79,12 +74,10 @@ private void deleteAllDatafeeds() throws IOException {
}

private void deleteAllJobs() throws IOException {
final Request jobsRequest = new Request("GET", "/_xpack/ml/anomaly_detectors");
jobsRequest.addParameter("filter_path", "jobs");
final Response response = adminClient.performRequest(jobsRequest);
final Map<String, Object> jobsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/anomaly_detectors"));
@SuppressWarnings("unchecked")
final List<Map<String, Object>> jobConfigs =
(List<Map<String, Object>>) XContentMapValues.extractValue("jobs", testCase.entityAsMap(response));
(List<Map<String, Object>>) XContentMapValues.extractValue("jobs", jobsAsMap);
if (jobConfigs == null) {
return;
}
Expand Down

0 comments on commit f51c497

Please sign in to comment.