From 4402cf38bf9b2e515d596678117956806cb77059 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Mon, 15 Jul 2019 11:58:09 +0100 Subject: [PATCH] Wait for pending tasks in docs tests cleanup (#44123) ML and Data Frame tests should wait for pending tasks --- .../data-frames/apis/put-transform.asciidoc | 2 +- docs/reference/ml/apis/put-job.asciidoc | 1 - .../smoketest/DocsClientYamlTestSuiteIT.java | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/reference/data-frames/apis/put-transform.asciidoc b/docs/reference/data-frames/apis/put-transform.asciidoc index 92fa0a42762b0..a86f488f8ef5b 100644 --- a/docs/reference/data-frames/apis/put-transform.asciidoc +++ b/docs/reference/data-frames/apis/put-transform.asciidoc @@ -110,7 +110,7 @@ PUT _data_frame/transforms/ecommerce_transform } -------------------------------------------------- // CONSOLE -// TEST[skip: https://github.com/elastic/elasticsearch/issues/43271] +// TEST[setup:kibana_sample_data_ecommerce] When the transform is created, you receive the following results: [source,js] diff --git a/docs/reference/ml/apis/put-job.asciidoc b/docs/reference/ml/apis/put-job.asciidoc index d7069dac6736b..dd32bb108d784 100644 --- a/docs/reference/ml/apis/put-job.asciidoc +++ b/docs/reference/ml/apis/put-job.asciidoc @@ -120,7 +120,6 @@ PUT _ml/anomaly_detectors/total-requests } -------------------------------------------------- // CONSOLE -// TEST[skip: https://github.com/elastic/elasticsearch/issues/43271] When the job is created, you receive the following results: [source,js] diff --git a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java index e87df16264e94..ffdabd6d63399 100644 --- a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java +++ b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.xcontent.XContentLocation; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; +import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ClientYamlDocsTestClient; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestClient; @@ -41,6 +42,7 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec; import org.elasticsearch.test.rest.yaml.section.ExecutableSection; +import org.junit.After; import java.io.IOException; import java.util.ArrayList; @@ -97,6 +99,23 @@ protected ClientYamlTestClient initClientYamlTestClient( return new ClientYamlDocsTestClient(restSpec, restClient, hosts, esVersion, masterVersion, this::getClientBuilderWithSniffedHosts); } + @After + public void cleanup() throws Exception { + if (isMachineLearningTest() || isDataFrameTest()) { + ESRestTestCase.waitForPendingTasks(adminClient()); + } + } + + protected boolean isMachineLearningTest() { + String testName = getTestName(); + return testName != null && (testName.contains("/ml/") || testName.contains("\\ml\\")); + } + + protected boolean isDataFrameTest() { + String testName = getTestName(); + return testName != null && (testName.contains("/data-frames/") || testName.contains("\\data-frames\\")); + } + /** * Compares the results of running two analyzers against many random * strings. The goal is to figure out if two anlayzers are "the same" by