From e08ca5567976707b5f65153fd082311e6fff7f73 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 30 May 2018 10:04:29 +0100 Subject: [PATCH] [TEST] Fix backport of #30941 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. --- .../ml/integration/MlRestTestStateCleaner.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java index 426b9d7edd866..1fa7f6cbf377d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java @@ -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; @@ -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 datafeedsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/datafeeds")); final List> datafeeds = - (List>) XContentMapValues.extractValue("datafeeds", testCase.entityAsMap(datafeedsResponse)); + (List>) XContentMapValues.extractValue("datafeeds", datafeedsAsMap); if (datafeeds == null) { return; } @@ -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 jobsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/anomaly_detectors")); @SuppressWarnings("unchecked") final List> jobConfigs = - (List>) XContentMapValues.extractValue("jobs", testCase.entityAsMap(response)); + (List>) XContentMapValues.extractValue("jobs", jobsAsMap); if (jobConfigs == null) { return; }