From e13468bc81d435bd5b64ec34ba713e09bdbdcff6 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Thu, 11 Feb 2021 16:39:32 -0600 Subject: [PATCH 01/32] refactor --- .../transform/feature/FeatureInjector.java | 133 +++++++ .../rest/transform/headers/InjectHeaders.java | 103 +----- .../transform/feature/InjectFeatureTests.java | 278 ++++++++++++++ .../transform/header/InjectHeaderTests.java | 342 +++--------------- .../feature/with_feature_predefined.yml | 11 + .../feature/with_multiple_feature.yml | 13 + .../feature/with_setup_no_feature.yml | 13 + .../transform/feature/with_setup_no_skip.yml | 13 + .../transform/feature/with_single_feature.yml | 11 + .../rest/transform/feature/without_setup.yml | 7 + .../rest/transform/header/no_setup.yml | 64 ---- .../header/with_existing_headers.yml | 9 + .../rest/transform/header/with_features.yml | 25 -- .../rest/transform/header/with_headers.yml | 301 --------------- .../rest/transform/header/with_setup.yml | 102 ------ .../rest/transform/header/with_skip.yml | 63 ---- .../header/without_existing_headers.yml | 7 + 17 files changed, 548 insertions(+), 947 deletions(-) create mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java create mode 100644 buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java create mode 100644 buildSrc/src/test/resources/rest/transform/feature/with_feature_predefined.yml create mode 100644 buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml create mode 100644 buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml create mode 100644 buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml create mode 100644 buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml create mode 100644 buildSrc/src/test/resources/rest/transform/feature/without_setup.yml delete mode 100644 buildSrc/src/test/resources/rest/transform/header/no_setup.yml create mode 100644 buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml delete mode 100644 buildSrc/src/test/resources/rest/transform/header/with_features.yml delete mode 100644 buildSrc/src/test/resources/rest/transform/header/with_headers.yml delete mode 100644 buildSrc/src/test/resources/rest/transform/header/with_setup.yml delete mode 100644 buildSrc/src/test/resources/rest/transform/header/with_skip.yml create mode 100644 buildSrc/src/test/resources/rest/transform/header/without_existing_headers.yml diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java new file mode 100644 index 0000000000000..1171ac52efdcf --- /dev/null +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java @@ -0,0 +1,133 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.feature; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransformGlobalSetup; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransformGlobalTeardown; + +import javax.annotation.Nullable; +import java.util.Iterator; + +/** + * A parent class for transformations that are backed by a feature. This will inject the necessary "feature" into the + * global setup and teardown section. See also org.elasticsearch.test.rest.yaml.Features for a list of possible features. + */ +public abstract class FeatureInjector implements RestTestTransformGlobalSetup, RestTestTransformGlobalTeardown { + + private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); + + @Override + public ObjectNode transformSetup(ObjectNode setupNodeParent) { + // check to ensure that headers feature does not already exist + if (setupNodeParent != null) { + ArrayNode setupNode = (ArrayNode) setupNodeParent.get("setup"); + if (hasHeadersFeature(setupNode)) { + return setupNodeParent; + } + } + // transform or insert the headers feature into setup/skip/features + ArrayNode setupNode; + if (setupNodeParent == null) { + setupNodeParent = new ObjectNode(jsonNodeFactory); + setupNode = new ArrayNode(jsonNodeFactory); + setupNodeParent.set("setup", setupNode); + } + setupNode = (ArrayNode) setupNodeParent.get("setup"); + addSkip(setupNode); + return setupNodeParent; + } + + @Override + public ObjectNode transformTeardown(@Nullable ObjectNode teardownNodeParent) { + if (teardownNodeParent != null) { + ArrayNode teardownNode = (ArrayNode) teardownNodeParent.get("teardown"); + // only transform an existing teardown section since a teardown does not inherit from setup but still needs the skip section + if (teardownNode != null) { + // check to ensure that headers feature does not already exist + if (hasHeadersFeature(teardownNode)) { + return teardownNodeParent; + } + addSkip(teardownNode); + return teardownNodeParent; + } + } + return teardownNodeParent; + } + + /** + * The name of the feature to skip. These are defined in org.elasticsearch.test.rest.yaml.Features and found in the tests at + * as the value of skip.feature. For example this method should return "allowed_warnings" : + *
+     * skip:
+     *       features: allowed_warnings
+     * 
+ */ + public abstract String getSkipFeatureName(); + + private boolean hasHeadersFeature(ArrayNode skipParent) { + JsonNode features = skipParent.at("/0/skip/features"); + if (features != null) { + if (features.isArray()) { + ArrayNode featuresArray = (ArrayNode) features; + Iterator it = featuresArray.elements(); + while (it.hasNext()) { + if (getSkipFeatureName().equals(it.next().asText())) { + return true; + } + } + } else { + if (getSkipFeatureName().equals(features.asText())) { + return true; + } + } + } + return false; + } + + private void addSkip(ArrayNode skipParent) { + Iterator skipParentIt = skipParent.elements(); + boolean foundSkipNode = false; + while (skipParentIt.hasNext()) { + JsonNode arrayEntry = skipParentIt.next(); + if (arrayEntry.isObject()) { + ObjectNode skipCandidate = (ObjectNode) arrayEntry; + if (skipCandidate.get("skip") != null) { + ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); + foundSkipNode = true; + JsonNode featuresNode = skipNode.get("features"); + if (featuresNode == null) { + skipNode.set("features", TextNode.valueOf(getSkipFeatureName())); + } else if (featuresNode.isArray()) { + ArrayNode featuresNodeArray = (ArrayNode) featuresNode; + featuresNodeArray.add(getSkipFeatureName()); + } else if (featuresNode.isTextual()) { + // convert to an array + ArrayNode featuresNodeArray = new ArrayNode(jsonNodeFactory); + featuresNodeArray.add(featuresNode.asText()); + featuresNodeArray.add(getSkipFeatureName()); + // overwrite the features object + skipNode.set("features", featuresNodeArray); + } + } + } + } + if (foundSkipNode == false) { + ObjectNode skipNode = new ObjectNode(jsonNodeFactory); + ObjectNode featuresNode = new ObjectNode(jsonNodeFactory); + skipParent.insert(0, skipNode); + featuresNode.set("features", TextNode.valueOf(getSkipFeatureName())); + skipNode.set("skip", featuresNode); + } + } +} diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java index e38d922763ed4..756037bf3fd47 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java @@ -8,26 +8,21 @@ package org.elasticsearch.gradle.test.rest.transform.headers; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformGlobalSetup; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformGlobalTeardown; +import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; import org.gradle.api.tasks.Input; -import javax.annotation.Nullable; -import java.util.Iterator; import java.util.Map; /** * A {@link RestTestTransform} that injects HTTP headers into a REST test. This includes adding the necessary values to the "do" section * as well as adding headers as a features to the "setup" and "teardown" sections. */ -public class InjectHeaders implements RestTestTransformByParentObject, RestTestTransformGlobalSetup, RestTestTransformGlobalTeardown { +public class InjectHeaders extends FeatureInjector implements RestTestTransformByParentObject { private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); @@ -59,98 +54,8 @@ public String getKeyToFind() { } @Override - public ObjectNode transformSetup(ObjectNode setupNodeParent) { - // check to ensure that headers feature does not already exist - if (setupNodeParent != null) { - ArrayNode setupNode = (ArrayNode) setupNodeParent.get("setup"); - if (hasHeadersFeature(setupNode)) { - return setupNodeParent; - } - } - // transform or insert the headers feature into setup/skip/features - ArrayNode setupNode; - if (setupNodeParent == null) { - setupNodeParent = new ObjectNode(jsonNodeFactory); - setupNode = new ArrayNode(jsonNodeFactory); - setupNodeParent.set("setup", setupNode); - } - setupNode = (ArrayNode) setupNodeParent.get("setup"); - addSkip(setupNode); - return setupNodeParent; - } - - @Override - public ObjectNode transformTeardown(@Nullable ObjectNode teardownNodeParent) { - if (teardownNodeParent != null) { - ArrayNode teardownNode = (ArrayNode) teardownNodeParent.get("teardown"); - // only transform an existing teardown section since a teardown does not inherit from setup but still needs the skip section - if (teardownNode != null) { - // check to ensure that headers feature does not already exist - if (hasHeadersFeature(teardownNode)) { - return teardownNodeParent; - } - addSkip(teardownNode); - return teardownNodeParent; - } - } - return teardownNodeParent; - } - - private boolean hasHeadersFeature(ArrayNode skipParent) { - JsonNode features = skipParent.at("/0/skip/features"); - if (features != null) { - if (features.isArray()) { - ArrayNode featuresArray = (ArrayNode) features; - Iterator it = featuresArray.elements(); - while (it.hasNext()) { - if ("headers".equals(it.next().asText())) { - return true; - } - } - } else { - if ("headers".equals(features.asText())) { - return true; - } - } - } - return false; - } - - private void addSkip(ArrayNode skipParent) { - Iterator skipParentIt = skipParent.elements(); - boolean foundSkipNode = false; - while (skipParentIt.hasNext()) { - JsonNode arrayEntry = skipParentIt.next(); - if (arrayEntry.isObject()) { - ObjectNode skipCandidate = (ObjectNode) arrayEntry; - if (skipCandidate.get("skip") != null) { - ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); - foundSkipNode = true; - JsonNode featuresNode = skipNode.get("features"); - if (featuresNode == null) { - ObjectNode featuresNodeObject = new ObjectNode(jsonNodeFactory); - skipNode.set("features", TextNode.valueOf("headers")); - } else if (featuresNode.isArray()) { - ArrayNode featuresNodeArray = (ArrayNode) featuresNode; - featuresNodeArray.add("headers"); - } else if (featuresNode.isTextual()) { - // convert to an array - ArrayNode featuresNodeArray = new ArrayNode(jsonNodeFactory); - featuresNodeArray.add(featuresNode.asText()); - featuresNodeArray.add("headers"); - // overwrite the features object - skipNode.set("features", featuresNodeArray); - } - } - } - } - if (foundSkipNode == false) { - ObjectNode skipNode = new ObjectNode(jsonNodeFactory); - ObjectNode featuresNode = new ObjectNode(jsonNodeFactory); - skipParent.insert(0, skipNode); - featuresNode.set("features", TextNode.valueOf("headers")); - skipNode.set("skip", featuresNode); - } + public String getSkipFeatureName() { + return "headers"; } @Input diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java new file mode 100644 index 0000000000000..9366c3f1cb91b --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java @@ -0,0 +1,278 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.feature; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.SequenceWriter; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLParser; +import org.elasticsearch.gradle.test.GradleUnitTestCase; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; +import org.hamcrest.CoreMatchers; +import org.hamcrest.core.IsCollectionContaining; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class InjectFeatureTests extends GradleUnitTestCase { + + private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); + private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); + private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); + + private static final Map headers1 = Map.of("foo", "bar"); + private static final Map headers2 = Map.of("abc", "xyz"); + RestTestTransformer transformer; + + @Before + public void setup() { + transformer = new RestTestTransformer(); + } + + /** + * test file does not have a setup + */ + @Test + public void testInjectFeatureWithoutSetup() throws Exception { + String testName = "/rest/transform/feature/without_setup.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + } + + /** + * test file has a single feature + */ + @Test + public void testInjectFeatureWithSinglePreexistingFeature() throws Exception { + String testName = "/rest/transform/feature/with_single_feature.yml"; + List tests = getTests(testName); + validateSetupExist(tests); + validatePreExistingFeatureExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + } + + /** + * test file has multiple feature + */ + @Test + public void testInjectFeatureWithMultiplePreexistingFeature() throws Exception { + String testName = "/rest/transform/feature/with_multiple_feature.yml"; + List tests = getTests(testName); + validateSetupExist(tests); + validatePreExistingFeatureExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + } + + /** + * test file has a setup, but no skip (and by inference no feature) + */ + @Test + public void testInjectFeatureWithSetupNoSkip() throws Exception { + String testName = "/rest/transform/feature/with_setup_no_skip.yml"; + List tests = getTests(testName); + validateSetupExist(tests); + validateSkipNodesDoesNotExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + } + + /** + * test file has a setup, a skip section, but no features + */ + @Test + public void testInjectFeatureWithSetupWithSkipNoFeature() throws Exception { + String testName = "/rest/transform/feature/with_setup_no_feature.yml"; + List tests = getTests(testName); + validateSetupExist(tests); + validateSkipNodesExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + } + + /** + * test file has a single feature + */ + @Test + public void testInjectFeatureWithFeatureAlreadyDefined() throws Exception { + String testName = "/rest/transform/feature/with_feature_predefined.yml"; + List tests = getTests(testName); + validateSetupExist(tests); + validatePreExistingFeatureExist(tests); + validateFeatureNameExists(tests, "headers"); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + } + + protected void validateSetupAndTearDown(List transformedTests) { + assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); + transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); + transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); + } + + protected ObjectNode validateSkipNodesExist(List tests) { + List skipNodes = tests.stream() + .filter(node -> node.get("setup") != null) + .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) + .map(node -> getSkipNode((ArrayNode) node.get("setup"))) + .collect(Collectors.toList()); + assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); + return skipNodes.get(0); + } + + protected void validateSkipNodesDoesNotExist(List tests) { + List skipNodes = tests.stream() + .filter(node -> node.get("setup") != null) + .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) + .map(node -> getSkipNode((ArrayNode) node.get("setup"))) + .collect(Collectors.toList()); + assertThat(skipNodes.size(), CoreMatchers.equalTo(0)); + } + + protected void validatePreExistingFeatureExist(List tests) { + assertThat(validateSkipNodesExist(tests).get("features"), CoreMatchers.notNullValue()); + } + + protected void validateSetupDoesNotExist(List tests) { + assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(0L)); + } + + protected void validateFeatureNameExists(List tests, String featureName) { + ObjectNode skipNode = validateSkipNodesExist(tests); + JsonNode featureValues = skipNode.get("features"); + assertNotNull(featureValues); + + List features = new ArrayList<>(1); + if (featureValues.isArray()) { + Iterator featuresIt = featureValues.elements(); + while (featuresIt.hasNext()) { + JsonNode feature = featuresIt.next(); + features.add(feature.asText()); + } + } else if (featureValues.isTextual()) { + features.add(featureValues.asText()); + } + + assertThat(features, IsCollectionContaining.hasItem(featureName)); + } + + protected void validateSetupExist(List tests) { + assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); + } + + protected List transformTests(List tests) { + List t = transformer.transformRestTests(new LinkedList<>(tests), getTransformations()); + getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); + return t; + } + + protected List getKnownFeatures() { + return Collections.singletonList("headers"); + } + + protected List> getTransformations() { + List> transformations = new ArrayList<>(); + transformations.add(new InjectHeaders(headers1)); + transformations.add(new InjectHeaders(headers2)); + return transformations; + } + + protected List getTests(String relativePath) throws Exception { + String testName = relativePath; + File testFile = new File(getClass().getResource(testName).toURI()); + YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); + return READER.readValues(yamlParser).readAll(); + } + + protected void assertTeardown(ObjectNode teardownNode) { + assertThat(teardownNode.get("teardown"), CoreMatchers.instanceOf(ArrayNode.class)); + ObjectNode skipNode = getSkipNode((ArrayNode) teardownNode.get("teardown")); + assertSkipNode(skipNode); + } + + protected void assertSetup(ObjectNode setupNode) { + assertThat(setupNode.get("setup"), CoreMatchers.instanceOf(ArrayNode.class)); + ObjectNode skipNode = getSkipNode((ArrayNode) setupNode.get("setup")); + assertSkipNode(skipNode); + } + + protected void assertSkipNode(ObjectNode skipNode) { + assertThat(skipNode, CoreMatchers.notNullValue()); + List featureValues = new ArrayList<>(); + if (skipNode.get("features").isArray()) { + assertThat(skipNode.get("features"), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode features = (ArrayNode) skipNode.get("features"); + features.forEach(x -> { + if (x.isTextual()) { + featureValues.add(x.asText()); + } + }); + } else { + featureValues.add(skipNode.get("features").asText()); + } + assertEquals(featureValues.stream().distinct().count(), featureValues.size()); + } + + protected ObjectNode getSkipNode(ArrayNode setupNodeValue) { + Iterator setupIt = setupNodeValue.elements(); + while (setupIt.hasNext()) { + JsonNode arrayEntry = setupIt.next(); + if (arrayEntry.isObject()) { + ObjectNode skipCandidate = (ObjectNode) arrayEntry; + if (skipCandidate.get("skip") != null) { + ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); + return skipNode; + } + } + } + return null; + } + + protected boolean getHumanDebug() { + return false; + } + + // only to help manually debug + protected void printTest(String testName, List tests) { + if (getHumanDebug()) { + System.out.println("\n************* " + testName + " *************"); + try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { + for (ObjectNode transformedTest : tests) { + sequenceWriter.write(transformedTest); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java index a3ec8cb550237..1434ec3a2bc44 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java @@ -9,37 +9,22 @@ package org.elasticsearch.gradle.test.rest.transform.header; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; +import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; import org.hamcrest.CoreMatchers; -import org.hamcrest.core.IsCollectionContaining; import org.junit.Test; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.LongAdder; -import java.util.stream.Collectors; -public class InjectHeaderTests extends GradleUnitTestCase { - - private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); - private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); +public class InjectHeaderTests extends InjectFeatureTests { private static final Map headers = Map.of( "Content-Type", @@ -47,306 +32,77 @@ public class InjectHeaderTests extends GradleUnitTestCase { "Accept", "application/vnd.elasticsearch+json;compatible-with=7" ); - private static final boolean humanDebug = false; // useful for humans trying to debug these tests /** - * test file does not have setup: block + * test file does not any headers defined */ @Test - public void testInjectHeadersWithoutSetupBlock() throws Exception { - String testName = "/rest/transform/header/no_setup.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); - // validate no setup - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(0L)); - - List transformedTests = transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new InjectHeaders(headers)) - ); + public void testInjectHeadersNoPreExisting() throws Exception { + String testName = "/rest/transform/header/without_existing_headers.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + List transformedTests = transformTests(tests); printTest(testName, transformedTests); - // ensure setup is correct - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - // ensure do body is correct - transformedTests.forEach(test -> { - Iterator> testsIterator = test.fields(); - while (testsIterator.hasNext()) { - Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - assertTestBodyForHeaders(testBody, headers); - } - }); + validateSetupAndTearDown(transformedTests); + validateBodyHasHeaders(transformedTests, headers); } /** - * test file has a setup: block, but no relevant children + * test file has preexisting headers */ @Test - public void testInjectHeadersWithSetupBlock() throws Exception { - String testName = "/rest/transform/header/with_setup.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); - - // validate setup exists - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - - List transformedTests = transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new InjectHeaders(headers)) - ); + public void testInjectHeadersWithPreExisting() throws Exception { + String testName = "/rest/transform/header/with_existing_headers.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + validateBodyHasHeaders(tests, Map.of("foo", "bar")); + List transformedTests = transformTests(tests); printTest(testName, transformedTests); - // ensure setup is correct - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - // ensure do body is correct - transformedTests.forEach(test -> { - Iterator> testsIterator = test.fields(); - while (testsIterator.hasNext()) { - Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - assertTestBodyForHeaders(testBody, headers); - } - }); + validateSetupAndTearDown(transformedTests); + validateBodyHasHeaders(tests, Map.of("foo", "bar")); + validateBodyHasHeaders(transformedTests, headers); } - /** - * test file has a setup: then skip: but does not have the features: block - */ - @Test - public void testInjectHeadersWithSkipBlock() throws Exception { - String testName = "/rest/transform/header/with_skip.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); - - // validate setup exists - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - - // validate skip node exists - assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); - // validate features does not exists - assertNull(skipNodes.get(0).get("features")); - - List transformedTests = transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new InjectHeaders(headers)) - ); - printTest(testName, transformedTests); - // ensure setup is correct - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - - // ensure do body is correct - transformedTests.forEach(test -> { - Iterator> testsIterator = test.fields(); - while (testsIterator.hasNext()) { - Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - assertTestBodyForHeaders(testBody, headers); - } - }); + @Override + protected List getKnownFeatures() { + return Collections.singletonList("headers"); } - /** - * test file has a setup: then skip:, then features: block , but does not have the headers feature defined - */ - @Test - public void testInjectHeadersWithFeaturesBlock() throws Exception { - String testName = "/rest/transform/header/with_features.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); - - // validate setup exists - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - - // validate skip node exists - assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); - // validate features exists - assertThat(skipNodes.get(0).get("features"), CoreMatchers.notNullValue()); - - List transformedTests = transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new InjectHeaders(headers)) - ); - printTest(testName, transformedTests); - // ensure setup is correct - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - // ensure do body is correct - transformedTests.forEach(test -> { - Iterator> testsIterator = test.fields(); - while (testsIterator.hasNext()) { - Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - assertTestBodyForHeaders(testBody, headers); - } - }); + @Override + protected List> getTransformations() { + return Collections.singletonList(new InjectHeaders(headers)); } - /** - * test file has a setup: then skip:, then features: block , and already has the headers feature defined - */ - @Test - public void testInjectHeadersWithHeadersBlock() throws Exception { - String testName = "/rest/transform/header/with_headers.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); - - // validate setup exists - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - - // validate skip node exists - assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); - // validate features exists - assertThat(skipNodes.get(0).get("features"), CoreMatchers.notNullValue()); - - JsonNode featureValues = skipNodes.get(0).get("features"); - List features = new ArrayList<>(1); - if (featureValues.isArray()) { - Iterator featuresIt = featureValues.elements(); - while (featuresIt.hasNext()) { - JsonNode feature = featuresIt.next(); - features.add(feature.asText()); - } - } else if (featureValues.isTextual()) { - features.add(featureValues.asText()); - } - // validate that features block has a headers value - assertThat(features, IsCollectionContaining.hasItem("headers")); + @Override + protected boolean getHumanDebug() { + return false; + } - List transformedTests = transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new InjectHeaders(headers)) - ); - printTest(testName, transformedTests); - // ensure setup is correct - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - // ensure do body is correct - transformedTests.forEach(test -> { + private void validateBodyHasHeaders(List tests, Map headers) { + tests.forEach(test -> { Iterator> testsIterator = test.fields(); while (testsIterator.hasNext()) { Map.Entry testObject = testsIterator.next(); assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode testBody = (ArrayNode) testObject.getValue(); - assertTestBodyForHeaders(testBody, headers); - } - }); - } - - private void assertTestBodyForHeaders(ArrayNode testBody, Map headers) { - testBody.forEach(arrayObject -> { - assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode testSection = (ObjectNode) arrayObject; - if (testSection.get("do") != null) { - ObjectNode doSection = (ObjectNode) testSection.get("do"); - assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); - ObjectNode headersNode = (ObjectNode) doSection.get("headers"); - LongAdder assertions = new LongAdder(); - headers.forEach((k, v) -> { - assertThat(headersNode.get(k), CoreMatchers.notNullValue()); - TextNode textNode = (TextNode) headersNode.get(k); - assertThat(textNode.asText(), CoreMatchers.equalTo(v)); - assertions.increment(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); + ObjectNode headersNode = (ObjectNode) doSection.get("headers"); + LongAdder assertions = new LongAdder(); + headers.forEach((k, v) -> { + assertThat(headersNode.get(k), CoreMatchers.notNullValue()); + TextNode textNode = (TextNode) headersNode.get(k); + assertThat(textNode.asText(), CoreMatchers.equalTo(v)); + assertions.increment(); + }); + assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); + } }); - assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); } }); } - - private void assertTeardown(ObjectNode teardownNode) { - assertThat(teardownNode.get("teardown"), CoreMatchers.instanceOf(ArrayNode.class)); - ObjectNode skipNode = getSkipNode((ArrayNode) teardownNode.get("teardown")); - assertSkipNode(skipNode); - } - - private void assertSetup(ObjectNode setupNode) { - assertThat(setupNode.get("setup"), CoreMatchers.instanceOf(ArrayNode.class)); - ObjectNode skipNode = getSkipNode((ArrayNode) setupNode.get("setup")); - assertSkipNode(skipNode); - } - - private void assertSkipNode(ObjectNode skipNode) { - assertThat(skipNode, CoreMatchers.notNullValue()); - List featureValues = new ArrayList<>(); - if (skipNode.get("features").isArray()) { - assertThat(skipNode.get("features"), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode features = (ArrayNode) skipNode.get("features"); - features.forEach(x -> { - if (x.isTextual()) { - featureValues.add(x.asText()); - } - }); - } else { - featureValues.add(skipNode.get("features").asText()); - } - assertThat(featureValues, IsCollectionContaining.hasItem("headers")); - assertEquals(featureValues.stream().distinct().count(), featureValues.size()); - } - - private ObjectNode getSkipNode(ArrayNode setupNodeValue) { - Iterator setupIt = setupNodeValue.elements(); - while (setupIt.hasNext()) { - JsonNode arrayEntry = setupIt.next(); - if (arrayEntry.isObject()) { - ObjectNode skipCandidate = (ObjectNode) arrayEntry; - if (skipCandidate.get("skip") != null) { - ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); - return skipNode; - } - } - } - return null; - } - - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } } diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_feature_predefined.yml b/buildSrc/src/test/resources/rest/transform/feature/with_feature_predefined.yml new file mode 100644 index 0000000000000..de13364636b99 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/feature/with_feature_predefined.yml @@ -0,0 +1,11 @@ +--- +setup: + - skip: + features: headers +--- +"Test without with single feature setup": + - do: + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml b/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml new file mode 100644 index 0000000000000..948adc2f3500b --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml @@ -0,0 +1,13 @@ +--- +setup: + - skip: + features: + - pre_existing_feature1 + - pre_existing_feature2 +--- +"Test without with multiple feature setup": + - do: + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml new file mode 100644 index 0000000000000..b58b68a3d2160 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml @@ -0,0 +1,13 @@ +--- +setup: + - skip: + version: " - 7.1.99" + reason: why not +--- +"Test without with setup and skip but no feature": + - do: + something: + id: "something" + - match: { acknowledged: true } + + diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml new file mode 100644 index 0000000000000..17146614e83a2 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml @@ -0,0 +1,13 @@ +--- +setup: + - do: + some.setup: + index: blah +--- +"Test without with setup but no skip (and by inference no features)": + - do: + something: + id: "something" + - match: { acknowledged: true } + + diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml b/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml new file mode 100644 index 0000000000000..36ab3cd44bc49 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml @@ -0,0 +1,11 @@ +--- +setup: + - skip: + features: pre_existing_feature +--- +"Test without with single feature setup": + - do: + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/feature/without_setup.yml b/buildSrc/src/test/resources/rest/transform/feature/without_setup.yml new file mode 100644 index 0000000000000..4c414c847308f --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/feature/without_setup.yml @@ -0,0 +1,7 @@ +--- +"Test without a setup": + - do: + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/header/no_setup.yml b/buildSrc/src/test/resources/rest/transform/header/no_setup.yml deleted file mode 100644 index 9142317ce1507..0000000000000 --- a/buildSrc/src/test/resources/rest/transform/header/no_setup.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -teardown: - - do: - ingest.delete_pipeline: - id: "my_pipeline" - ignore: 404 - ---- -"Test foreach Processor": - - do: - ingest.put_pipeline: - id: "my_pipeline" - body: > - { - "description": "_description", - "processors": [ - { - "foreach" : { - "field" : "values", - "processor" : { - "uppercase" : { - "field" : "_ingest._value" - } - } - } - } - ] - } - - match: { acknowledged: true } - - - do: - index: - index: test - id: 1 - pipeline: "my_pipeline" - body: > - { - "values": ["foo", "bar", "baz"] - } - - - do: - get: - index: test - id: 1 - - match: { _source.values: ["FOO", "BAR", "BAZ"] } - - #exceeds the recurse max per thread and will runs some of these on a different thread - - do: - index: - index: test - id: 1 - pipeline: "my_pipeline" - body: > - { - "values": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", - "v", "w", "x", "y", "z"] - } - - - do: - get: - index: test - id: 1 - - match: { _source.values: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", - "V", "W", "X", "Y", "Z"] } diff --git a/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml new file mode 100644 index 0000000000000..ee58986ba8ec0 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml @@ -0,0 +1,9 @@ +--- +"Test without a setup": + - do: + headers: + foo: "bar" + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/header/with_features.yml b/buildSrc/src/test/resources/rest/transform/header/with_features.yml deleted file mode 100644 index 1ff5bfc40ce14..0000000000000 --- a/buildSrc/src/test/resources/rest/transform/header/with_features.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -setup: - - skip: - features: allowed_warnings - - - do: - cluster.health: - wait_for_status: yellow - ---- -"Test inline template against specific index": - - do: - search_template: - rest_total_hits_as_int: true - index: foobar - body: - source: - query: - match: - title: "{{query_string}}" - params: - query_string: "search for these words" - - - match: { hits.total: 1} - - match: { hits.hits.0._id: "1"} diff --git a/buildSrc/src/test/resources/rest/transform/header/with_headers.yml b/buildSrc/src/test/resources/rest/transform/header/with_headers.yml deleted file mode 100644 index be970f0d59cf9..0000000000000 --- a/buildSrc/src/test/resources/rest/transform/header/with_headers.yml +++ /dev/null @@ -1,301 +0,0 @@ ---- -setup: - - skip: - features: headers - - - do: - cluster.health: - wait_for_status: yellow - - do: - security.put_user: - username: "joe" - body: > - { - "password": "s3krit-password", - "roles" : [ "x_cluster_role" ] - } - - do: - security.put_role: - name: "x_cluster_role" - body: > - { - "cluster": ["monitor"], - "indices": [ - { - "names": ["single_doc_index", "secure_alias", "test_index", "aliased_test_index", "field_caps_index_1", - "field_caps_index_3", "point_in_time_index"], - "privileges": ["read", "read_cross_cluster"] - } - ] - } - - - do: - security.put_user: - username: "remote" - body: > - { - "password": "s3krit-password", - "roles" : [ "remote_ccs" ] - } - - do: - security.put_role: - name: "remote_ccs" - body: > - { - "cluster": ["monitor"], - "indices": [ - { - "names": ["single_doc_index", "secure_alias", "test_index", "aliased_test_index", "field_caps_index_1", - "field_caps_index_3", "point_in_time_index"], - "privileges": ["read", "read_cross_cluster"] - } - ] - } ---- -"Index data and search on the remote cluster": - - skip: - features: allowed_warnings - - - do: - allowed_warnings: - - "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation" - indices.put_index_template: - name: my-template1 - body: - index_patterns: [simple-data-stream1] - template: - mappings: - properties: - '@timestamp': - type: date - data_stream: {} - - - do: - allowed_warnings: - - "index template [my-template2] has index patterns [simple-data-stream2] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template2] will take precedence during new index creation" - indices.put_index_template: - name: my-template2 - body: - index_patterns: [simple-data-stream2] - template: - mappings: - properties: - '@timestamp': - type: date - data_stream: {} - - - do: - indices.create_data_stream: - name: simple-data-stream1 - - - do: - indices.create_data_stream: - name: simple-data-stream2 - - - do: - indices.rollover: - alias: "simple-data-stream2" - - - do: - indices.create: - index: closed_index - body: - aliases: - aliased_closed_index: {} - - - do: - indices.close: - index: closed_index - - - do: - indices.create: - index: single_doc_index - body: - settings: - index: - number_of_shards: 1 - number_of_replicas: 0 - mappings: - properties: - created_at: - type: date - format: "yyyy-MM-dd" - - - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "remote_cluster", "sort_field": 1, "created_at" : "2016-01-01"}' - - - do: - indices.create: - index: field_caps_index_1 - body: - mappings: - properties: - text: - type: text - keyword: - type: keyword - number: - type: double - geo: - type: geo_point - object: - type: object - properties: - nested1 : - type : text - index: false - nested2: - type: float - doc_values: false - - do: - indices.create: - index: field_caps_index_3 - body: - mappings: - properties: - text: - type: text - keyword: - type: keyword - number: - type: long - geo: - type: keyword - object: - type: object - properties: - nested1 : - type : long - index: false - nested2: - type: keyword - doc_values: false - - - do: - indices.create: - index: test_index - body: - settings: - index: - number_of_shards: 3 - number_of_replicas: 0 - aliases: - aliased_test_index: # we use this alias in the multi cluster test to verify filtered aliases work - filter: - term: - filter_field : 1 - - do: - indices.create: - index: secured_via_alias - body: - settings: - index: - number_of_shards: 2 - number_of_replicas: 0 - aliases: - secure_alias: {} # we use this alias in the multi cluster test to verify permissions via aliases work - - - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "test_index"}}' - - '{"f1": "remote_cluster", "filter_field": 0}' - - '{"index": {"_index": "test_index"}}' - - '{"f1": "remote_cluster", "filter_field": 1}' - - '{"index": {"_index": "test_index"}}' - - '{"f1": "remote_cluster", "filter_field": 0}' - - '{"index": {"_index": "test_index"}}' - - '{"f1": "remote_cluster", "filter_field": 1}' - - '{"index": {"_index": "test_index"}}' - - '{"f1": "remote_cluster", "filter_field": 0}' - - '{"index": {"_index": "test_index"}}' - - '{"f1": "remote_cluster", "filter_field": 0}' - - '{"index": {"_index": "secured_via_alias"}}' - - '{"f1": "remote_cluster", "secure": true}' - - - - do: - headers: { Authorization: "Basic am9lOnMza3JpdC1wYXNzd29yZA==" } - search: - rest_total_hits_as_int: true - index: test_index - body: - aggs: - cluster: - terms: - field: f1.keyword - - - match: { _shards.total: 3 } - - match: { hits.total: 6 } - - length: { aggregations.cluster.buckets: 1 } - - match: { aggregations.cluster.buckets.0.key: "remote_cluster" } - - match: { aggregations.cluster.buckets.0.doc_count: 6 } - - - do: - headers: { Authorization: "Basic am9lOnMza3JpdC1wYXNzd29yZA==" } - search: - rest_total_hits_as_int: true - index: aliased_test_index - - - match: { _shards.total: 3 } - - match: { hits.total: 2 } - - match: { hits.hits.0._source.filter_field: 1 } - - match: { hits.hits.0._index: "test_index" } - - - do: - headers: { Authorization: "Basic am9lOnMza3JpdC1wYXNzd29yZA==" } - search: - rest_total_hits_as_int: true - index: secure_alias - - - match: { _shards.total: 2 } - - match: { hits.total: 1 } - - is_true: hits.hits.0._source.secure - - match: { hits.hits.0._index: "secured_via_alias" } - - # The user is updated to remove its role mappings to show that we do not - # need the user to be assigned to a role on the remote cluster and that the - # roles sent with the user from the other cluster are used. The put user - # request clears the cached reference to the user so we do not need to do - # that manually - - do: - security.put_user: - username: "joe" - body: > - { - "password": "s3krit-password", - "roles" : [ ] - } - - match: { created: false } - - - do: - indices.create: - index: point_in_time_index - body: - settings: - index: - number_of_shards: 2 - number_of_replicas: 0 - mappings: - properties: - created_at: - type: date - format: "yyyy-MM-dd" - - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "point_in_time_index"}}' - - '{"f": "r1", "created_at" : "2020-01-01"}' - - '{"index": {"_index": "point_in_time_index"}}' - - '{"f": "r2", "created_at" : "2020-01-02"}' - - '{"index": {"_index": "point_in_time_index"}}' - - '{"f": "r3", "created_at" : "2020-01-03"}' - - '{"index": {"_index": "point_in_time_index"}}' - - '{"f": "r4", "created_at" : "2020-01-04"}' - diff --git a/buildSrc/src/test/resources/rest/transform/header/with_setup.yml b/buildSrc/src/test/resources/rest/transform/header/with_setup.yml deleted file mode 100644 index 972c65db3225a..0000000000000 --- a/buildSrc/src/test/resources/rest/transform/header/with_setup.yml +++ /dev/null @@ -1,102 +0,0 @@ ---- -setup: - - do: - indices.create: - index: single_doc_index - body: - settings: - index: - number_of_shards: 1 - number_of_replicas: 0 ---- -teardown: - - do: - indices.delete: - index: single_doc_index - ignore_unavailable: true - ---- -"Test that queries on _index match against the correct indices.": - - - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' - - - do: - search: - rest_total_hits_as_int: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - body: - query: - term: - "_index": "single_doc_index" - - - match: { hits.total: 1 } - - match: { hits.hits.0._index: "single_doc_index"} - - match: { _shards.total: 2 } - - match: { _shards.successful: 2 } - - match: { _shards.skipped : 0} - - match: { _shards.failed: 0 } - - - do: - search: - rest_total_hits_as_int: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - body: - query: - term: - "_index": "my_remote_cluster:single_doc_index" - - - match: { hits.total: 1 } - - match: { hits.hits.0._index: "my_remote_cluster:single_doc_index"} - - match: { _shards.total: 2 } - - match: { _shards.successful: 2 } - - match: { _shards.skipped : 0} - - match: { _shards.failed: 0 } - ---- -"Test that queries on _index that don't match are skipped": - - - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' - - - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "does_not_match" - - - match: { hits.total.value: 0 } - - match: { _shards.total: 2 } - - match: { _shards.successful: 2 } - - match: { _shards.skipped : 1} - - match: { _shards.failed: 0 } - - - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "my_remote_cluster:does_not_match" - - - match: { hits.total.value: 0 } - - match: { _shards.total: 2 } - - match: { _shards.successful: 2 } - - match: { _shards.skipped : 1} - - match: { _shards.failed: 0 } diff --git a/buildSrc/src/test/resources/rest/transform/header/with_skip.yml b/buildSrc/src/test/resources/rest/transform/header/with_skip.yml deleted file mode 100644 index 0ea9d3de00926..0000000000000 --- a/buildSrc/src/test/resources/rest/transform/header/with_skip.yml +++ /dev/null @@ -1,63 +0,0 @@ -setup: - - skip: - version: " - 7.1.99" - reason: calendar_interval introduced in 7.2.0 - - - do: - indices.create: - index: test_date_hist - body: - settings: - # There was a BWC issue that only showed up on empty shards. This - # test has 4 docs and 5 shards makes sure we get one empty. - number_of_shards: 5 - mappings: - properties: - range: - type: date_range - - - do: - bulk: - index: test_date_hist - refresh: true - body: - - '{"index": {}}' - - '{"range": {"gte": "2016-01-01", "lt": "2016-01-02"}}' - - '{"index": {}}' - - '{"range": {"gte": "2016-01-02", "lt": "2016-01-03"}}' - - '{"index": {}}' - - '{"range": {"gte": "2016-02-01", "lt": "2016-02-02"}}' - - '{"index": {}}' - - '{"range": {"gte": "2016-03-01", "lt": "2016-03-02"}}' - - '{"index": {}}' - - '{"range": {"gte": "2016-04-01"}}' - - '{"index": {}}' - - '{"range": {"lt": "2016-02-01"}}' - ---- -"date_histogram on range with hard bounds": - - skip: - version: " - 7.9.99" - reason: hard_bounds introduced in 7.10.0 - - - do: - search: - body: - size: 0 - aggs: - histo: - date_histogram: - field: range - calendar_interval: month - hard_bounds: - "min": "2015-06-01" - "max": "2016-06-01" - - - match: { hits.total.value: 6 } - - length: { aggregations.histo.buckets: 13 } - - match: { aggregations.histo.buckets.0.key_as_string: "2015-06-01T00:00:00.000Z" } - - match: { aggregations.histo.buckets.0.doc_count: 1 } - - match: { aggregations.histo.buckets.8.key_as_string: "2016-02-01T00:00:00.000Z" } - - match: { aggregations.histo.buckets.8.doc_count: 1 } - - match: { aggregations.histo.buckets.12.key_as_string: "2016-06-01T00:00:00.000Z" } - - match: { aggregations.histo.buckets.12.doc_count: 1 } diff --git a/buildSrc/src/test/resources/rest/transform/header/without_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/header/without_existing_headers.yml new file mode 100644 index 0000000000000..4c414c847308f --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/header/without_existing_headers.yml @@ -0,0 +1,7 @@ +--- +"Test without a setup": + - do: + something: + id: "something" + - match: { acknowledged: true } + From 3cb7200b13ef7333ee7e95f171c3d2bbc06943ec Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 12 Feb 2021 14:33:41 -0600 Subject: [PATCH 02/32] start of support for allowed_warnings --- .../warnings/InjectAllowedWarnings.java | 53 +++++++++ .../warnings/InjectAllowedWarningsTests.java | 103 ++++++++++++++++++ .../warnings/with_existing_headers.yml | 10 ++ .../warnings/without_existing_headers.yml | 7 ++ 4 files changed, 173 insertions(+) create mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java create mode 100644 buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java create mode 100644 buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml create mode 100644 buildSrc/src/test/resources/rest/transform/warnings/without_existing_headers.yml diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java new file mode 100644 index 0000000000000..8fb3da8d90615 --- /dev/null +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.warnings; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; +import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; + +import java.util.List; + +//TODO +public class InjectAllowedWarnings extends FeatureInjector implements RestTestTransformByParentObject { + + private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); + + private final List allowedWarnings; + + /** + * @param allowedWarnings The allowed warnings to inject + */ + public InjectAllowedWarnings(List allowedWarnings) { + this.allowedWarnings = allowedWarnings; + } + + @Override + public void transformTest(ObjectNode doNodeParent) { + ObjectNode doNodeValue = (ObjectNode) doNodeParent.get(getKeyToFind()); + ArrayNode arrayWarnings = (ArrayNode) doNodeValue.get("allowed_warnings"); + if (arrayWarnings == null) { + arrayWarnings = new ArrayNode(jsonNodeFactory); + doNodeValue.set("allowed_warnings", arrayWarnings); + } + allowedWarnings.forEach(arrayWarnings::add); + } + + @Override + public String getKeyToFind() { + return "do"; + } + + @Override + public String getSkipFeatureName() { + return "allowed_warnings"; + } +} diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java new file mode 100644 index 0000000000000..f82bf3a25e810 --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java @@ -0,0 +1,103 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.warnings; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; +import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; +import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; +import org.hamcrest.CoreMatchers; +import org.junit.Test; + +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.LongAdder; + +public class InjectAllowedWarningsTests extends InjectFeatureTests { + +List addWarnings = List.of("added warning"); + + /** + * test file does not any headers defined + */ + @Test + public void testInjectHeadersNoPreExisting() throws Exception { + String testName = "/rest/transform/warnings/without_existing_headers.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + // validateBodyHasHeaders(transformedTests, addWarnings); + } + + /** + * test file has preexisting headers + */ + @Test + public void testInjectHeadersWithPreExisting() throws Exception { + String testName = "/rest/transform/warnings/with_existing_headers.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + //validateBodyHasHeaders(transformedTests, addWarnings); + } + + @Override + protected List getKnownFeatures() { + return Collections.singletonList("allowed_warnings"); + } + + @Override + protected List> getTransformations() { + return Collections.singletonList(new InjectAllowedWarnings(addWarnings)); + } + + @Override + protected boolean getHumanDebug() { + return true; + } + +// private void validateBodyHasHeaders(List tests, Map headers) { +// tests.forEach(test -> { +// Iterator> testsIterator = test.fields(); +// while (testsIterator.hasNext()) { +// Map.Entry testObject = testsIterator.next(); +// assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); +// ArrayNode testBody = (ArrayNode) testObject.getValue(); +// testBody.forEach(arrayObject -> { +// assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); +// ObjectNode testSection = (ObjectNode) arrayObject; +// if (testSection.get("do") != null) { +// ObjectNode doSection = (ObjectNode) testSection.get("do"); +// assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); +// ObjectNode headersNode = (ObjectNode) doSection.get("headers"); +// LongAdder assertions = new LongAdder(); +// headers.forEach((k, v) -> { +// assertThat(headersNode.get(k), CoreMatchers.notNullValue()); +// TextNode textNode = (TextNode) headersNode.get(k); +// assertThat(textNode.asText(), CoreMatchers.equalTo(v)); +// assertions.increment(); +// }); +// assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); +// } +// }); +// } +// }); +// } +} diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml new file mode 100644 index 0000000000000..eadcb161b59ec --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml @@ -0,0 +1,10 @@ +--- +"Test with existing warnings": + - do: + allowed_warnings: + - "a" + - "b" + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/warnings/without_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/warnings/without_existing_headers.yml new file mode 100644 index 0000000000000..681a10576daa8 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/warnings/without_existing_headers.yml @@ -0,0 +1,7 @@ +--- +"Test without any warnings": + - do: + something: + id: "something" + - match: { acknowledged: true } + From 526cdd3670fd94264fb6a53f38db26218e2fcf85 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 12 Feb 2021 15:08:56 -0600 Subject: [PATCH 03/32] start of injectWarning --- .../transform/warnings/InjectWarnings.java | 53 +++++++++++ .../warnings/InjectAllowedWarningsTests.java | 12 +-- .../warnings/InjectWarningsTests.java | 95 +++++++++++++++++++ .../with_existing_allowed_warnings.yml | 10 ++ ...headers.yml => with_existing_warnings.yml} | 2 +- ...ders.yml => without_existing_warnings.yml} | 0 6 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java create mode 100644 buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java create mode 100644 buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml rename buildSrc/src/test/resources/rest/transform/warnings/{with_existing_headers.yml => with_existing_warnings.yml} (85%) rename buildSrc/src/test/resources/rest/transform/warnings/{without_existing_headers.yml => without_existing_warnings.yml} (100%) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java new file mode 100644 index 0000000000000..5d64e23fd3330 --- /dev/null +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.warnings; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; +import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; + +import java.util.List; + +//TODO +public class InjectWarnings extends FeatureInjector implements RestTestTransformByParentObject { + + private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); + + private final List warnings; + + /** + * @param warnings The allowed warnings to inject + */ + public InjectWarnings(List warnings) { + this.warnings = warnings; + } + + @Override + public void transformTest(ObjectNode doNodeParent) { + ObjectNode doNodeValue = (ObjectNode) doNodeParent.get(getKeyToFind()); + ArrayNode arrayWarnings = (ArrayNode) doNodeValue.get("warnings"); + if (arrayWarnings == null) { + arrayWarnings = new ArrayNode(jsonNodeFactory); + doNodeValue.set("warnings", arrayWarnings); + } + warnings.forEach(arrayWarnings::add); + } + + @Override + public String getKeyToFind() { + return "do"; + } + + @Override + public String getSkipFeatureName() { + return "warnings"; + } +} diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java index f82bf3a25e810..5081060e0ac70 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java @@ -8,21 +8,13 @@ package org.elasticsearch.gradle.test.rest.transform.warnings; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; -import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; -import org.hamcrest.CoreMatchers; import org.junit.Test; import java.util.Collections; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.LongAdder; public class InjectAllowedWarningsTests extends InjectFeatureTests { @@ -33,7 +25,7 @@ public class InjectAllowedWarningsTests extends InjectFeatureTests { */ @Test public void testInjectHeadersNoPreExisting() throws Exception { - String testName = "/rest/transform/warnings/without_existing_headers.yml"; + String testName = "/rest/transform/warnings/without_existing_warnings.yml"; List tests = getTests(testName); validateSetupDoesNotExist(tests); List transformedTests = transformTests(tests); @@ -47,7 +39,7 @@ public void testInjectHeadersNoPreExisting() throws Exception { */ @Test public void testInjectHeadersWithPreExisting() throws Exception { - String testName = "/rest/transform/warnings/with_existing_headers.yml"; + String testName = "/rest/transform/warnings/with_existing_allowed_warnings.yml"; List tests = getTests(testName); validateSetupDoesNotExist(tests); // validateBodyHasHeaders(tests, Map.of("foo", "bar")); diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java new file mode 100644 index 0000000000000..69aa7eed6953a --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java @@ -0,0 +1,95 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.warnings; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; +import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; +import org.junit.Test; + +import java.util.Collections; +import java.util.List; + +public class InjectWarningsTests extends InjectFeatureTests { + +List addWarnings = List.of("added warning"); + + /** + * test file does not any headers defined + */ + @Test + public void testInjectHeadersNoPreExisting() throws Exception { + String testName = "/rest/transform/warnings/without_existing_warnings.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + // validateBodyHasHeaders(transformedTests, addWarnings); + } + + /** + * test file has preexisting headers + */ + @Test + public void testInjectHeadersWithPreExisting() throws Exception { + String testName = "/rest/transform/warnings/with_existing_warnings.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + //validateBodyHasHeaders(transformedTests, addWarnings); + } + + @Override + protected List getKnownFeatures() { + return Collections.singletonList("warnings"); + } + + @Override + protected List> getTransformations() { + return Collections.singletonList(new InjectWarnings(addWarnings)); + } + + @Override + protected boolean getHumanDebug() { + return true; + } + +// private void validateBodyHasHeaders(List tests, Map headers) { +// tests.forEach(test -> { +// Iterator> testsIterator = test.fields(); +// while (testsIterator.hasNext()) { +// Map.Entry testObject = testsIterator.next(); +// assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); +// ArrayNode testBody = (ArrayNode) testObject.getValue(); +// testBody.forEach(arrayObject -> { +// assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); +// ObjectNode testSection = (ObjectNode) arrayObject; +// if (testSection.get("do") != null) { +// ObjectNode doSection = (ObjectNode) testSection.get("do"); +// assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); +// ObjectNode headersNode = (ObjectNode) doSection.get("headers"); +// LongAdder assertions = new LongAdder(); +// headers.forEach((k, v) -> { +// assertThat(headersNode.get(k), CoreMatchers.notNullValue()); +// TextNode textNode = (TextNode) headersNode.get(k); +// assertThat(textNode.asText(), CoreMatchers.equalTo(v)); +// assertions.increment(); +// }); +// assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); +// } +// }); +// } +// }); +// } +} diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml new file mode 100644 index 0000000000000..8420520a6d193 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml @@ -0,0 +1,10 @@ +--- +"Test with existing allowed warnings": + - do: + allowed_warnings: + - "a" + - "b" + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml similarity index 85% rename from buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml rename to buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml index eadcb161b59ec..53151e03b4f25 100644 --- a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_headers.yml +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml @@ -1,7 +1,7 @@ --- "Test with existing warnings": - do: - allowed_warnings: + warnings: - "a" - "b" something: diff --git a/buildSrc/src/test/resources/rest/transform/warnings/without_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/warnings/without_existing_warnings.yml similarity index 100% rename from buildSrc/src/test/resources/rest/transform/warnings/without_existing_headers.yml rename to buildSrc/src/test/resources/rest/transform/warnings/without_existing_warnings.yml From 19141dd5c847589609aa81040e3912a025c160d2 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 09:46:02 -0600 Subject: [PATCH 04/32] start remove warning --- .../transform/warnings/RemoveWarnings.java | 61 ++++++++++++ .../warnings/RemoveWarningsTests.java | 95 +++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java create mode 100644 buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java new file mode 100644 index 0000000000000..54a33114c1af9 --- /dev/null +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.warnings; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; +import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +//TODO +//NOTE: this does not remove the features from the setup and/or teardown. while it would be more technically correct to do so, the effort/complexity does not warrant it. +public class RemoveWarnings implements RestTestTransformByParentObject { + + private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); + + private final Set warnings; + + /** + * @param warnings The allowed warnings to inject + */ + public RemoveWarnings(Set warnings) { + this.warnings = warnings; + } + + @Override + public void transformTest(ObjectNode doNodeParent) { + ObjectNode doNodeValue = (ObjectNode) doNodeParent.get(getKeyToFind()); + ArrayNode arrayWarnings = (ArrayNode) doNodeValue.get("warnings"); + if (arrayWarnings == null) { + arrayWarnings = new ArrayNode(jsonNodeFactory); + doNodeValue.set("warnings", arrayWarnings); + } + List keepWarnings = new ArrayList<>(); + arrayWarnings.elements().forEachRemaining(warning -> { + String warningValue = warning.textValue(); + if (warnings.contains(warningValue) == false) { + keepWarnings.add(warningValue); + } + + }); + arrayWarnings.removeAll(); + keepWarnings.forEach(arrayWarnings::add); + } + + @Override + public String getKeyToFind() { + return "do"; + } + +} diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java new file mode 100644 index 0000000000000..33d5c4cc1441d --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java @@ -0,0 +1,95 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform.warnings; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; +import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; +import org.junit.Test; + +import java.util.Collections; +import java.util.List; + +public class RemoveWarningsTests extends InjectFeatureTests { + +List addWarnings = List.of("added warning"); + + /** + * test file does not any headers defined + */ + @Test + public void testInjectHeadersNoPreExisting() throws Exception { + String testName = "/rest/transform/warnings/without_existing_warnings.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + // validateBodyHasHeaders(transformedTests, addWarnings); + } + + /** + * test file has preexisting headers + */ + @Test + public void testInjectHeadersWithPreExisting() throws Exception { + String testName = "/rest/transform/warnings/with_existing_warnings.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + //validateBodyHasHeaders(transformedTests, addWarnings); + } + + @Override + protected List getKnownFeatures() { + return Collections.singletonList("warnings"); + } + + @Override + protected List> getTransformations() { + return Collections.singletonList(new InjectWarnings(addWarnings)); + } + + @Override + protected boolean getHumanDebug() { + return true; + } + +// private void validateBodyHasHeaders(List tests, Map headers) { +// tests.forEach(test -> { +// Iterator> testsIterator = test.fields(); +// while (testsIterator.hasNext()) { +// Map.Entry testObject = testsIterator.next(); +// assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); +// ArrayNode testBody = (ArrayNode) testObject.getValue(); +// testBody.forEach(arrayObject -> { +// assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); +// ObjectNode testSection = (ObjectNode) arrayObject; +// if (testSection.get("do") != null) { +// ObjectNode doSection = (ObjectNode) testSection.get("do"); +// assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); +// ObjectNode headersNode = (ObjectNode) doSection.get("headers"); +// LongAdder assertions = new LongAdder(); +// headers.forEach((k, v) -> { +// assertThat(headersNode.get(k), CoreMatchers.notNullValue()); +// TextNode textNode = (TextNode) headersNode.get(k); +// assertThat(textNode.asText(), CoreMatchers.equalTo(v)); +// assertions.increment(); +// }); +// assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); +// } +// }); +// } +// }); +// } +} From bc7b2aa46fef51085bb1fd0293cb05be5a4b5ba4 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 09:59:42 -0600 Subject: [PATCH 05/32] review changes --- .../gradle/test/rest/transform/feature/FeatureInjector.java | 6 +++--- .../test/rest/transform/header/InjectHeaderTests.java | 2 +- .../rest/transform/feature/with_multiple_feature.yml | 2 +- .../rest/transform/feature/with_setup_no_feature.yml | 2 +- .../resources/rest/transform/feature/with_setup_no_skip.yml | 2 +- .../rest/transform/feature/with_single_feature.yml | 2 +- .../rest/transform/header/with_existing_headers.yml | 4 ++++ 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java index 1171ac52efdcf..36afa6f9afad1 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java @@ -32,7 +32,7 @@ public ObjectNode transformSetup(ObjectNode setupNodeParent) { // check to ensure that headers feature does not already exist if (setupNodeParent != null) { ArrayNode setupNode = (ArrayNode) setupNodeParent.get("setup"); - if (hasHeadersFeature(setupNode)) { + if (hasFeature(setupNode)) { return setupNodeParent; } } @@ -55,7 +55,7 @@ public ObjectNode transformTeardown(@Nullable ObjectNode teardownNodeParent) { // only transform an existing teardown section since a teardown does not inherit from setup but still needs the skip section if (teardownNode != null) { // check to ensure that headers feature does not already exist - if (hasHeadersFeature(teardownNode)) { + if (hasFeature(teardownNode)) { return teardownNodeParent; } addSkip(teardownNode); @@ -75,7 +75,7 @@ public ObjectNode transformTeardown(@Nullable ObjectNode teardownNodeParent) { */ public abstract String getSkipFeatureName(); - private boolean hasHeadersFeature(ArrayNode skipParent) { + private boolean hasFeature(ArrayNode skipParent) { JsonNode features = skipParent.at("/0/skip/features"); if (features != null) { if (features.isArray()) { diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java index 1434ec3a2bc44..1de8972597e8f 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java @@ -54,7 +54,7 @@ public void testInjectHeadersNoPreExisting() throws Exception { public void testInjectHeadersWithPreExisting() throws Exception { String testName = "/rest/transform/header/with_existing_headers.yml"; List tests = getTests(testName); - validateSetupDoesNotExist(tests); + validateSetupExist(tests); validateBodyHasHeaders(tests, Map.of("foo", "bar")); List transformedTests = transformTests(tests); printTest(testName, transformedTests); diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml b/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml index 948adc2f3500b..0d0ee965178e9 100644 --- a/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml +++ b/buildSrc/src/test/resources/rest/transform/feature/with_multiple_feature.yml @@ -5,7 +5,7 @@ setup: - pre_existing_feature1 - pre_existing_feature2 --- -"Test without with multiple feature setup": +"Test with multiple feature setup": - do: something: id: "something" diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml index b58b68a3d2160..f096848f2a659 100644 --- a/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml +++ b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_feature.yml @@ -4,7 +4,7 @@ setup: version: " - 7.1.99" reason: why not --- -"Test without with setup and skip but no feature": +"Test with setup and skip but no feature": - do: something: id: "something" diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml index 17146614e83a2..8f196575cb56a 100644 --- a/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml +++ b/buildSrc/src/test/resources/rest/transform/feature/with_setup_no_skip.yml @@ -4,7 +4,7 @@ setup: some.setup: index: blah --- -"Test without with setup but no skip (and by inference no features)": +"Test with setup but no skip (and by inference no features)": - do: something: id: "something" diff --git a/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml b/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml index 36ab3cd44bc49..ebb7cad99fa74 100644 --- a/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml +++ b/buildSrc/src/test/resources/rest/transform/feature/with_single_feature.yml @@ -3,7 +3,7 @@ setup: - skip: features: pre_existing_feature --- -"Test without with single feature setup": +"Test with single feature setup": - do: something: id: "something" diff --git a/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml b/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml index ee58986ba8ec0..1014157747766 100644 --- a/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml +++ b/buildSrc/src/test/resources/rest/transform/header/with_existing_headers.yml @@ -1,4 +1,8 @@ --- +setup: + - skip: + features: headers +--- "Test without a setup": - do: headers: From 4cea42542700ee2db6eb618db00c58da876fe429 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 11:14:59 -0600 Subject: [PATCH 06/32] clean up match tests --- .../rest/transform/match/AddMatchTests.java | 10 +- .../transform/match/RemoveMatchTests.java | 10 +- .../transform/match/ReplaceMatchTests.java | 10 +- .../resources/rest/transform/match/match.yml | 125 ++++-------------- 4 files changed, 42 insertions(+), 113 deletions(-) diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java index 1103eed094202..a91c9a9ffb129 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java @@ -68,7 +68,7 @@ public void testAddByTest() throws Exception { validateTest(tests, true); List transformedTests = transformer.transformRestTests( new LinkedList<>(tests), - Collections.singletonList(new AddMatch("my_number", addNode, "Basic")) + Collections.singletonList(new AddMatch("my_number", addNode, "Last test")) ); printTest(testName, transformedTests); validateTest(tests, false); @@ -80,9 +80,9 @@ private void validateTest(List tests, boolean beforeTransformation) ObjectNode tearDown = tests.get(1); assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("Test that queries on _index match against the correct indices."), CoreMatchers.notNullValue()); + assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Basic"), CoreMatchers.notNullValue()); + assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); // setup JsonNode setup = setUp.get("setup"); @@ -117,7 +117,7 @@ private void validateTest(List tests, boolean beforeTransformation) assertFalse(teardownHasMatchObject.get()); // first test - JsonNode firstTestChild = firstTest.get("Test that queries on _index match against the correct indices."); + JsonNode firstTestChild = firstTest.get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -133,7 +133,7 @@ private void validateTest(List tests, boolean beforeTransformation) assertTrue(firstTestHasMatchObject.get()); // last test - JsonNode lastTestChild = lastTest.get("Basic"); + JsonNode lastTestChild = lastTest.get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java index 3beef1bb23ecf..3643266916003 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java @@ -62,7 +62,7 @@ public void testRemoveByTest() throws Exception { validateTest(tests, true, false); List transformedTests = transformer.transformRestTests( new LinkedList<>(tests), - Collections.singletonList(new RemoveMatch("_type", "Basic")) + Collections.singletonList(new RemoveMatch("_type", "Last test")) ); printTest(testName, transformedTests); validateTest(tests, false, false); @@ -75,9 +75,9 @@ private void validateTest(List tests, boolean beforeTransformation, ObjectNode tearDown = tests.get(1); assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("Test that queries on _index match against the correct indices."), CoreMatchers.notNullValue()); + assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Basic"), CoreMatchers.notNullValue()); + assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); // setup JsonNode setup = setUp.get("setup"); @@ -112,7 +112,7 @@ private void validateTest(List tests, boolean beforeTransformation, assertFalse(teardownHasMatchObject.get()); // first test - JsonNode firstTestChild = firstTest.get("Test that queries on _index match against the correct indices."); + JsonNode firstTestChild = firstTest.get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -142,7 +142,7 @@ private void validateTest(List tests, boolean beforeTransformation, } // last test - JsonNode lastTestChild = lastTest.get("Basic"); + JsonNode lastTestChild = lastTest.get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java index 84f7545b85720..22f36a5cb7c61 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java @@ -65,7 +65,7 @@ public void testReplaceByTest() throws Exception { validateTest(tests, true, false); List transformedTests = transformer.transformRestTests( new LinkedList<>(tests), - Collections.singletonList(new ReplaceMatch("_type", replacementNode, "Basic")) + Collections.singletonList(new ReplaceMatch("_type", replacementNode, "Last test")) ); printTest(testName, transformedTests); validateTest(tests, false, false); @@ -77,9 +77,9 @@ private void validateTest(List tests, boolean beforeTransformation, ObjectNode tearDown = tests.get(1); assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("Test that queries on _index match against the correct indices."), CoreMatchers.notNullValue()); + assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Basic"), CoreMatchers.notNullValue()); + assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); // setup JsonNode setup = setUp.get("setup"); @@ -114,7 +114,7 @@ private void validateTest(List tests, boolean beforeTransformation, assertFalse(teardownHasMatchObject.get()); // first test - JsonNode firstTestChild = firstTest.get("Test that queries on _index match against the correct indices."); + JsonNode firstTestChild = firstTest.get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -139,7 +139,7 @@ private void validateTest(List tests, boolean beforeTransformation, assertTrue(firstTestHasTypeMatch.get()); // last test - JsonNode lastTestChild = lastTest.get("Basic"); + JsonNode lastTestChild = lastTest.get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; diff --git a/buildSrc/src/test/resources/rest/transform/match/match.yml b/buildSrc/src/test/resources/rest/transform/match/match.yml index 84fb7832510c3..bb35031d08804 100644 --- a/buildSrc/src/test/resources/rest/transform/match/match.yml +++ b/buildSrc/src/test/resources/rest/transform/match/match.yml @@ -1,40 +1,24 @@ --- setup: - do: - indices.create: - index: single_doc_index - body: - settings: - index: - number_of_shards: 1 - number_of_replicas: 0 + something: + here: ok --- teardown: - do: - indices.delete: - index: single_doc_index - ignore_unavailable: true - + something_else: + here: true --- -"Test that queries on _index match against the correct indices.": +"First test": - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' + something: + that_is: true - do: - search: - rest_total_hits_as_int: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - body: - query: - term: - "_index": "single_doc_index" + and: again - - match: { hits.total: 1 } + - match: { copied.from.real.test.total: 1 } - match: { hits.hits.0._index: "single_doc_index"} - match: { _shards.total: 2 } - match: { _shards.successful: 2 } @@ -42,60 +26,37 @@ teardown: - match: { _shards.failed: 0 } - do: - search: - rest_total_hits_as_int: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - body: - query: - term: - "_index": "my_remote_cluster:single_doc_index" + and: again - match: { hits.total: 1 } - match: { hits.hits.0._index: "my_remote_cluster:single_doc_index"} - match: { _shards.total: 2 } - match: { _shards.successful: 2 } - match: { _shards.skipped : 0} - - match: { _shards.failed: 0 } + - match: { _below_is_target_for_tests: 0 } - match: { _type: foo } --- -"Test that queries on _index that don't match are skipped": +"Also has _type match": - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' + something: + that_is: true - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "does_not_match" + and: again - match: { hits.total.value: 0 } - match: { _type: test } + - match: { _below_is_target_for_tests: 0 } + - match: { _type: foo } - match: { _shards.total: 2 } - match: { _shards.successful: 2 } - match: { _shards.skipped : 1} - match: { _shards.failed: 0 } - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "my_remote_cluster:does_not_match" + not_random_but_representive: "of actual test" - match: { hits.total.value: 0 } - match: { _shards.total: 2 } @@ -104,25 +65,14 @@ teardown: - match: { _shards.failed: 0 } --- -"no _type": +"Does not have _type match ": - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' + something: + that_is: true - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "does_not_match" + and: again - match: { hits.total.value: 0 } - match: { _shards.total: 2 } @@ -131,15 +81,7 @@ teardown: - match: { _shards.failed: 0 } - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "my_remote_cluster:does_not_match" + it: again - match: { hits.total.value: 0 } - match: { _shards.total: 2 } @@ -147,20 +89,10 @@ teardown: - match: { _shards.skipped : 1} - match: { _shards.failed: 0 } --- -"Basic": +"Last test": - do: - index: - index: test_1 - type: test - id: 中文 - body: { "foo": "Hello: 中文" } - - - do: - get: - index: test_1 - type: test - id: 中文 + something: 中文 - match: { _index: test_1 } - match: { _type: test } @@ -168,13 +100,10 @@ teardown: - match: { _source: { foo: "Hello: 中文" } } - do: - get: - index: test_1 - type: _all - id: 中文 + something_else: 中文 - match: { _index: test_1 } - - match: { _type: test } + - match: { _type: "the value does not matter" } - match: { _id: 中文 } - match: { _source: { foo: "Hello: 中文" } } From 757200ee9df7c40e83921b287cf44fbdfce58548 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 13:05:35 -0600 Subject: [PATCH 07/32] more refactoring and tests passing --- .../transform/warnings/RemoveWarnings.java | 5 +- .../test/rest/transform/TransformTests.java | 343 ++++++++++++++++++ .../transform/feature/InjectFeatureTests.java | 176 +-------- .../transform/header/InjectHeaderTests.java | 35 +- .../rest/transform/match/AddMatchTests.java | 92 +---- .../transform/match/RemoveMatchTests.java | 79 +--- .../transform/match/ReplaceMatchTests.java | 81 +---- .../warnings/InjectAllowedWarningsTests.java | 57 +-- .../warnings/InjectWarningsTests.java | 58 +-- .../warnings/RemoveWarningsTests.java | 73 ++-- .../with_existing_allowed_warnings.yml | 4 + .../with_existing_single_warnings.yml | 13 + .../warnings/with_existing_warnings.yml | 4 + 13 files changed, 470 insertions(+), 550 deletions(-) create mode 100644 buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java create mode 100644 buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java index 54a33114c1af9..156bfdc344b30 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -38,9 +38,10 @@ public void transformTest(ObjectNode doNodeParent) { ObjectNode doNodeValue = (ObjectNode) doNodeParent.get(getKeyToFind()); ArrayNode arrayWarnings = (ArrayNode) doNodeValue.get("warnings"); if (arrayWarnings == null) { - arrayWarnings = new ArrayNode(jsonNodeFactory); - doNodeValue.set("warnings", arrayWarnings); + return; } + + List keepWarnings = new ArrayList<>(); arrayWarnings.elements().forEachRemaining(warning -> { String warningValue = warning.textValue(); diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java new file mode 100644 index 0000000000000..7504eef86d230 --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java @@ -0,0 +1,343 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.SequenceWriter; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLParser; +import org.elasticsearch.gradle.test.GradleUnitTestCase; +import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; +import org.hamcrest.CoreMatchers; +import org.hamcrest.core.IsCollectionContaining; +import org.junit.Before; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.LongAdder; +import java.util.stream.Collectors; + +abstract public class TransformTests extends GradleUnitTestCase { + + private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); + private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); + private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); + + private static final Map headers1 = Map.of("foo", "bar"); + private static final Map headers2 = Map.of("abc", "xyz"); + + RestTestTransformer transformer; + + @Before + public void setup() { + transformer = new RestTestTransformer(); + } + + protected void validateSetupAndTearDown(List transformedTests) { + assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); + transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); + transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); + } + + protected ObjectNode validateSkipNodesExist(List tests) { + List skipNodes = tests.stream() + .filter(node -> node.get("setup") != null) + .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) + .map(node -> getSkipNode((ArrayNode) node.get("setup"))) + .collect(Collectors.toList()); + assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); + return skipNodes.get(0); + } + + protected void validateSkipNodesDoesNotExist(List tests) { + List skipNodes = tests.stream() + .filter(node -> node.get("setup") != null) + .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) + .map(node -> getSkipNode((ArrayNode) node.get("setup"))) + .collect(Collectors.toList()); + assertThat(skipNodes.size(), CoreMatchers.equalTo(0)); + } + + protected void validatePreExistingFeatureExist(List tests) { + assertThat(validateSkipNodesExist(tests).get("features"), CoreMatchers.notNullValue()); + } + + protected void validateSetupDoesNotExist(List tests) { + assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(0L)); + } + + protected void validateFeatureNameExists(List tests, String featureName) { + ObjectNode skipNode = validateSkipNodesExist(tests); + JsonNode featureValues = skipNode.get("features"); + assertNotNull(featureValues); + + List features = new ArrayList<>(1); + if (featureValues.isArray()) { + Iterator featuresIt = featureValues.elements(); + while (featuresIt.hasNext()) { + JsonNode feature = featuresIt.next(); + features.add(feature.asText()); + } + } else if (featureValues.isTextual()) { + features.add(featureValues.asText()); + } + + assertThat(features, IsCollectionContaining.hasItem(featureName)); + } + + protected void validateSetupExist(List tests) { + assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); + } + + protected List transformTests(List tests) { + return transformTests(tests, getTransformations()); + } + + protected List transformTests(List tests, List> transforms) { + List t = transformer.transformRestTests(new LinkedList<>(tests), transforms); + if (getKnownFeatures() != null) { + getKnownFeatures().forEach(name -> { + validateFeatureNameExists(t, name); + }); + } + return t; + } + + + protected List getKnownFeatures() { + return null; + } + + protected List> getTransformations() { + List> transformations = new ArrayList<>(); + transformations.add(new InjectHeaders(headers1)); + transformations.add(new InjectHeaders(headers2)); + return transformations; + } + + protected List getTests(String relativePath) throws Exception { + String testName = relativePath; + File testFile = new File(getClass().getResource(testName).toURI()); + YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); + return READER.readValues(yamlParser).readAll(); + } + + protected void assertTeardown(ObjectNode teardownNode) { + assertThat(teardownNode.get("teardown"), CoreMatchers.instanceOf(ArrayNode.class)); + ObjectNode skipNode = getSkipNode((ArrayNode) teardownNode.get("teardown")); + assertSkipNode(skipNode); + } + + protected void assertSetup(ObjectNode setupNode) { + assertThat(setupNode.get("setup"), CoreMatchers.instanceOf(ArrayNode.class)); + ObjectNode skipNode = getSkipNode((ArrayNode) setupNode.get("setup")); + assertSkipNode(skipNode); + } + + protected void assertSkipNode(ObjectNode skipNode) { + assertThat(skipNode, CoreMatchers.notNullValue()); + List featureValues = new ArrayList<>(); + if (skipNode.get("features").isArray()) { + assertThat(skipNode.get("features"), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode features = (ArrayNode) skipNode.get("features"); + features.forEach(x -> { + if (x.isTextual()) { + featureValues.add(x.asText()); + } + }); + } else { + featureValues.add(skipNode.get("features").asText()); + } + assertEquals(featureValues.stream().distinct().count(), featureValues.size()); + } + + protected ObjectNode getSkipNode(ArrayNode setupNodeValue) { + Iterator setupIt = setupNodeValue.elements(); + while (setupIt.hasNext()) { + JsonNode arrayEntry = setupIt.next(); + if (arrayEntry.isObject()) { + ObjectNode skipCandidate = (ObjectNode) arrayEntry; + if (skipCandidate.get("skip") != null) { + ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); + return skipNode; + } + } + } + return null; + } + + protected void validateBodyHasWarnings(String featureName, List tests, Set expectedWarnings) { + tests.forEach(test -> { + Iterator> testsIterator = test.fields(); + while (testsIterator.hasNext()) { + Map.Entry testObject = testsIterator.next(); + assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get(featureName), CoreMatchers.notNullValue()); + ArrayNode warningsNode = (ArrayNode) doSection.get(featureName); + LongAdder assertions = new LongAdder(); + warningsNode.forEach(warning -> { + if (expectedWarnings.contains(warning.asText())) { + assertions.increment(); + } + }); + assertThat(assertions.intValue(), CoreMatchers.equalTo(expectedWarnings.size())); + } + }); + } + }); + } + + protected void validateBodyHasNoWarnings(String featureName, List tests) { + tests.forEach(test -> { + Iterator> testsIterator = test.fields(); + while (testsIterator.hasNext()) { + Map.Entry testObject = testsIterator.next(); + assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get(featureName), CoreMatchers.nullValue()); + } + }); + } + }); + } + + protected void validateBodyHasEmptyNoWarnings(String featureName, List tests) { + tests.forEach(test -> { + Iterator> testsIterator = test.fields(); + while (testsIterator.hasNext()) { + Map.Entry testObject = testsIterator.next(); + assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get(featureName), CoreMatchers.notNullValue()); + ArrayNode warningsNode = (ArrayNode) doSection.get(featureName); + assertTrue(warningsNode.isEmpty()); + } + }); + } + }); + } + + protected void validateBodyHasHeaders(List tests, Map expectedHeaders) { + tests.forEach(test -> { + Iterator> testsIterator = test.fields(); + while (testsIterator.hasNext()) { + Map.Entry testObject = testsIterator.next(); + assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); + ObjectNode headersNode = (ObjectNode) doSection.get("headers"); + LongAdder assertions = new LongAdder(); + expectedHeaders.forEach((k, v) -> { + assertThat(headersNode.get(k), CoreMatchers.notNullValue()); + TextNode textNode = (TextNode) headersNode.get(k); + assertThat(textNode.asText(), CoreMatchers.equalTo(v)); + assertions.increment(); + }); + assertThat(assertions.intValue(), CoreMatchers.equalTo(expectedHeaders.size())); + } + }); + } + }); + } + + protected void validateSetupAndTearDownForMatchTests(List tests) { + ObjectNode setUp = tests.get(0); + assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); + ObjectNode tearDown = tests.get(1); + assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); + ObjectNode firstTest = tests.get(2); + assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); + ObjectNode lastTest = tests.get(tests.size() - 1); + assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); + + // setup + JsonNode setup = setUp.get("setup"); + assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode setupParentArray = (ArrayNode) setup; + + AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); + setupParentArray.elements().forEachRemaining(node -> { + assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode childObject = (ObjectNode) node; + JsonNode matchObject = childObject.get("match"); + if (matchObject != null) { + setUpHasMatchObject.set(true); + } + }); + assertFalse(setUpHasMatchObject.get()); + + // teardown + JsonNode teardown = tearDown.get("teardown"); + assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode teardownParentArray = (ArrayNode) teardown; + + AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); + teardownParentArray.elements().forEachRemaining(node -> { + assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode childObject = (ObjectNode) node; + JsonNode matchObject = childObject.get("match"); + if (matchObject != null) { + teardownHasMatchObject.set(true); + } + }); + assertFalse(teardownHasMatchObject.get()); + } + + + protected boolean getHumanDebug() { + return false; + } + + // only to help manually debug + protected void printTest(String testName, List tests) { + if (getHumanDebug()) { + System.out.println("\n************* " + testName + " *************"); + try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { + for (ObjectNode transformedTest : tests) { + sequenceWriter.write(transformedTest); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java index 9366c3f1cb91b..3f79da3910e0b 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java @@ -8,47 +8,15 @@ package org.elasticsearch.gradle.test.rest.transform.feature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; -import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; -import org.hamcrest.CoreMatchers; -import org.hamcrest.core.IsCollectionContaining; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -public class InjectFeatureTests extends GradleUnitTestCase { - - private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); - private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - - private static final Map headers1 = Map.of("foo", "bar"); - private static final Map headers2 = Map.of("abc", "xyz"); - RestTestTransformer transformer; - - @Before - public void setup() { - transformer = new RestTestTransformer(); - } +public class InjectFeatureTests extends TransformTests { /** * test file does not have a setup @@ -134,145 +102,5 @@ public void testInjectFeatureWithFeatureAlreadyDefined() throws Exception { validateSetupAndTearDown(transformedTests); } - protected void validateSetupAndTearDown(List transformedTests) { - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - } - - protected ObjectNode validateSkipNodesExist(List tests) { - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); - return skipNodes.get(0); - } - - protected void validateSkipNodesDoesNotExist(List tests) { - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - assertThat(skipNodes.size(), CoreMatchers.equalTo(0)); - } - - protected void validatePreExistingFeatureExist(List tests) { - assertThat(validateSkipNodesExist(tests).get("features"), CoreMatchers.notNullValue()); - } - - protected void validateSetupDoesNotExist(List tests) { - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(0L)); - } - - protected void validateFeatureNameExists(List tests, String featureName) { - ObjectNode skipNode = validateSkipNodesExist(tests); - JsonNode featureValues = skipNode.get("features"); - assertNotNull(featureValues); - - List features = new ArrayList<>(1); - if (featureValues.isArray()) { - Iterator featuresIt = featureValues.elements(); - while (featuresIt.hasNext()) { - JsonNode feature = featuresIt.next(); - features.add(feature.asText()); - } - } else if (featureValues.isTextual()) { - features.add(featureValues.asText()); - } - - assertThat(features, IsCollectionContaining.hasItem(featureName)); - } - - protected void validateSetupExist(List tests) { - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - } - - protected List transformTests(List tests) { - List t = transformer.transformRestTests(new LinkedList<>(tests), getTransformations()); - getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); - return t; - } - - protected List getKnownFeatures() { - return Collections.singletonList("headers"); - } - - protected List> getTransformations() { - List> transformations = new ArrayList<>(); - transformations.add(new InjectHeaders(headers1)); - transformations.add(new InjectHeaders(headers2)); - return transformations; - } - - protected List getTests(String relativePath) throws Exception { - String testName = relativePath; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - return READER.readValues(yamlParser).readAll(); - } - - protected void assertTeardown(ObjectNode teardownNode) { - assertThat(teardownNode.get("teardown"), CoreMatchers.instanceOf(ArrayNode.class)); - ObjectNode skipNode = getSkipNode((ArrayNode) teardownNode.get("teardown")); - assertSkipNode(skipNode); - } - protected void assertSetup(ObjectNode setupNode) { - assertThat(setupNode.get("setup"), CoreMatchers.instanceOf(ArrayNode.class)); - ObjectNode skipNode = getSkipNode((ArrayNode) setupNode.get("setup")); - assertSkipNode(skipNode); - } - - protected void assertSkipNode(ObjectNode skipNode) { - assertThat(skipNode, CoreMatchers.notNullValue()); - List featureValues = new ArrayList<>(); - if (skipNode.get("features").isArray()) { - assertThat(skipNode.get("features"), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode features = (ArrayNode) skipNode.get("features"); - features.forEach(x -> { - if (x.isTextual()) { - featureValues.add(x.asText()); - } - }); - } else { - featureValues.add(skipNode.get("features").asText()); - } - assertEquals(featureValues.stream().distinct().count(), featureValues.size()); - } - - protected ObjectNode getSkipNode(ArrayNode setupNodeValue) { - Iterator setupIt = setupNodeValue.elements(); - while (setupIt.hasNext()) { - JsonNode arrayEntry = setupIt.next(); - if (arrayEntry.isObject()) { - ObjectNode skipCandidate = (ObjectNode) arrayEntry; - if (skipCandidate.get("skip") != null) { - ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); - return skipNode; - } - } - } - return null; - } - - protected boolean getHumanDebug() { - return false; - } - - // only to help manually debug - protected void printTest(String testName, List tests) { - if (getHumanDebug()) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java index 1de8972597e8f..5dfc45f4f476d 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java @@ -8,21 +8,15 @@ package org.elasticsearch.gradle.test.rest.transform.header; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; -import org.hamcrest.CoreMatchers; import org.junit.Test; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.LongAdder; public class InjectHeaderTests extends InjectFeatureTests { @@ -77,32 +71,5 @@ protected List> getTransformations() { protected boolean getHumanDebug() { return false; } - - private void validateBodyHasHeaders(List tests, Map headers) { - tests.forEach(test -> { - Iterator> testsIterator = test.fields(); - while (testsIterator.hasNext()) { - Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - testBody.forEach(arrayObject -> { - assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode testSection = (ObjectNode) arrayObject; - if (testSection.get("do") != null) { - ObjectNode doSection = (ObjectNode) testSection.get("do"); - assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); - ObjectNode headersNode = (ObjectNode) doSection.get("headers"); - LongAdder assertions = new LongAdder(); - headers.forEach((k, v) -> { - assertThat(headersNode.get(k), CoreMatchers.notNullValue()); - TextNode textNode = (TextNode) headersNode.get(k); - assertThat(textNode.asText(), CoreMatchers.equalTo(v)); - assertions.increment(); - }); - assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); - } - }); - } - }); - } } + diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java index a91c9a9ffb129..51cd7a6962ab0 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLParser; import org.elasticsearch.gradle.test.GradleUnitTestCase; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -28,45 +29,31 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class AddMatchTests extends GradleUnitTestCase { +public class AddMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - - private static final boolean humanDebug = false; // useful for humans trying to debug these tests @Test public void testAddAllNotSupported() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode addNode = MAPPER.convertValue("_doc", JsonNode.class); assertEquals( "adding matches is only supported for named tests", - expectThrows( - NullPointerException.class, - () -> transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new AddMatch("_type", addNode, null)) - ) - ).getMessage() - ); - + expectThrows(NullPointerException.class, () -> transformTests( + new LinkedList<>(tests), + Collections.singletonList(new AddMatch("_type", addNode, null)))) + .getMessage()); } @Test public void testAddByTest() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode addNode = MAPPER.convertValue(123456789, JsonNode.class); validateTest(tests, true); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), Collections.singletonList(new AddMatch("my_number", addNode, "Last test")) ); @@ -75,49 +62,9 @@ public void testAddByTest() throws Exception { } private void validateTest(List tests, boolean beforeTransformation) { - ObjectNode setUp = tests.get(0); - assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); - ObjectNode tearDown = tests.get(1); - assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); - ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); - ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); - - // setup - JsonNode setup = setUp.get("setup"); - assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode setupParentArray = (ArrayNode) setup; - - AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); - setupParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - setUpHasMatchObject.set(true); - } - }); - assertFalse(setUpHasMatchObject.get()); - - // teardown - JsonNode teardown = tearDown.get("teardown"); - assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode teardownParentArray = (ArrayNode) teardown; - - AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); - teardownParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - teardownHasMatchObject.set(true); - } - }); - assertFalse(teardownHasMatchObject.get()); - + validateSetupAndTearDownForMatchTests(tests); // first test - JsonNode firstTestChild = firstTest.get("First test"); + JsonNode firstTestChild = tests.get(2).get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -133,7 +80,7 @@ private void validateTest(List tests, boolean beforeTransformation) assertTrue(firstTestHasMatchObject.get()); // last test - JsonNode lastTestChild = lastTest.get("Last test"); + JsonNode lastTestChild = tests.get(tests.size() - 1).get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; @@ -159,17 +106,8 @@ private void validateTest(List tests, boolean beforeTransformation) } } - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + @Override + protected boolean getHumanDebug() { + return false; } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java index 3643266916003..6b601b4605e01 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLParser; import org.elasticsearch.gradle.test.GradleUnitTestCase; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -28,23 +29,19 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class RemoveMatchTests extends GradleUnitTestCase { +public class RemoveMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - private static final boolean humanDebug = false; // useful for humans trying to debug these tests @Test public void testRemoveAll() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); validateTest(tests, true, true); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), Collections.singletonList(new RemoveMatch("_type")) ); @@ -55,12 +52,9 @@ public void testRemoveAll() throws Exception { @Test public void testRemoveByTest() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); validateTest(tests, true, false); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), Collections.singletonList(new RemoveMatch("_type", "Last test")) ); @@ -70,49 +64,9 @@ public void testRemoveByTest() throws Exception { } private void validateTest(List tests, boolean beforeTransformation, boolean allTests) { - ObjectNode setUp = tests.get(0); - assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); - ObjectNode tearDown = tests.get(1); - assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); - ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); - ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); - - // setup - JsonNode setup = setUp.get("setup"); - assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode setupParentArray = (ArrayNode) setup; - - AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); - setupParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - setUpHasMatchObject.set(true); - } - }); - assertFalse(setUpHasMatchObject.get()); - - // teardown - JsonNode teardown = tearDown.get("teardown"); - assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode teardownParentArray = (ArrayNode) teardown; - - AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); - teardownParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - teardownHasMatchObject.set(true); - } - }); - assertFalse(teardownHasMatchObject.get()); - + validateSetupAndTearDownForMatchTests(tests); // first test - JsonNode firstTestChild = firstTest.get("First test"); + JsonNode firstTestChild = tests.get(2).get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -142,7 +96,7 @@ private void validateTest(List tests, boolean beforeTransformation, } // last test - JsonNode lastTestChild = lastTest.get("Last test"); + JsonNode lastTestChild = tests.get(tests.size() - 1).get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; @@ -193,17 +147,8 @@ private void validateTest(List tests, boolean beforeTransformation, } } - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + @Override + protected boolean getHumanDebug() { + return false; } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java index 22f36a5cb7c61..9e802cee14a50 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLParser; import org.elasticsearch.gradle.test.GradleUnitTestCase; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -28,24 +29,19 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class ReplaceMatchTests extends GradleUnitTestCase { +public class ReplaceMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - private static final boolean humanDebug = false; // useful for humans trying to debug these tests @Test public void testReplaceAll() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode replacementNode = MAPPER.convertValue("_replaced_type", JsonNode.class); validateTest(tests, true, true); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), Collections.singletonList(new ReplaceMatch("_type", replacementNode, null)) ); @@ -57,13 +53,10 @@ public void testReplaceAll() throws Exception { @Test public void testReplaceByTest() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode replacementNode = MAPPER.convertValue("_replaced_type", JsonNode.class); validateTest(tests, true, false); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), Collections.singletonList(new ReplaceMatch("_type", replacementNode, "Last test")) ); @@ -72,49 +65,9 @@ public void testReplaceByTest() throws Exception { } private void validateTest(List tests, boolean beforeTransformation, boolean allTests) { - ObjectNode setUp = tests.get(0); - assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); - ObjectNode tearDown = tests.get(1); - assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); - ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); - ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); - - // setup - JsonNode setup = setUp.get("setup"); - assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode setupParentArray = (ArrayNode) setup; - - AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); - setupParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - setUpHasMatchObject.set(true); - } - }); - assertFalse(setUpHasMatchObject.get()); - - // teardown - JsonNode teardown = tearDown.get("teardown"); - assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode teardownParentArray = (ArrayNode) teardown; - - AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); - teardownParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - teardownHasMatchObject.set(true); - } - }); - assertFalse(teardownHasMatchObject.get()); - + validateSetupAndTearDownForMatchTests(tests); // first test - JsonNode firstTestChild = firstTest.get("First test"); + JsonNode firstTestChild = tests.get(2).get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -139,7 +92,7 @@ private void validateTest(List tests, boolean beforeTransformation, assertTrue(firstTestHasTypeMatch.get()); // last test - JsonNode lastTestChild = lastTest.get("Last test"); + JsonNode lastTestChild = tests.get(tests.size() - 1).get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; @@ -168,7 +121,6 @@ private void validateTest(List tests, boolean beforeTransformation, JsonNode otherTestChild = otherTest.get(otherTest.fields().next().getKey()); assertThat(otherTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode otherTestParentArray = (ArrayNode) otherTestChild; - AtomicBoolean otherTestHasTypeMatch = new AtomicBoolean(false); otherTestParentArray.elements().forEachRemaining(node -> { assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); ObjectNode childObject = (ObjectNode) node; @@ -184,17 +136,8 @@ private void validateTest(List tests, boolean beforeTransformation, } } - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + @Override + protected boolean getHumanDebug() { + return false; } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java index 5081060e0ac70..34046ca795e7f 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarningsTests.java @@ -13,83 +13,58 @@ import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.junit.Test; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; public class InjectAllowedWarningsTests extends InjectFeatureTests { -List addWarnings = List.of("added warning"); + Set addWarnings = Set.of("added warning"); + private static final String ALLOWED_WARNINGS = "allowed_warnings"; /** - * test file does not any headers defined + * test file does not any allowed warnings defined */ @Test - public void testInjectHeadersNoPreExisting() throws Exception { + public void testInjectAllowedWarningsNoPreExisting() throws Exception { String testName = "/rest/transform/warnings/without_existing_warnings.yml"; List tests = getTests(testName); validateSetupDoesNotExist(tests); List transformedTests = transformTests(tests); printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); - // validateBodyHasHeaders(transformedTests, addWarnings); + validateBodyHasWarnings(ALLOWED_WARNINGS, transformedTests, addWarnings); } /** - * test file has preexisting headers + * test file has preexisting allowed warnings */ @Test - public void testInjectHeadersWithPreExisting() throws Exception { + public void testInjectAllowedWarningsWithPreExisting() throws Exception { String testName = "/rest/transform/warnings/with_existing_allowed_warnings.yml"; List tests = getTests(testName); - validateSetupDoesNotExist(tests); - // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + validateSetupExist(tests); + validateBodyHasWarnings(ALLOWED_WARNINGS, tests, Set.of("a", "b")); List transformedTests = transformTests(tests); printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); - // validateBodyHasHeaders(tests, Map.of("foo", "bar")); - //validateBodyHasHeaders(transformedTests, addWarnings); + validateBodyHasWarnings(ALLOWED_WARNINGS, tests, Set.of("a", "b")); + validateBodyHasWarnings(ALLOWED_WARNINGS, tests, addWarnings); } @Override protected List getKnownFeatures() { - return Collections.singletonList("allowed_warnings"); + return Collections.singletonList(ALLOWED_WARNINGS); } @Override protected List> getTransformations() { - return Collections.singletonList(new InjectAllowedWarnings(addWarnings)); + return Collections.singletonList(new InjectAllowedWarnings(new ArrayList<>(addWarnings))); } @Override protected boolean getHumanDebug() { - return true; + return false; } - -// private void validateBodyHasHeaders(List tests, Map headers) { -// tests.forEach(test -> { -// Iterator> testsIterator = test.fields(); -// while (testsIterator.hasNext()) { -// Map.Entry testObject = testsIterator.next(); -// assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); -// ArrayNode testBody = (ArrayNode) testObject.getValue(); -// testBody.forEach(arrayObject -> { -// assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); -// ObjectNode testSection = (ObjectNode) arrayObject; -// if (testSection.get("do") != null) { -// ObjectNode doSection = (ObjectNode) testSection.get("do"); -// assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); -// ObjectNode headersNode = (ObjectNode) doSection.get("headers"); -// LongAdder assertions = new LongAdder(); -// headers.forEach((k, v) -> { -// assertThat(headersNode.get(k), CoreMatchers.notNullValue()); -// TextNode textNode = (TextNode) headersNode.get(k); -// assertThat(textNode.asText(), CoreMatchers.equalTo(v)); -// assertions.increment(); -// }); -// assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); -// } -// }); -// } -// }); -// } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java index 69aa7eed6953a..569403bd28691 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java @@ -13,83 +13,57 @@ import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.junit.Test; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; public class InjectWarningsTests extends InjectFeatureTests { - -List addWarnings = List.of("added warning"); + Set addWarnings = Set.of("added warning"); + private static final String WARNINGS = "warnings"; /** - * test file does not any headers defined + * test file does not any warnings defined */ @Test - public void testInjectHeadersNoPreExisting() throws Exception { + public void testInjectWarningsNoPreExisting() throws Exception { String testName = "/rest/transform/warnings/without_existing_warnings.yml"; List tests = getTests(testName); validateSetupDoesNotExist(tests); List transformedTests = transformTests(tests); printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); - // validateBodyHasHeaders(transformedTests, addWarnings); + validateBodyHasWarnings(WARNINGS, transformedTests, addWarnings); } /** - * test file has preexisting headers + * test file has preexisting warnings */ @Test - public void testInjectHeadersWithPreExisting() throws Exception { + public void testInjectWarningsWithPreExisting() throws Exception { String testName = "/rest/transform/warnings/with_existing_warnings.yml"; List tests = getTests(testName); - validateSetupDoesNotExist(tests); - // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + validateSetupExist(tests); + validateBodyHasWarnings(WARNINGS, tests, Set.of("a", "b")); List transformedTests = transformTests(tests); printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); - // validateBodyHasHeaders(tests, Map.of("foo", "bar")); - //validateBodyHasHeaders(transformedTests, addWarnings); + validateBodyHasWarnings(WARNINGS, tests, Set.of("a", "b")); + validateBodyHasWarnings(WARNINGS, tests, addWarnings); } @Override protected List getKnownFeatures() { - return Collections.singletonList("warnings"); + return Collections.singletonList(WARNINGS); } @Override protected List> getTransformations() { - return Collections.singletonList(new InjectWarnings(addWarnings)); + return Collections.singletonList(new InjectWarnings(new ArrayList<>(addWarnings))); } @Override protected boolean getHumanDebug() { - return true; + return false; } - -// private void validateBodyHasHeaders(List tests, Map headers) { -// tests.forEach(test -> { -// Iterator> testsIterator = test.fields(); -// while (testsIterator.hasNext()) { -// Map.Entry testObject = testsIterator.next(); -// assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); -// ArrayNode testBody = (ArrayNode) testObject.getValue(); -// testBody.forEach(arrayObject -> { -// assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); -// ObjectNode testSection = (ObjectNode) arrayObject; -// if (testSection.get("do") != null) { -// ObjectNode doSection = (ObjectNode) testSection.get("do"); -// assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); -// ObjectNode headersNode = (ObjectNode) doSection.get("headers"); -// LongAdder assertions = new LongAdder(); -// headers.forEach((k, v) -> { -// assertThat(headersNode.get(k), CoreMatchers.notNullValue()); -// TextNode textNode = (TextNode) headersNode.get(k); -// assertThat(textNode.asText(), CoreMatchers.equalTo(v)); -// assertions.increment(); -// }); -// assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); -// } -// }); -// } -// }); -// } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java index 33d5c4cc1441d..9840dccd66e73 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java @@ -10,86 +10,71 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.junit.Test; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; -public class RemoveWarningsTests extends InjectFeatureTests { +public class RemoveWarningsTests extends TransformTests { -List addWarnings = List.of("added warning"); + private static final String WARNINGS = "warnings"; /** - * test file does not any headers defined + * test file does not any warnings defined */ @Test - public void testInjectHeadersNoPreExisting() throws Exception { + public void testRemoveWarningsNoPreExisting() throws Exception { String testName = "/rest/transform/warnings/without_existing_warnings.yml"; List tests = getTests(testName); validateSetupDoesNotExist(tests); List transformedTests = transformTests(tests); printTest(testName, transformedTests); - validateSetupAndTearDown(transformedTests); - // validateBodyHasHeaders(transformedTests, addWarnings); + validateSetupDoesNotExist(transformedTests); + validateBodyHasNoWarnings(WARNINGS, transformedTests); } /** - * test file has preexisting headers + * test file has preexisting multiple warnings */ @Test - public void testInjectHeadersWithPreExisting() throws Exception { + public void testRemoveWarningWithPreExisting() throws Exception { String testName = "/rest/transform/warnings/with_existing_warnings.yml"; List tests = getTests(testName); - validateSetupDoesNotExist(tests); - // validateBodyHasHeaders(tests, Map.of("foo", "bar")); + validateSetupExist(tests); + validateBodyHasWarnings(WARNINGS, tests, Set.of("a", "b")); List transformedTests = transformTests(tests); printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); - // validateBodyHasHeaders(tests, Map.of("foo", "bar")); - //validateBodyHasHeaders(transformedTests, addWarnings); + validateBodyHasWarnings(WARNINGS, tests, Set.of("b")); } - @Override - protected List getKnownFeatures() { - return Collections.singletonList("warnings"); + /** + * test file has preexisting single warning + */ + @Test + public void testRemoveWarningWithSinglePreExisting() throws Exception { + //For simplicity, when removing the last item, it does not remove the headers/teardown and leaves an empty array + String testName = "/rest/transform/warnings/with_existing_single_warnings.yml"; + List tests = getTests(testName); + validateSetupExist(tests); + validateBodyHasWarnings(WARNINGS, tests, Set.of("a")); + List transformedTests = transformTests(tests); + printTest(testName, transformedTests); + validateSetupAndTearDown(transformedTests); + validateBodyHasEmptyNoWarnings(WARNINGS, tests); } @Override protected List> getTransformations() { - return Collections.singletonList(new InjectWarnings(addWarnings)); + return Collections.singletonList(new RemoveWarnings(Set.of("a"))); } @Override protected boolean getHumanDebug() { return true; } - -// private void validateBodyHasHeaders(List tests, Map headers) { -// tests.forEach(test -> { -// Iterator> testsIterator = test.fields(); -// while (testsIterator.hasNext()) { -// Map.Entry testObject = testsIterator.next(); -// assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); -// ArrayNode testBody = (ArrayNode) testObject.getValue(); -// testBody.forEach(arrayObject -> { -// assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); -// ObjectNode testSection = (ObjectNode) arrayObject; -// if (testSection.get("do") != null) { -// ObjectNode doSection = (ObjectNode) testSection.get("do"); -// assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); -// ObjectNode headersNode = (ObjectNode) doSection.get("headers"); -// LongAdder assertions = new LongAdder(); -// headers.forEach((k, v) -> { -// assertThat(headersNode.get(k), CoreMatchers.notNullValue()); -// TextNode textNode = (TextNode) headersNode.get(k); -// assertThat(textNode.asText(), CoreMatchers.equalTo(v)); -// assertions.increment(); -// }); -// assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); -// } -// }); -// } -// }); -// } } diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml index 8420520a6d193..ba94af94e36ef 100644 --- a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_allowed_warnings.yml @@ -1,4 +1,8 @@ --- +setup: + - skip: + features: allowed_warnings +--- "Test with existing allowed warnings": - do: allowed_warnings: diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml new file mode 100644 index 0000000000000..4edd0efd6a821 --- /dev/null +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml @@ -0,0 +1,13 @@ +--- +setup: + - skip: + features: warnings +--- +"Test with existing single warnings": + - do: + warnings: + - "a" + something: + id: "something" + - match: { acknowledged: true } + diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml index 53151e03b4f25..db929aa4c5503 100644 --- a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml @@ -1,4 +1,8 @@ --- +setup: + - skip: + features: warnings +--- "Test with existing warnings": - do: warnings: From 4b0629efe7e82e9a87f8b589536e6af00c2ac058 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 13:27:48 -0600 Subject: [PATCH 08/32] more refactor of tests --- .../transform/feature/InjectFeatureTests.java | 180 +----------------- .../transform/header/InjectHeaderTests.java | 34 ---- .../rest/transform/match/AddMatchTests.java | 94 ++------- .../transform/match/RemoveMatchTests.java | 91 ++------- .../transform/match/ReplaceMatchTests.java | 91 ++------- .../resources/rest/transform/match/match.yml | 125 +++--------- 6 files changed, 68 insertions(+), 547 deletions(-) diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java index 9366c3f1cb91b..2ce5e5e510866 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java @@ -8,47 +8,13 @@ package org.elasticsearch.gradle.test.rest.transform.feature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; -import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; -import org.hamcrest.CoreMatchers; -import org.hamcrest.core.IsCollectionContaining; -import org.junit.Before; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.junit.Test; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -public class InjectFeatureTests extends GradleUnitTestCase { - - private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); - private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - - private static final Map headers1 = Map.of("foo", "bar"); - private static final Map headers2 = Map.of("abc", "xyz"); - RestTestTransformer transformer; - - @Before - public void setup() { - transformer = new RestTestTransformer(); - } +public class InjectFeatureTests extends TransformTests { /** * test file does not have a setup @@ -133,146 +99,4 @@ public void testInjectFeatureWithFeatureAlreadyDefined() throws Exception { printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); } - - protected void validateSetupAndTearDown(List transformedTests) { - assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); - transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); - } - - protected ObjectNode validateSkipNodesExist(List tests) { - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); - return skipNodes.get(0); - } - - protected void validateSkipNodesDoesNotExist(List tests) { - List skipNodes = tests.stream() - .filter(node -> node.get("setup") != null) - .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) - .map(node -> getSkipNode((ArrayNode) node.get("setup"))) - .collect(Collectors.toList()); - assertThat(skipNodes.size(), CoreMatchers.equalTo(0)); - } - - protected void validatePreExistingFeatureExist(List tests) { - assertThat(validateSkipNodesExist(tests).get("features"), CoreMatchers.notNullValue()); - } - - protected void validateSetupDoesNotExist(List tests) { - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(0L)); - } - - protected void validateFeatureNameExists(List tests, String featureName) { - ObjectNode skipNode = validateSkipNodesExist(tests); - JsonNode featureValues = skipNode.get("features"); - assertNotNull(featureValues); - - List features = new ArrayList<>(1); - if (featureValues.isArray()) { - Iterator featuresIt = featureValues.elements(); - while (featuresIt.hasNext()) { - JsonNode feature = featuresIt.next(); - features.add(feature.asText()); - } - } else if (featureValues.isTextual()) { - features.add(featureValues.asText()); - } - - assertThat(features, IsCollectionContaining.hasItem(featureName)); - } - - protected void validateSetupExist(List tests) { - assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); - } - - protected List transformTests(List tests) { - List t = transformer.transformRestTests(new LinkedList<>(tests), getTransformations()); - getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); - return t; - } - - protected List getKnownFeatures() { - return Collections.singletonList("headers"); - } - - protected List> getTransformations() { - List> transformations = new ArrayList<>(); - transformations.add(new InjectHeaders(headers1)); - transformations.add(new InjectHeaders(headers2)); - return transformations; - } - - protected List getTests(String relativePath) throws Exception { - String testName = relativePath; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - return READER.readValues(yamlParser).readAll(); - } - - protected void assertTeardown(ObjectNode teardownNode) { - assertThat(teardownNode.get("teardown"), CoreMatchers.instanceOf(ArrayNode.class)); - ObjectNode skipNode = getSkipNode((ArrayNode) teardownNode.get("teardown")); - assertSkipNode(skipNode); - } - - protected void assertSetup(ObjectNode setupNode) { - assertThat(setupNode.get("setup"), CoreMatchers.instanceOf(ArrayNode.class)); - ObjectNode skipNode = getSkipNode((ArrayNode) setupNode.get("setup")); - assertSkipNode(skipNode); - } - - protected void assertSkipNode(ObjectNode skipNode) { - assertThat(skipNode, CoreMatchers.notNullValue()); - List featureValues = new ArrayList<>(); - if (skipNode.get("features").isArray()) { - assertThat(skipNode.get("features"), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode features = (ArrayNode) skipNode.get("features"); - features.forEach(x -> { - if (x.isTextual()) { - featureValues.add(x.asText()); - } - }); - } else { - featureValues.add(skipNode.get("features").asText()); - } - assertEquals(featureValues.stream().distinct().count(), featureValues.size()); - } - - protected ObjectNode getSkipNode(ArrayNode setupNodeValue) { - Iterator setupIt = setupNodeValue.elements(); - while (setupIt.hasNext()) { - JsonNode arrayEntry = setupIt.next(); - if (arrayEntry.isObject()) { - ObjectNode skipCandidate = (ObjectNode) arrayEntry; - if (skipCandidate.get("skip") != null) { - ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); - return skipNode; - } - } - } - return null; - } - - protected boolean getHumanDebug() { - return false; - } - - // only to help manually debug - protected void printTest(String testName, List tests) { - if (getHumanDebug()) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java index 1de8972597e8f..7b79a11777337 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java @@ -8,21 +8,15 @@ package org.elasticsearch.gradle.test.rest.transform.header; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; -import org.hamcrest.CoreMatchers; import org.junit.Test; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.LongAdder; public class InjectHeaderTests extends InjectFeatureTests { @@ -77,32 +71,4 @@ protected List> getTransformations() { protected boolean getHumanDebug() { return false; } - - private void validateBodyHasHeaders(List tests, Map headers) { - tests.forEach(test -> { - Iterator> testsIterator = test.fields(); - while (testsIterator.hasNext()) { - Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - testBody.forEach(arrayObject -> { - assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode testSection = (ObjectNode) arrayObject; - if (testSection.get("do") != null) { - ObjectNode doSection = (ObjectNode) testSection.get("do"); - assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); - ObjectNode headersNode = (ObjectNode) doSection.get("headers"); - LongAdder assertions = new LongAdder(); - headers.forEach((k, v) -> { - assertThat(headersNode.get(k), CoreMatchers.notNullValue()); - TextNode textNode = (TextNode) headersNode.get(k); - assertThat(textNode.asText(), CoreMatchers.equalTo(v)); - assertions.increment(); - }); - assertThat(assertions.intValue(), CoreMatchers.equalTo(headers.size())); - } - }); - } - }); - } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java index 1103eed094202..73117ce56eb13 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java @@ -10,114 +10,55 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class AddMatchTests extends GradleUnitTestCase { +public class AddMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - - private static final boolean humanDebug = false; // useful for humans trying to debug these tests @Test public void testAddAllNotSupported() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode addNode = MAPPER.convertValue("_doc", JsonNode.class); assertEquals( "adding matches is only supported for named tests", expectThrows( NullPointerException.class, - () -> transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new AddMatch("_type", addNode, null)) - ) + () -> transformTests(new LinkedList<>(tests), Collections.singletonList(new AddMatch("_type", addNode, null))) ).getMessage() ); - } @Test public void testAddByTest() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode addNode = MAPPER.convertValue(123456789, JsonNode.class); validateTest(tests, true); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), - Collections.singletonList(new AddMatch("my_number", addNode, "Basic")) + Collections.singletonList(new AddMatch("my_number", addNode, "Last test")) ); printTest(testName, transformedTests); validateTest(tests, false); } private void validateTest(List tests, boolean beforeTransformation) { - ObjectNode setUp = tests.get(0); - assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); - ObjectNode tearDown = tests.get(1); - assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); - ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("Test that queries on _index match against the correct indices."), CoreMatchers.notNullValue()); - ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Basic"), CoreMatchers.notNullValue()); - - // setup - JsonNode setup = setUp.get("setup"); - assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode setupParentArray = (ArrayNode) setup; - - AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); - setupParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - setUpHasMatchObject.set(true); - } - }); - assertFalse(setUpHasMatchObject.get()); - - // teardown - JsonNode teardown = tearDown.get("teardown"); - assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode teardownParentArray = (ArrayNode) teardown; - - AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); - teardownParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - teardownHasMatchObject.set(true); - } - }); - assertFalse(teardownHasMatchObject.get()); - + validateSetupAndTearDownForMatchTests(tests); // first test - JsonNode firstTestChild = firstTest.get("Test that queries on _index match against the correct indices."); + JsonNode firstTestChild = tests.get(2).get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -133,7 +74,7 @@ private void validateTest(List tests, boolean beforeTransformation) assertTrue(firstTestHasMatchObject.get()); // last test - JsonNode lastTestChild = lastTest.get("Basic"); + JsonNode lastTestChild = tests.get(tests.size() - 1).get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; @@ -159,17 +100,8 @@ private void validateTest(List tests, boolean beforeTransformation) } } - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + @Override + protected boolean getHumanDebug() { + return false; } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java index 3beef1bb23ecf..63c1a55338678 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java @@ -11,43 +11,30 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class RemoveMatchTests extends GradleUnitTestCase { +public class RemoveMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - private static final boolean humanDebug = false; // useful for humans trying to debug these tests - @Test public void testRemoveAll() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); validateTest(tests, true, true); - List transformedTests = transformer.transformRestTests( - new LinkedList<>(tests), - Collections.singletonList(new RemoveMatch("_type")) - ); + List transformedTests = transformTests(new LinkedList<>(tests), Collections.singletonList(new RemoveMatch("_type"))); printTest(testName, transformedTests); validateTest(tests, false, true); } @@ -55,14 +42,11 @@ public void testRemoveAll() throws Exception { @Test public void testRemoveByTest() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); validateTest(tests, true, false); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), - Collections.singletonList(new RemoveMatch("_type", "Basic")) + Collections.singletonList(new RemoveMatch("_type", "Last test")) ); printTest(testName, transformedTests); validateTest(tests, false, false); @@ -70,49 +54,9 @@ public void testRemoveByTest() throws Exception { } private void validateTest(List tests, boolean beforeTransformation, boolean allTests) { - ObjectNode setUp = tests.get(0); - assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); - ObjectNode tearDown = tests.get(1); - assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); - ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("Test that queries on _index match against the correct indices."), CoreMatchers.notNullValue()); - ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Basic"), CoreMatchers.notNullValue()); - - // setup - JsonNode setup = setUp.get("setup"); - assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode setupParentArray = (ArrayNode) setup; - - AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); - setupParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - setUpHasMatchObject.set(true); - } - }); - assertFalse(setUpHasMatchObject.get()); - - // teardown - JsonNode teardown = tearDown.get("teardown"); - assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode teardownParentArray = (ArrayNode) teardown; - - AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); - teardownParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - teardownHasMatchObject.set(true); - } - }); - assertFalse(teardownHasMatchObject.get()); - + validateSetupAndTearDownForMatchTests(tests); // first test - JsonNode firstTestChild = firstTest.get("Test that queries on _index match against the correct indices."); + JsonNode firstTestChild = tests.get(2).get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -142,7 +86,7 @@ private void validateTest(List tests, boolean beforeTransformation, } // last test - JsonNode lastTestChild = lastTest.get("Basic"); + JsonNode lastTestChild = tests.get(tests.size() - 1).get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; @@ -193,17 +137,8 @@ private void validateTest(List tests, boolean beforeTransformation, } } - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + @Override + protected boolean getHumanDebug() { + return false; } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java index 84f7545b85720..bd3bedc3abd56 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java @@ -10,42 +10,30 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; +import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -public class ReplaceMatchTests extends GradleUnitTestCase { +public class ReplaceMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - - private static final boolean humanDebug = false; // useful for humans trying to debug these tests @Test public void testReplaceAll() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode replacementNode = MAPPER.convertValue("_replaced_type", JsonNode.class); validateTest(tests, true, true); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), Collections.singletonList(new ReplaceMatch("_type", replacementNode, null)) ); @@ -57,64 +45,21 @@ public void testReplaceAll() throws Exception { @Test public void testReplaceByTest() throws Exception { String testName = "/rest/transform/match/match.yml"; - File testFile = new File(getClass().getResource(testName).toURI()); - YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); - List tests = READER.readValues(yamlParser).readAll(); - RestTestTransformer transformer = new RestTestTransformer(); + List tests = getTests(testName); JsonNode replacementNode = MAPPER.convertValue("_replaced_type", JsonNode.class); validateTest(tests, true, false); - List transformedTests = transformer.transformRestTests( + List transformedTests = transformTests( new LinkedList<>(tests), - Collections.singletonList(new ReplaceMatch("_type", replacementNode, "Basic")) + Collections.singletonList(new ReplaceMatch("_type", replacementNode, "Last test")) ); printTest(testName, transformedTests); validateTest(tests, false, false); } private void validateTest(List tests, boolean beforeTransformation, boolean allTests) { - ObjectNode setUp = tests.get(0); - assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); - ObjectNode tearDown = tests.get(1); - assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); - ObjectNode firstTest = tests.get(2); - assertThat(firstTest.get("Test that queries on _index match against the correct indices."), CoreMatchers.notNullValue()); - ObjectNode lastTest = tests.get(tests.size() - 1); - assertThat(lastTest.get("Basic"), CoreMatchers.notNullValue()); - - // setup - JsonNode setup = setUp.get("setup"); - assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode setupParentArray = (ArrayNode) setup; - - AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); - setupParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - setUpHasMatchObject.set(true); - } - }); - assertFalse(setUpHasMatchObject.get()); - - // teardown - JsonNode teardown = tearDown.get("teardown"); - assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode teardownParentArray = (ArrayNode) teardown; - - AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); - teardownParentArray.elements().forEachRemaining(node -> { - assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode childObject = (ObjectNode) node; - JsonNode matchObject = childObject.get("match"); - if (matchObject != null) { - teardownHasMatchObject.set(true); - } - }); - assertFalse(teardownHasMatchObject.get()); - + validateSetupAndTearDownForMatchTests(tests); // first test - JsonNode firstTestChild = firstTest.get("Test that queries on _index match against the correct indices."); + JsonNode firstTestChild = tests.get(2).get("First test"); assertThat(firstTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode firstTestParentArray = (ArrayNode) firstTestChild; @@ -139,7 +84,7 @@ private void validateTest(List tests, boolean beforeTransformation, assertTrue(firstTestHasTypeMatch.get()); // last test - JsonNode lastTestChild = lastTest.get("Basic"); + JsonNode lastTestChild = tests.get(tests.size() - 1).get("Last test"); assertThat(lastTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode lastTestParentArray = (ArrayNode) lastTestChild; @@ -168,7 +113,6 @@ private void validateTest(List tests, boolean beforeTransformation, JsonNode otherTestChild = otherTest.get(otherTest.fields().next().getKey()); assertThat(otherTestChild, CoreMatchers.instanceOf(ArrayNode.class)); ArrayNode otherTestParentArray = (ArrayNode) otherTestChild; - AtomicBoolean otherTestHasTypeMatch = new AtomicBoolean(false); otherTestParentArray.elements().forEachRemaining(node -> { assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); ObjectNode childObject = (ObjectNode) node; @@ -184,17 +128,8 @@ private void validateTest(List tests, boolean beforeTransformation, } } - // only to help manually debug - private void printTest(String testName, List tests) { - if (humanDebug) { - System.out.println("\n************* " + testName + " *************"); - try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { - for (ObjectNode transformedTest : tests) { - sequenceWriter.write(transformedTest); - } - } catch (IOException e) { - e.printStackTrace(); - } - } + @Override + protected boolean getHumanDebug() { + return false; } } diff --git a/buildSrc/src/test/resources/rest/transform/match/match.yml b/buildSrc/src/test/resources/rest/transform/match/match.yml index 84fb7832510c3..bb35031d08804 100644 --- a/buildSrc/src/test/resources/rest/transform/match/match.yml +++ b/buildSrc/src/test/resources/rest/transform/match/match.yml @@ -1,40 +1,24 @@ --- setup: - do: - indices.create: - index: single_doc_index - body: - settings: - index: - number_of_shards: 1 - number_of_replicas: 0 + something: + here: ok --- teardown: - do: - indices.delete: - index: single_doc_index - ignore_unavailable: true - + something_else: + here: true --- -"Test that queries on _index match against the correct indices.": +"First test": - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' + something: + that_is: true - do: - search: - rest_total_hits_as_int: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - body: - query: - term: - "_index": "single_doc_index" + and: again - - match: { hits.total: 1 } + - match: { copied.from.real.test.total: 1 } - match: { hits.hits.0._index: "single_doc_index"} - match: { _shards.total: 2 } - match: { _shards.successful: 2 } @@ -42,60 +26,37 @@ teardown: - match: { _shards.failed: 0 } - do: - search: - rest_total_hits_as_int: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - body: - query: - term: - "_index": "my_remote_cluster:single_doc_index" + and: again - match: { hits.total: 1 } - match: { hits.hits.0._index: "my_remote_cluster:single_doc_index"} - match: { _shards.total: 2 } - match: { _shards.successful: 2 } - match: { _shards.skipped : 0} - - match: { _shards.failed: 0 } + - match: { _below_is_target_for_tests: 0 } - match: { _type: foo } --- -"Test that queries on _index that don't match are skipped": +"Also has _type match": - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' + something: + that_is: true - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "does_not_match" + and: again - match: { hits.total.value: 0 } - match: { _type: test } + - match: { _below_is_target_for_tests: 0 } + - match: { _type: foo } - match: { _shards.total: 2 } - match: { _shards.successful: 2 } - match: { _shards.skipped : 1} - match: { _shards.failed: 0 } - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "my_remote_cluster:does_not_match" + not_random_but_representive: "of actual test" - match: { hits.total.value: 0 } - match: { _shards.total: 2 } @@ -104,25 +65,14 @@ teardown: - match: { _shards.failed: 0 } --- -"no _type": +"Does not have _type match ": - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "single_doc_index"}}' - - '{"f1": "local_cluster", "sort_field": 0}' + something: + that_is: true - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "does_not_match" + and: again - match: { hits.total.value: 0 } - match: { _shards.total: 2 } @@ -131,15 +81,7 @@ teardown: - match: { _shards.failed: 0 } - do: - search: - ccs_minimize_roundtrips: false - track_total_hits: true - index: "single_doc_index,my_remote_cluster:single_doc_index" - pre_filter_shard_size: 1 - body: - query: - term: - "_index": "my_remote_cluster:does_not_match" + it: again - match: { hits.total.value: 0 } - match: { _shards.total: 2 } @@ -147,20 +89,10 @@ teardown: - match: { _shards.skipped : 1} - match: { _shards.failed: 0 } --- -"Basic": +"Last test": - do: - index: - index: test_1 - type: test - id: 中文 - body: { "foo": "Hello: 中文" } - - - do: - get: - index: test_1 - type: test - id: 中文 + something: 中文 - match: { _index: test_1 } - match: { _type: test } @@ -168,13 +100,10 @@ teardown: - match: { _source: { foo: "Hello: 中文" } } - do: - get: - index: test_1 - type: _all - id: 中文 + something_else: 中文 - match: { _index: test_1 } - - match: { _type: test } + - match: { _type: "the value does not matter" } - match: { _id: 中文 } - match: { _source: { foo: "Hello: 中文" } } From 3884c3db25f9ad18ae37a2878712bf29bf3363cd Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 13:28:05 -0600 Subject: [PATCH 09/32] add missing file --- .../test/rest/transform/TransformTests.java | 271 ++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java new file mode 100644 index 0000000000000..bd2714d05b22f --- /dev/null +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java @@ -0,0 +1,271 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.test.rest.transform; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.SequenceWriter; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLParser; +import org.elasticsearch.gradle.test.GradleUnitTestCase; +import org.elasticsearch.gradle.test.rest.transform.headers.InjectHeaders; +import org.hamcrest.CoreMatchers; +import org.hamcrest.core.IsCollectionContaining; +import org.junit.Before; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.LongAdder; +import java.util.stream.Collectors; + +abstract public class TransformTests extends GradleUnitTestCase { + + private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); + private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); + private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); + + private static final Map headers1 = Map.of("foo", "bar"); + private static final Map headers2 = Map.of("abc", "xyz"); + + RestTestTransformer transformer; + + @Before + public void setup() { + transformer = new RestTestTransformer(); + } + + protected void validateSetupAndTearDown(List transformedTests) { + assertThat(transformedTests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); + transformedTests.stream().filter(node -> node.get("setup") != null).forEach(this::assertSetup); + transformedTests.stream().filter(node -> node.get("teardown") != null).forEach(this::assertTeardown); + } + + protected ObjectNode validateSkipNodesExist(List tests) { + List skipNodes = tests.stream() + .filter(node -> node.get("setup") != null) + .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) + .map(node -> getSkipNode((ArrayNode) node.get("setup"))) + .collect(Collectors.toList()); + assertThat(skipNodes.size(), CoreMatchers.equalTo(1)); + return skipNodes.get(0); + } + + protected void validateSkipNodesDoesNotExist(List tests) { + List skipNodes = tests.stream() + .filter(node -> node.get("setup") != null) + .filter(node -> getSkipNode((ArrayNode) node.get("setup")) != null) + .map(node -> getSkipNode((ArrayNode) node.get("setup"))) + .collect(Collectors.toList()); + assertThat(skipNodes.size(), CoreMatchers.equalTo(0)); + } + + protected void validatePreExistingFeatureExist(List tests) { + assertThat(validateSkipNodesExist(tests).get("features"), CoreMatchers.notNullValue()); + } + + protected void validateSetupDoesNotExist(List tests) { + assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(0L)); + } + + protected void validateFeatureNameExists(List tests, String featureName) { + ObjectNode skipNode = validateSkipNodesExist(tests); + JsonNode featureValues = skipNode.get("features"); + assertNotNull(featureValues); + + List features = new ArrayList<>(1); + if (featureValues.isArray()) { + Iterator featuresIt = featureValues.elements(); + while (featuresIt.hasNext()) { + JsonNode feature = featuresIt.next(); + features.add(feature.asText()); + } + } else if (featureValues.isTextual()) { + features.add(featureValues.asText()); + } + + assertThat(features, IsCollectionContaining.hasItem(featureName)); + } + + protected void validateSetupExist(List tests) { + assertThat(tests.stream().filter(node -> node.get("setup") != null).count(), CoreMatchers.equalTo(1L)); + } + + protected List transformTests(List tests) { + return transformTests(tests, getTransformations()); + } + + protected List transformTests(List tests, List> transforms) { + List t = transformer.transformRestTests(new LinkedList<>(tests), transforms); + if (getKnownFeatures() != null) { + getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); + } + return t; + } + + protected List getKnownFeatures() { + return null; + } + + protected List> getTransformations() { + List> transformations = new ArrayList<>(); + transformations.add(new InjectHeaders(headers1)); + transformations.add(new InjectHeaders(headers2)); + return transformations; + } + + protected List getTests(String relativePath) throws Exception { + String testName = relativePath; + File testFile = new File(getClass().getResource(testName).toURI()); + YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); + return READER.readValues(yamlParser).readAll(); + } + + protected void assertTeardown(ObjectNode teardownNode) { + assertThat(teardownNode.get("teardown"), CoreMatchers.instanceOf(ArrayNode.class)); + ObjectNode skipNode = getSkipNode((ArrayNode) teardownNode.get("teardown")); + assertSkipNode(skipNode); + } + + protected void assertSetup(ObjectNode setupNode) { + assertThat(setupNode.get("setup"), CoreMatchers.instanceOf(ArrayNode.class)); + ObjectNode skipNode = getSkipNode((ArrayNode) setupNode.get("setup")); + assertSkipNode(skipNode); + } + + protected void assertSkipNode(ObjectNode skipNode) { + assertThat(skipNode, CoreMatchers.notNullValue()); + List featureValues = new ArrayList<>(); + if (skipNode.get("features").isArray()) { + assertThat(skipNode.get("features"), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode features = (ArrayNode) skipNode.get("features"); + features.forEach(x -> { + if (x.isTextual()) { + featureValues.add(x.asText()); + } + }); + } else { + featureValues.add(skipNode.get("features").asText()); + } + assertEquals(featureValues.stream().distinct().count(), featureValues.size()); + } + + protected ObjectNode getSkipNode(ArrayNode setupNodeValue) { + Iterator setupIt = setupNodeValue.elements(); + while (setupIt.hasNext()) { + JsonNode arrayEntry = setupIt.next(); + if (arrayEntry.isObject()) { + ObjectNode skipCandidate = (ObjectNode) arrayEntry; + if (skipCandidate.get("skip") != null) { + ObjectNode skipNode = (ObjectNode) skipCandidate.get("skip"); + return skipNode; + } + } + } + return null; + } + + protected void validateBodyHasHeaders(List tests, Map expectedHeaders) { + tests.forEach(test -> { + Iterator> testsIterator = test.fields(); + while (testsIterator.hasNext()) { + Map.Entry testObject = testsIterator.next(); + assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get("headers"), CoreMatchers.notNullValue()); + ObjectNode headersNode = (ObjectNode) doSection.get("headers"); + LongAdder assertions = new LongAdder(); + expectedHeaders.forEach((k, v) -> { + assertThat(headersNode.get(k), CoreMatchers.notNullValue()); + TextNode textNode = (TextNode) headersNode.get(k); + assertThat(textNode.asText(), CoreMatchers.equalTo(v)); + assertions.increment(); + }); + assertThat(assertions.intValue(), CoreMatchers.equalTo(expectedHeaders.size())); + } + }); + } + }); + } + + protected void validateSetupAndTearDownForMatchTests(List tests) { + ObjectNode setUp = tests.get(0); + assertThat(setUp.get("setup"), CoreMatchers.notNullValue()); + ObjectNode tearDown = tests.get(1); + assertThat(tearDown.get("teardown"), CoreMatchers.notNullValue()); + ObjectNode firstTest = tests.get(2); + assertThat(firstTest.get("First test"), CoreMatchers.notNullValue()); + ObjectNode lastTest = tests.get(tests.size() - 1); + assertThat(lastTest.get("Last test"), CoreMatchers.notNullValue()); + + // setup + JsonNode setup = setUp.get("setup"); + assertThat(setup, CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode setupParentArray = (ArrayNode) setup; + + AtomicBoolean setUpHasMatchObject = new AtomicBoolean(false); + setupParentArray.elements().forEachRemaining(node -> { + assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode childObject = (ObjectNode) node; + JsonNode matchObject = childObject.get("match"); + if (matchObject != null) { + setUpHasMatchObject.set(true); + } + }); + assertFalse(setUpHasMatchObject.get()); + + // teardown + JsonNode teardown = tearDown.get("teardown"); + assertThat(teardown, CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode teardownParentArray = (ArrayNode) teardown; + + AtomicBoolean teardownHasMatchObject = new AtomicBoolean(false); + teardownParentArray.elements().forEachRemaining(node -> { + assertThat(node, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode childObject = (ObjectNode) node; + JsonNode matchObject = childObject.get("match"); + if (matchObject != null) { + teardownHasMatchObject.set(true); + } + }); + assertFalse(teardownHasMatchObject.get()); + } + + protected boolean getHumanDebug() { + return false; + } + + // only to help manually debug + protected void printTest(String testName, List tests) { + if (getHumanDebug()) { + System.out.println("\n************* " + testName + " *************"); + try (SequenceWriter sequenceWriter = MAPPER.writer().writeValues(System.out)) { + for (ObjectNode transformedTest : tests) { + sequenceWriter.write(transformedTest); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} From 106f2269d99bf88e79f80ee8423d406d4e3cc2bd Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 13:38:34 -0600 Subject: [PATCH 10/32] spotless --- .../rest/transform/warnings/RemoveWarnings.java | 2 -- .../test/rest/transform/TransformTests.java | 6 +----- .../transform/feature/InjectFeatureTests.java | 3 --- .../rest/transform/header/InjectHeaderTests.java | 1 - .../test/rest/transform/match/AddMatchTests.java | 16 +++++----------- .../rest/transform/match/RemoveMatchTests.java | 12 +----------- .../rest/transform/match/ReplaceMatchTests.java | 8 -------- .../transform/warnings/RemoveWarningsTests.java | 4 +--- 8 files changed, 8 insertions(+), 44 deletions(-) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java index 156bfdc344b30..8e4b8e5d06409 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; -import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; import java.util.ArrayList; import java.util.List; @@ -41,7 +40,6 @@ public void transformTest(ObjectNode doNodeParent) { return; } - List keepWarnings = new ArrayList<>(); arrayWarnings.elements().forEachRemaining(warning -> { String warningValue = warning.textValue(); diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java index 7504eef86d230..8313b4d5cbc18 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java @@ -114,14 +114,11 @@ protected List transformTests(List tests) { protected List transformTests(List tests, List> transforms) { List t = transformer.transformRestTests(new LinkedList<>(tests), transforms); if (getKnownFeatures() != null) { - getKnownFeatures().forEach(name -> { - validateFeatureNameExists(t, name); - }); + getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); } return t; } - protected List getKnownFeatures() { return null; } @@ -322,7 +319,6 @@ protected void validateSetupAndTearDownForMatchTests(List tests) { assertFalse(teardownHasMatchObject.get()); } - protected boolean getHumanDebug() { return false; } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java index 3f79da3910e0b..f587d0738ebfd 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/feature/InjectFeatureTests.java @@ -9,9 +9,7 @@ package org.elasticsearch.gradle.test.rest.transform.feature; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; import org.elasticsearch.gradle.test.rest.transform.TransformTests; -import org.junit.Before; import org.junit.Test; import java.util.List; @@ -102,5 +100,4 @@ public void testInjectFeatureWithFeatureAlreadyDefined() throws Exception { validateSetupAndTearDown(transformedTests); } - } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java index 5dfc45f4f476d..7b79a11777337 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/header/InjectHeaderTests.java @@ -72,4 +72,3 @@ protected boolean getHumanDebug() { return false; } } - diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java index 51cd7a6962ab0..73117ce56eb13 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatchTests.java @@ -10,20 +10,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -41,10 +34,11 @@ public void testAddAllNotSupported() throws Exception { JsonNode addNode = MAPPER.convertValue("_doc", JsonNode.class); assertEquals( "adding matches is only supported for named tests", - expectThrows(NullPointerException.class, () -> transformTests( - new LinkedList<>(tests), - Collections.singletonList(new AddMatch("_type", addNode, null)))) - .getMessage()); + expectThrows( + NullPointerException.class, + () -> transformTests(new LinkedList<>(tests), Collections.singletonList(new AddMatch("_type", addNode, null))) + ).getMessage() + ); } @Test diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java index 6b601b4605e01..63c1a55338678 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatchTests.java @@ -11,19 +11,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -35,16 +29,12 @@ public class RemoveMatchTests extends TransformTests { private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); private static final ObjectReader READER = MAPPER.readerFor(ObjectNode.class); - @Test public void testRemoveAll() throws Exception { String testName = "/rest/transform/match/match.yml"; List tests = getTests(testName); validateTest(tests, true, true); - List transformedTests = transformTests( - new LinkedList<>(tests), - Collections.singletonList(new RemoveMatch("_type")) - ); + List transformedTests = transformTests(new LinkedList<>(tests), Collections.singletonList(new RemoveMatch("_type"))); printTest(testName, transformedTests); validateTest(tests, false, true); } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java index 9e802cee14a50..bd3bedc3abd56 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatchTests.java @@ -10,20 +10,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLParser; -import org.elasticsearch.gradle.test.GradleUnitTestCase; -import org.elasticsearch.gradle.test.rest.transform.RestTestTransformer; import org.elasticsearch.gradle.test.rest.transform.TransformTests; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -34,7 +27,6 @@ public class ReplaceMatchTests extends TransformTests { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); - @Test public void testReplaceAll() throws Exception { String testName = "/rest/transform/match/match.yml"; diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java index 9840dccd66e73..c986549f245eb 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarningsTests.java @@ -11,10 +11,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransform; import org.elasticsearch.gradle.test.rest.transform.TransformTests; -import org.elasticsearch.gradle.test.rest.transform.feature.InjectFeatureTests; import org.junit.Test; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -57,7 +55,7 @@ public void testRemoveWarningWithPreExisting() throws Exception { */ @Test public void testRemoveWarningWithSinglePreExisting() throws Exception { - //For simplicity, when removing the last item, it does not remove the headers/teardown and leaves an empty array + // For simplicity, when removing the last item, it does not remove the headers/teardown and leaves an empty array String testName = "/rest/transform/warnings/with_existing_single_warnings.yml"; List tests = getTests(testName); validateSetupExist(tests); From d9ba6c0a81f0200670933e79c5df888e91bfdbab Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 13:41:40 -0600 Subject: [PATCH 11/32] checkstyle --- .../gradle/test/rest/transform/TransformTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java index bd2714d05b22f..543e5fe5e0bd6 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.LongAdder; import java.util.stream.Collectors; -abstract public class TransformTests extends GradleUnitTestCase { +public abstract class TransformTests extends GradleUnitTestCase { private static final YAMLFactory YAML_FACTORY = new YAMLFactory(); private static final ObjectMapper MAPPER = new ObjectMapper(YAML_FACTORY); From 857b2c60f679391b8b95f0979d670d85d8349cde Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 14:11:33 -0600 Subject: [PATCH 12/32] review changes --- .../gradle/test/rest/transform/TransformTests.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java index 543e5fe5e0bd6..fcea05e3f7f35 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java @@ -26,6 +26,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -112,14 +113,13 @@ protected List transformTests(List tests) { protected List transformTests(List tests, List> transforms) { List t = transformer.transformRestTests(new LinkedList<>(tests), transforms); - if (getKnownFeatures() != null) { - getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); - } + getKnownFeatures().forEach(name -> { validateFeatureNameExists(t, name); }); + return t; } protected List getKnownFeatures() { - return null; + return Collections.emptyList(); } protected List> getTransformations() { @@ -130,8 +130,7 @@ protected List> getTransformations() { } protected List getTests(String relativePath) throws Exception { - String testName = relativePath; - File testFile = new File(getClass().getResource(testName).toURI()); + File testFile = new File(getClass().getResource(relativePath).toURI()); YAMLParser yamlParser = YAML_FACTORY.createParser(testFile); return READER.readValues(yamlParser).readAll(); } From 98ee1f77b6aec487ad01f5bdaeb1af0085491302 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 15:35:46 -0600 Subject: [PATCH 13/32] more tests --- .../YamlRestCompatTestPluginFuncTest.groovy | 22 +++++- .../compat/RestCompatTestTransformTask.java | 20 ++++++ .../warnings/InjectAllowedWarnings.java | 4 +- .../transform/warnings/InjectWarnings.java | 29 +++++++- .../transform/warnings/RemoveWarnings.java | 11 +-- .../test/rest/transform/TransformTests.java | 72 ++++++++++++------- .../warnings/InjectWarningsTests.java | 24 +++++-- .../with_existing_single_warnings.yml | 2 +- .../warnings/with_existing_warnings.yml | 11 ++- .../warnings/without_existing_warnings.yml | 8 ++- 10 files changed, 158 insertions(+), 45 deletions(-) diff --git a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy index f61906e37d670..90309909fe72d 100644 --- a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy @@ -11,6 +11,7 @@ package org.elasticsearch.gradle import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectReader import com.fasterxml.jackson.databind.ObjectWriter +import com.fasterxml.jackson.databind.SequenceWriter import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.dataformat.yaml.YAMLFactory import org.elasticsearch.gradle.fixtures.AbstractRestResourcesFuncTest @@ -205,6 +206,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { task.removeMatch("_source.blah") task.removeMatch("_source.junk", "two") task.addMatch("_source.added", [name: 'jake', likes: 'cheese'], "one") + task.addWarning("one", "warning1", "warning2") }) // can't actually spin up test cluster from this test tasks.withType(Test).configureEach{ enabled = false } @@ -249,7 +251,9 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { --- setup: - skip: - features: "headers" + features: + - "headers" + - "warnings" --- one: - do: @@ -257,8 +261,11 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { index: "test" id: 1 headers: - Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" Accept: "application/vnd.elasticsearch+json;compatible-with=7" + Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" + warnings: + - "warning1" + - "warning2" - match: _source.values: - "z" @@ -280,8 +287,8 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { index: "test" id: 1 headers: - Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" Accept: "application/vnd.elasticsearch+json;compatible-with=7" + Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" - match: _source.values: - "foo" @@ -291,6 +298,15 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { - match: {} """.stripIndent()).readAll() + boolean humanDebug = false; + if(humanDebug) { + SequenceWriter sequenceWriter = WRITER.writeValues(System.out) + for (ObjectNode transformedTest : actual) { + sequenceWriter.write(transformedTest) + } + sequenceWriter.close() + } + expectedAll.eachWithIndex{ ObjectNode expected, int i -> assert expected == actual.get(i) } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java index edde99db4cac8..cfd6ede6f1cbb 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java @@ -22,6 +22,7 @@ import org.elasticsearch.gradle.test.rest.transform.match.AddMatch; import org.elasticsearch.gradle.test.rest.transform.match.RemoveMatch; import org.elasticsearch.gradle.test.rest.transform.match.ReplaceMatch; +import org.elasticsearch.gradle.test.rest.transform.warnings.InjectWarnings; import org.gradle.api.DefaultTask; import org.gradle.api.file.FileCollection; import org.gradle.api.file.FileTree; @@ -38,6 +39,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -130,6 +132,24 @@ public void addMatch(String subKey, Object value, String testName) { transformations.add(new AddMatch(subKey, MAPPER.convertValue(value, JsonNode.class), testName)); } + /** + * Adds one or more warnings to the given test + * @param testName the test name to add the warning + * @param warnings the warning(s) to add + */ + public void addWarning(String testName, String... warnings){ + transformations.add(new InjectWarnings(Arrays.asList(warnings), testName)); + } + + + public void removeWarning(){ + + } + + public void addAllowedWarning(){ + + } + @OutputDirectory public File getOutputDir() { return output; diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java index 8fb3da8d90615..502b297de592a 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java @@ -16,7 +16,9 @@ import java.util.List; -//TODO +/** + * A transformation to inject an allowed warning. + */ public class InjectAllowedWarnings extends FeatureInjector implements RestTestTransformByParentObject { private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java index 5d64e23fd3330..2cea36eba228e 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java @@ -11,23 +11,31 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import org.elasticsearch.gradle.test.rest.transform.RestTestContext; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; +import org.gradle.api.tasks.Input; import java.util.List; +import java.util.Objects; -//TODO +/** + * A transformation to inject an expected warning for a given test. + */ public class InjectWarnings extends FeatureInjector implements RestTestTransformByParentObject { private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); private final List warnings; + private final String testName; /** - * @param warnings The allowed warnings to inject + * @param warnings The warnings to inject + * @param testName The testName to inject */ - public InjectWarnings(List warnings) { + public InjectWarnings(List warnings, String testName) { this.warnings = warnings; + this.testName = Objects.requireNonNull(testName, "inject warnings is only supported for named tests"); } @Override @@ -50,4 +58,19 @@ public String getKeyToFind() { public String getSkipFeatureName() { return "warnings"; } + + @Override + public boolean shouldApply(RestTestContext testContext) { + return testName.equals(testContext.getTestName()); + } + + @Input + public List getWarnings() { + return warnings; + } + + @Input + public String getTestName() { + return testName; + } } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java index 8e4b8e5d06409..289413387a85c 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -17,11 +17,14 @@ import java.util.List; import java.util.Set; -//TODO -//NOTE: this does not remove the features from the setup and/or teardown. while it would be more technically correct to do so, the effort/complexity does not warrant it. -public class RemoveWarnings implements RestTestTransformByParentObject { +/** + * A transformation to to remove any warnings that match exactly. + * If this removes all of the warnings, this will not remove the feature from the setup and/or teardown and will leave behind an empty array + * While it would be more technically correct to do so, the effort/complexity does not warrant it, since for the expected usage it makes + * no difference. + */ - private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false); +public class RemoveWarnings implements RestTestTransformByParentObject { private final Set warnings; diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java index 34ee5109b3086..38499464e2786 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/TransformTests.java @@ -181,49 +181,67 @@ protected ObjectNode getSkipNode(ArrayNode setupNodeValue) { } protected void validateBodyHasWarnings(String featureName, List tests, Set expectedWarnings) { + validateBodyHasWarnings(featureName, null, tests, expectedWarnings); + } + + protected void validateBodyHasWarnings(String featureName, String testName, List tests, Set expectedWarnings) { + AtomicBoolean actuallyDidSomething = new AtomicBoolean(false); tests.forEach(test -> { Iterator> testsIterator = test.fields(); while (testsIterator.hasNext()) { Map.Entry testObject = testsIterator.next(); assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - testBody.forEach(arrayObject -> { - assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode testSection = (ObjectNode) arrayObject; - if (testSection.get("do") != null) { - ObjectNode doSection = (ObjectNode) testSection.get("do"); - assertThat(doSection.get(featureName), CoreMatchers.notNullValue()); - ArrayNode warningsNode = (ArrayNode) doSection.get(featureName); - LongAdder assertions = new LongAdder(); - warningsNode.forEach(warning -> { - if (expectedWarnings.contains(warning.asText())) { - assertions.increment(); - } - }); - assertThat(assertions.intValue(), CoreMatchers.equalTo(expectedWarnings.size())); - } - }); + if (testName == null || testName.equals(testObject.getKey())) { + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get(featureName), CoreMatchers.notNullValue()); + ArrayNode warningsNode = (ArrayNode) doSection.get(featureName); + LongAdder assertions = new LongAdder(); + warningsNode.forEach(warning -> { + if (expectedWarnings.contains(warning.asText())) { + assertions.increment(); + } + }); + assertThat(assertions.intValue(), CoreMatchers.equalTo(expectedWarnings.size())); + actuallyDidSomething.set(true); + } + }); + } } }); + assertTrue(actuallyDidSomething.get()); } protected void validateBodyHasNoWarnings(String featureName, List tests) { + validateBodyHasNoWarnings(featureName, null, tests); + } + + protected void validateBodyHasNoWarnings(String featureName, String testName, List tests) { + AtomicBoolean actuallyDidSomething = new AtomicBoolean(false); tests.forEach(test -> { Iterator> testsIterator = test.fields(); while (testsIterator.hasNext()) { Map.Entry testObject = testsIterator.next(); - assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); - ArrayNode testBody = (ArrayNode) testObject.getValue(); - testBody.forEach(arrayObject -> { - assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); - ObjectNode testSection = (ObjectNode) arrayObject; - if (testSection.get("do") != null) { - ObjectNode doSection = (ObjectNode) testSection.get("do"); - assertThat(doSection.get(featureName), CoreMatchers.nullValue()); - } - }); + if (testName == null || testName.equals(testObject.getKey())) { + assertThat(testObject.getValue(), CoreMatchers.instanceOf(ArrayNode.class)); + ArrayNode testBody = (ArrayNode) testObject.getValue(); + testBody.forEach(arrayObject -> { + assertThat(arrayObject, CoreMatchers.instanceOf(ObjectNode.class)); + ObjectNode testSection = (ObjectNode) arrayObject; + if (testSection.get("do") != null) { + ObjectNode doSection = (ObjectNode) testSection.get("do"); + assertThat(doSection.get(featureName), CoreMatchers.nullValue()); + actuallyDidSomething.set(true); + } + }); + } } }); + assertTrue(actuallyDidSomething.get()); } protected void validateBodyHasEmptyNoWarnings(String featureName, List tests) { diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java index 569403bd28691..969716d2af966 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java @@ -22,6 +22,21 @@ public class InjectWarningsTests extends InjectFeatureTests { Set addWarnings = Set.of("added warning"); private static final String WARNINGS = "warnings"; + + /** + * inject warning requires a test name to insert + */ + @Test + public void testInjectWarningsRequiresTestName() throws Exception { + String testName = "/rest/transform/warnings/without_existing_warnings.yml"; + List tests = getTests(testName); + validateSetupDoesNotExist(tests); + assertEquals("inject warnings is only supported for named tests", + expectThrows(NullPointerException.class, + () -> transformTests(tests, Collections.singletonList(new InjectWarnings(new ArrayList<>(addWarnings), null)))) + .getMessage()); + } + /** * test file does not any warnings defined */ @@ -33,7 +48,8 @@ public void testInjectWarningsNoPreExisting() throws Exception { List transformedTests = transformTests(tests); printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); - validateBodyHasWarnings(WARNINGS, transformedTests, addWarnings); + validateBodyHasWarnings(WARNINGS, "Test warnings", transformedTests, addWarnings); + validateBodyHasNoWarnings(WARNINGS, "Test another", transformedTests); } /** @@ -49,7 +65,7 @@ public void testInjectWarningsWithPreExisting() throws Exception { printTest(testName, transformedTests); validateSetupAndTearDown(transformedTests); validateBodyHasWarnings(WARNINGS, tests, Set.of("a", "b")); - validateBodyHasWarnings(WARNINGS, tests, addWarnings); + validateBodyHasWarnings(WARNINGS, "Test warnings", tests, addWarnings); } @Override @@ -59,11 +75,11 @@ protected List getKnownFeatures() { @Override protected List> getTransformations() { - return Collections.singletonList(new InjectWarnings(new ArrayList<>(addWarnings))); + return Collections.singletonList(new InjectWarnings(new ArrayList<>(addWarnings), "Test warnings")); } @Override protected boolean getHumanDebug() { - return false; + return true; } } diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml index 4edd0efd6a821..0c4a20cb683ca 100644 --- a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_single_warnings.yml @@ -3,7 +3,7 @@ setup: - skip: features: warnings --- -"Test with existing single warnings": +"Test warnings": - do: warnings: - "a" diff --git a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml index db929aa4c5503..8ced0e2fa830d 100644 --- a/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml +++ b/buildSrc/src/test/resources/rest/transform/warnings/with_existing_warnings.yml @@ -3,7 +3,16 @@ setup: - skip: features: warnings --- -"Test with existing warnings": +"Test warnings": + - do: + warnings: + - "a" + - "b" + something: + id: "something" + - match: { acknowledged: true } +--- +"Not the test to change": - do: warnings: - "a" diff --git a/buildSrc/src/test/resources/rest/transform/warnings/without_existing_warnings.yml b/buildSrc/src/test/resources/rest/transform/warnings/without_existing_warnings.yml index 681a10576daa8..423f5eb8462e6 100644 --- a/buildSrc/src/test/resources/rest/transform/warnings/without_existing_warnings.yml +++ b/buildSrc/src/test/resources/rest/transform/warnings/without_existing_warnings.yml @@ -1,5 +1,11 @@ --- -"Test without any warnings": +"Test warnings": + - do: + something: + id: "something" + - match: { acknowledged: true } +--- +"Test another": - do: something: id: "something" From cdd8ad5c073259b4acbbe7c1e4308e241de152d3 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 16:02:40 -0600 Subject: [PATCH 14/32] finish up testing --- .../YamlRestCompatTestPluginFuncTest.groovy | 35 ++++++++++++------- .../compat/RestCompatTestTransformTask.java | 19 +++++++--- .../warnings/InjectAllowedWarnings.java | 6 ++++ .../transform/warnings/RemoveWarnings.java | 5 +++ 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy index 90309909fe72d..b3a5bca7c66a1 100644 --- a/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/elasticsearch/gradle/YamlRestCompatTestPluginFuncTest.groovy @@ -207,6 +207,8 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { task.removeMatch("_source.junk", "two") task.addMatch("_source.added", [name: 'jake', likes: 'cheese'], "one") task.addWarning("one", "warning1", "warning2") + task.addAllowedWarning("added allowed warning") + task.removeWarning("one", "warning to remove") }) // can't actually spin up test cluster from this test tasks.withType(Test).configureEach{ enabled = false } @@ -220,6 +222,8 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { get: index: test id: 1 + warnings: + - "warning to remove" - match: { _source.values: ["foo"] } - match: { _type: "_foo" } - match: { _source.blah: 1234 } @@ -254,18 +258,21 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { features: - "headers" - "warnings" + - "allowed_warnings" --- one: - do: get: index: "test" id: 1 - headers: - Accept: "application/vnd.elasticsearch+json;compatible-with=7" - Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" warnings: - "warning1" - "warning2" + headers: + Accept: "application/vnd.elasticsearch+json;compatible-with=7" + Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" + allowed_warnings: + - "added allowed warning" - match: _source.values: - "z" @@ -289,6 +296,8 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { headers: Accept: "application/vnd.elasticsearch+json;compatible-with=7" Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" + allowed_warnings: + - "added allowed warning" - match: _source.values: - "foo" @@ -298,21 +307,21 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { - match: {} """.stripIndent()).readAll() - boolean humanDebug = false; - if(humanDebug) { - SequenceWriter sequenceWriter = WRITER.writeValues(System.out) - for (ObjectNode transformedTest : actual) { - sequenceWriter.write(transformedTest) - } - sequenceWriter.close() - } - expectedAll.eachWithIndex{ ObjectNode expected, int i -> + if(expected != actual.get(i)) { + println("\nTransformed Test:") + SequenceWriter sequenceWriter = WRITER.writeValues(System.out) + for (ObjectNode transformedTest : actual) { + sequenceWriter.write(transformedTest) + } + sequenceWriter.close() + } assert expected == actual.get(i) } when: - result = gradleRunner(transformTask).build() + //TODO: remove "-i" once https://github.com/elastic/elasticsearch/issues/68973 is resolved + result = gradleRunner(transformTask, "-i").build() then: result.task(transformTask).outcome == TaskOutcome.UP_TO_DATE diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java index cfd6ede6f1cbb..b087d95c81983 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java @@ -22,7 +22,9 @@ import org.elasticsearch.gradle.test.rest.transform.match.AddMatch; import org.elasticsearch.gradle.test.rest.transform.match.RemoveMatch; import org.elasticsearch.gradle.test.rest.transform.match.ReplaceMatch; +import org.elasticsearch.gradle.test.rest.transform.warnings.InjectAllowedWarnings; import org.elasticsearch.gradle.test.rest.transform.warnings.InjectWarnings; +import org.elasticsearch.gradle.test.rest.transform.warnings.RemoveWarnings; import org.gradle.api.DefaultTask; import org.gradle.api.file.FileCollection; import org.gradle.api.file.FileTree; @@ -43,6 +45,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import static org.elasticsearch.gradle.internal.rest.compat.YamlRestCompatTestPlugin.COMPATIBLE_VERSION; @@ -142,12 +145,20 @@ public void addWarning(String testName, String... warnings){ } - public void removeWarning(){ - + /** + * Removes one or more warnings + * @param warnings the warning(s) to remove + */ + public void removeWarning(String... warnings){ + transformations.add(new RemoveWarnings(Set.copyOf(Arrays.asList(warnings)))); } - public void addAllowedWarning(){ - + /** + * Adds one or more allowed warnings + * @param allowedWarnings the warning(s) to add + */ + public void addAllowedWarning(String... allowedWarnings){ + transformations.add(new InjectAllowedWarnings(Arrays.asList(allowedWarnings))); } @OutputDirectory diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java index 502b297de592a..6946c38f63b92 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; +import org.gradle.api.tasks.Input; import java.util.List; @@ -52,4 +53,9 @@ public String getKeyToFind() { public String getSkipFeatureName() { return "allowed_warnings"; } + + @Input + public List getAllowedWarnings() { + return allowedWarnings; + } } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java index 289413387a85c..8a48a2b28cbaa 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; +import org.gradle.api.tasks.Input; import java.util.ArrayList; import java.util.List; @@ -60,4 +61,8 @@ public String getKeyToFind() { return "do"; } + @Input + public Set getWarnings() { + return warnings; + } } From b51b72ff5944531943b4e69b21ae1551ef51ef16 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Mon, 15 Feb 2021 16:36:49 -0600 Subject: [PATCH 15/32] spotless --- .../rest/compat/RestCompatTestTransformTask.java | 7 +++---- .../test/rest/transform/warnings/RemoveWarnings.java | 1 - .../rest/transform/warnings/InjectWarningsTests.java | 12 +++++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java index b087d95c81983..fd0daa536b670 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java @@ -140,16 +140,15 @@ public void addMatch(String subKey, Object value, String testName) { * @param testName the test name to add the warning * @param warnings the warning(s) to add */ - public void addWarning(String testName, String... warnings){ + public void addWarning(String testName, String... warnings) { transformations.add(new InjectWarnings(Arrays.asList(warnings), testName)); } - /** * Removes one or more warnings * @param warnings the warning(s) to remove */ - public void removeWarning(String... warnings){ + public void removeWarning(String... warnings) { transformations.add(new RemoveWarnings(Set.copyOf(Arrays.asList(warnings)))); } @@ -157,7 +156,7 @@ public void removeWarning(String... warnings){ * Adds one or more allowed warnings * @param allowedWarnings the warning(s) to add */ - public void addAllowedWarning(String... allowedWarnings){ + public void addAllowedWarning(String... allowedWarnings) { transformations.add(new InjectAllowedWarnings(Arrays.asList(allowedWarnings))); } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java index 8a48a2b28cbaa..4a9510e8916ee 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -9,7 +9,6 @@ package org.elasticsearch.gradle.test.rest.transform.warnings; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.gradle.api.tasks.Input; diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java index 969716d2af966..2ac7cb401791c 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarningsTests.java @@ -22,7 +22,6 @@ public class InjectWarningsTests extends InjectFeatureTests { Set addWarnings = Set.of("added warning"); private static final String WARNINGS = "warnings"; - /** * inject warning requires a test name to insert */ @@ -31,10 +30,13 @@ public void testInjectWarningsRequiresTestName() throws Exception { String testName = "/rest/transform/warnings/without_existing_warnings.yml"; List tests = getTests(testName); validateSetupDoesNotExist(tests); - assertEquals("inject warnings is only supported for named tests", - expectThrows(NullPointerException.class, - () -> transformTests(tests, Collections.singletonList(new InjectWarnings(new ArrayList<>(addWarnings), null)))) - .getMessage()); + assertEquals( + "inject warnings is only supported for named tests", + expectThrows( + NullPointerException.class, + () -> transformTests(tests, Collections.singletonList(new InjectWarnings(new ArrayList<>(addWarnings), null))) + ).getMessage() + ); } /** From 5de4a306023f5593e6ad4d2b0fd3d8717ea5b553 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 16 Feb 2021 08:15:44 -0600 Subject: [PATCH 16/32] fix merge --- .../internal/rest/compat/RestCompatTestTransformTask.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java index fd700a3a725a9..ce19442e821ea 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java @@ -41,6 +41,8 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; From b60bf0ca8b1e225abc205769a1ad7ea4b4b1b332 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 16 Feb 2021 13:19:26 -0600 Subject: [PATCH 17/32] add @Internal for gradle tracked objects that look like getters --- .../gradle/test/rest/transform/headers/InjectHeaders.java | 3 +++ .../gradle/test/rest/transform/match/AddMatch.java | 2 ++ .../gradle/test/rest/transform/match/RemoveMatch.java | 2 ++ .../gradle/test/rest/transform/match/ReplaceMatch.java | 2 ++ .../test/rest/transform/warnings/InjectAllowedWarnings.java | 3 +++ .../gradle/test/rest/transform/warnings/InjectWarnings.java | 3 +++ .../gradle/test/rest/transform/warnings/RemoveWarnings.java | 2 ++ 7 files changed, 17 insertions(+) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java index 756037bf3fd47..508adac44d098 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java @@ -15,6 +15,7 @@ import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import java.util.Map; @@ -49,11 +50,13 @@ public void transformTest(ObjectNode doNodeParent) { } @Override + @Internal public String getKeyToFind() { return "do"; } @Override + @Internal public String getSkipFeatureName() { return "headers"; } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatch.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatch.java index dc17e7dbd9564..65d36e179dfd0 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatch.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/AddMatch.java @@ -15,6 +15,7 @@ import org.elasticsearch.gradle.test.rest.transform.RestTestContext; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentArray; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import java.util.Objects; @@ -48,6 +49,7 @@ public void transformTest(ArrayNode matchParent) { } @Override + @Internal public String getKeyOfArrayToFind() { // match objects are always in the array that is the direct child of the test name, i.e. // "my test name" : [ {"do" : ... }, { "match" : .... }] diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatch.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatch.java index aca4d151b0eb3..c2ef1f09638b3 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatch.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/RemoveMatch.java @@ -12,6 +12,7 @@ import org.elasticsearch.gradle.test.rest.transform.RestTestContext; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.Optional; /** @@ -33,6 +34,7 @@ public RemoveMatch(String removeKey, String testName) { } @Override + @Internal public String getKeyToFind() { return "match"; } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatch.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatch.java index a92e1f4d6a853..69d234009f983 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatch.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/match/ReplaceMatch.java @@ -13,6 +13,7 @@ import org.elasticsearch.gradle.test.rest.transform.RestTestContext; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.Optional; /** @@ -37,6 +38,7 @@ public ReplaceMatch(String replaceKey, JsonNode replacementNode, String testName } @Override + @Internal public String getKeyToFind() { return "match"; } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java index 6946c38f63b92..d87354a8a2bfb 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectAllowedWarnings.java @@ -14,6 +14,7 @@ import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import java.util.List; @@ -45,11 +46,13 @@ public void transformTest(ObjectNode doNodeParent) { } @Override + @Internal public String getKeyToFind() { return "do"; } @Override + @Internal public String getSkipFeatureName() { return "allowed_warnings"; } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java index 2cea36eba228e..16d81b21b2161 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/InjectWarnings.java @@ -15,6 +15,7 @@ import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import java.util.List; import java.util.Objects; @@ -50,11 +51,13 @@ public void transformTest(ObjectNode doNodeParent) { } @Override + @Internal public String getKeyToFind() { return "do"; } @Override + @Internal public String getSkipFeatureName() { return "warnings"; } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java index 4a9510e8916ee..3b782f3d2e0fe 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/warnings/RemoveWarnings.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; import java.util.ArrayList; import java.util.List; @@ -56,6 +57,7 @@ public void transformTest(ObjectNode doNodeParent) { } @Override + @Internal public String getKeyToFind() { return "do"; } From 7390a915d5612315ea6708556548fc624bd1c3bd Mon Sep 17 00:00:00 2001 From: pgomulka Date: Wed, 17 Feb 2021 11:28:27 +0100 Subject: [PATCH 18/32] index and get and testing --- rest-api-spec/build.gradle | 1 + server/build.gradle | 328 ++++++++++++++++++ .../elasticsearch/action/ActionModule.java | 11 + .../action/DocWriteResponse.java | 5 + .../elasticsearch/index/get/GetResult.java | 10 +- .../rest/action/document/RestGetActionV7.java | 51 +++ .../rest/action/document/RestIndexAction.java | 4 +- .../action/document/RestIndexActionV7.java | 114 ++++++ 8 files changed, 521 insertions(+), 3 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java create mode 100644 server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 8af6df35e6fa1..f7e9dd85757b6 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'elasticsearch.publish' apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.validate-rest-spec' apply plugin: 'elasticsearch.yaml-rest-test' +apply plugin: 'elasticsearch.yaml-rest-compat-test' restResources { restTests { diff --git a/server/build.gradle b/server/build.gradle index 6ce202a7e8ce7..0819a3cf19603 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -286,3 +286,331 @@ tasks.named("licenseHeaders").configure { excludes << 'org/apache/lucene/search/RegExp87*' excludes << 'org/apache/lucene/search/RegexpQuery87*' } + +//tasks.named("yamlRestCompatTest").configure { +// systemProperty 'tests.rest.blacklist', [ +// 'bulk/11_basic_with_types/Array of objects', +// 'bulk/11_basic_with_types/Empty _id with op_type create', +// 'bulk/11_basic_with_types/Empty _id', +// 'bulk/11_basic_with_types/empty action', +// 'bulk/21_list_of_strings_with_types/List of strings', +// 'bulk/31_big_string_with_types/One big string', +// 'bulk/41_source_with_types/Source filtering', +// 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', +// 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', +// 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', +// 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', +// 'cat.aliases/10_basic/Alias against closed index', +// 'cat.aliases/10_basic/Alias name', +// 'cat.aliases/10_basic/Alias sorting', +// 'cat.aliases/10_basic/Column headers', +// 'cat.aliases/10_basic/Complex alias', +// 'cat.aliases/10_basic/Empty cluster', +// 'cat.aliases/10_basic/Multiple alias names', +// 'cat.aliases/10_basic/Select columns', +// 'cat.aliases/10_basic/Simple alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', +// 'cat.allocation/10_basic/All Nodes', +// 'cat.allocation/10_basic/Bytes', +// 'cat.allocation/10_basic/Column headers', +// 'cat.allocation/10_basic/Empty cluster', +// 'cat.allocation/10_basic/Node ID', +// 'cat.allocation/10_basic/One index', +// 'cat.allocation/10_basic/Select columns', +// 'cat.count/10_basic/Test cat count output', +// 'cat.fielddata/10_basic/Test cat fielddata output', +// 'cat.health/10_basic/Empty cluster', +// 'cat.health/10_basic/With ts parameter', +// 'cat.indices/10_basic/Test cat indices output (no indices)', +// 'cat.indices/10_basic/Test cat indices output for closed index', +// 'cat.indices/10_basic/Test cat indices output', +// 'cat.indices/10_basic/Test cat indices sort', +// 'cat.indices/10_basic/Test cat indices using health status', +// 'cat.indices/10_basic/Test cat indices using wildcards', +// 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', +// 'cat.indices/20_hidden/Test cat indices output for hidden index', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', +// 'cat.nodeattrs/10_basic/Test cat nodes attrs output', +// 'cat.nodes/10_basic/Additional disk information', +// 'cat.nodes/10_basic/Test cat nodes output with full_id set', +// 'cat.nodes/10_basic/Test cat nodes output', +// 'cat.recovery/10_basic/Test cat recovery output for closed index', +// 'cat.recovery/10_basic/Test cat recovery output', +// 'cat.repositories/10_basic/Test cat repositories output', +// 'cat.repositories/10_basic/Test cat repositories sort', +// 'cat.segments/10_basic/Test cat segments output', +// 'cat.segments/10_basic/Test cat segments using wildcards', +// 'cat.shards/10_basic/Help', +// 'cat.shards/10_basic/Test cat shards output', +// 'cat.shards/10_basic/Test cat shards sort', +// 'cat.shards/10_basic/Test cat shards using wildcards', +// 'cat.snapshots/10_basic/Help', +// 'cat.snapshots/10_basic/Test cat snapshots output', +// 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', +// 'cat.tasks/10_basic/Test cat tasks output', +// 'cat.templates/10_basic/Column headers', +// 'cat.templates/10_basic/Filtered templates', +// 'cat.templates/10_basic/Mixture of legacy and composable templates', +// 'cat.templates/10_basic/Normal templates', +// 'cat.templates/10_basic/Select columns', +// 'cat.thread_pool/10_basic/Test cat thread_pool output', +// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', +// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', +// 'count/11_basic_with_types/count body without query element', +// 'count/11_basic_with_types/count with body', +// 'count/11_basic_with_types/count with empty body', +// 'create/11_with_id_with_types/Create with ID', +// 'create/36_external_version_with_types/External version', +// 'create/41_routing_with_types/Routing', +// 'create/61_refresh_with_types/Refresh', +// 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', +// 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', +// 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', +// 'delete/13_basic_with_types/Basic', +// 'delete/14_shard_header_with_types/Delete check shard header', +// 'delete/15_result_with_types/Delete result field', +// 'delete/21_cas_with_types/Internal version', +// 'delete/27_external_version_with_types/External version', +// 'delete/28_external_gte_version_with_types/External GTE version', +// 'delete/31_routing_with_types/Routing', +// 'delete/51_refresh_with_types/Refresh', +// 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'delete/61_missing_with_types/Missing document with catch', +// 'delete/61_missing_with_types/Missing document with ignore', +// 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', +// 'exists/11_basic_with_types/Basic', +// 'exists/41_routing_with_types/Routing', +// 'exists/61_realtime_refresh_with_types/Realtime Refresh', +// 'exists/71_defaults_with_types/Client-side default type', +// 'explain/10_basic/Basic explain with alias', +// 'explain/10_basic/Basic explain', +// 'explain/11_basic_with_types/Basic explain with alias', +// 'explain/11_basic_with_types/Basic explain', +// 'explain/11_basic_with_types/Explain body without query element', +// 'explain/20_source_filtering/Source filtering', +// 'explain/21_source_filtering_with_types/Source filtering', +// 'explain/31_query_string_with_types/explain with query_string parameters', +// 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', +// 'field_caps/10_basic/Get date_nanos field caps', +// 'field_caps/30_filter/Field caps with index filter', +// 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', +// 'get/11_basic_with_types/Basic', +// 'get/16_default_values_with_types/Default values', +// 'get/21_stored_fields_with_types/Stored fields', +// 'get/41_routing_with_types/Routing', +// 'get/51_with_headers_with_types/REST test with headers', +// 'get/61_realtime_refresh_with_types/Realtime Refresh', +// 'get/71_source_filtering_with_types/Source filtering', +// 'get/81_missing_with_types/Missing document with catch', +// 'get/81_missing_with_types/Missing document with ignore', +// 'get/91_versions_with_types/Versions', +// 'get_source/11_basic_with_types/Basic with types', +// 'get_source/16_default_values_with_types/Default values', +// 'get_source/41_routing_with_types/Routing', +// 'get_source/61_realtime_refresh_with_types/Realtime', +// 'get_source/71_source_filtering_with_types/Source filtering', +// 'get_source/81_missing_with_types/Missing document with catch', +// 'get_source/81_missing_with_types/Missing document with ignore', +// 'get_source/86_source_missing_with_types/Missing document source with catch', +// 'get_source/86_source_missing_with_types/Missing document source with ignore', +// 'index/11_with_id_with_types/Index with ID', +// 'index/13_result_with_types/Index result field', +// 'index/16_without_id_with_types/Index without ID', +// 'index/21_optype_with_types/Optype', +// 'index/37_external_version_with_types/External version', +// 'index/38_external_gte_version_with_types/External GTE version', +// 'index/41_routing_with_types/Routing', +// 'index/61_refresh_with_types/Refresh', +// 'index/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', +// 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', +// 'indices.create/10_basic/Create index with explicit _doc type', +// 'indices.create/10_basic/Create index without soft deletes', +// 'indices.create/11_basic_with_types/Create index with aliases', +// 'indices.create/11_basic_with_types/Create index with mappings', +// 'indices.create/11_basic_with_types/Create index with settings', +// 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', +// 'indices.create/11_basic_with_types/Create index with write aliases', +// 'indices.create/11_basic_with_types/Create index', +// 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', +// 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', +// 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', +// 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', +// 'indices.flush/10_basic/Flush stats', +// 'indices.flush/10_basic/Index synced flush rest test', +// 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', +// 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', +// 'indices.get/11_basic_with_types/Test include_type_name', +// 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', +// 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', +// 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', +// 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', +// 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_mapping', +// 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', +// 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', +// 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', +// 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', +// 'indices.get_mapping/20_missing_type/Non-existent type returns 404', +// 'indices.get_mapping/20_missing_type/Type missing when no types exist', +// 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', +// 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', +// 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', +// 'indices.get_template/11_basic_with_types/Get template with no mappings', +// 'indices.get_template/11_basic_with_types/Get template', +// 'indices.open/10_basic/?wait_for_active_shards default is deprecated', +// 'indices.open/10_basic/?wait_for_active_shards=index-setting', +// 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', +// 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', +// 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', +// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', +// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', +// 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', +// 'indices.put_mapping/all_path_options_with_types/put mapping in * index', +// 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', +// 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', +// 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', +// 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', +// 'indices.put_mapping/all_path_options_with_types/put one mapping per index', +// 'indices.put_template/10_basic/Put template with explicit _doc type', +// 'indices.put_template/11_basic_with_types/Put multiple template', +// 'indices.put_template/11_basic_with_types/Put template with empty mappings', +// 'indices.put_template/11_basic_with_types/Put template', +// 'indices.rollover/10_basic/Rollover index via API', +// 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', +// 'indices.rollover/30_max_size_condition/Rollover with max_size condition', +// 'indices.rollover/40_mapping/Mappings with explicit _doc type', +// 'indices.rollover/41_mapping_with_types/Typeless mapping', +// 'indices.segments/10_basic/basic segments test', +// 'indices.segments/10_basic/closed segments test', +// 'indices.shard_stores/10_basic/basic index test', +// 'indices.shard_stores/10_basic/multiple indices test', +// 'indices.shrink/30_copy_settings/Copy settings during shrink index', +// 'indices.split/30_copy_settings/Copy settings during split index', +// 'indices.stats/15_types/Types - _all metric', +// 'indices.stats/15_types/Types - blank', +// 'indices.stats/15_types/Types - indexing metric', +// 'indices.stats/15_types/Types - multi metric', +// 'indices.stats/15_types/Types - multi', +// 'indices.stats/15_types/Types - one', +// 'indices.stats/15_types/Types - pattern', +// 'indices.stats/15_types/Types - star', +// 'indices.stats/20_translog/Translog retention settings are deprecated', +// 'indices.stats/20_translog/Translog retention without soft_deletes', +// 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', +// 'indices.upgrade/10_basic/Basic test for upgrade indices', +// 'indices.upgrade/10_basic/Upgrade indices allow no indices', +// 'indices.upgrade/10_basic/Upgrade indices disallow no indices', +// 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', +// 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', +// 'mget/10_basic/Basic multi-get', +// 'mget/11_default_index_type/Default index/type', +// 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', +// 'mget/16_basic_with_types/Basic multi-get', +// 'mget/17_default_index/Default index/type', +// 'mget/18_non_existent_index_with_types/Non-existent index', +// 'mget/19_missing_metadata_with_types/Missing metadata', +// 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', +// 'mget/22_ids_with_types/IDs', +// 'mget/23_stored_fields_with_types/Stored fields', +// 'mget/41_routing_with_types/Routing', +// 'mget/61_realtime_refresh_with_types/Realtime Refresh', +// 'mget/71_source_filtering_with_types/Source filtering - exclude field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and include field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', +// 'mget/71_source_filtering_with_types/Source filtering - include field', +// 'mget/71_source_filtering_with_types/Source filtering - include nested field', +// 'mget/71_source_filtering_with_types/Source filtering - true/false', +// 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', +// 'mlt/20_docs/Basic mlt query with docs', +// 'mlt/30_unlike/Basic mlt query with unlike', +// 'msearch/12_basic_with_types/Basic multi-search', +// 'msearch/12_basic_with_types/Least impact smoke test', +// 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', +// 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', +// 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', +// 'search.aggregation/10_histogram/Deprecated _time order', +// 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', +// 'search.aggregation/20_terms/Deprecated _term order', +// 'search.aggregation/280_geohash_grid/Basic test', +// 'search.aggregation/290_geotile_grid/Basic test', +// 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it' s cached ', +// 'search.inner_hits/10_basic/Nested doc version and seqIDs', +// 'search.inner_hits/10_basic/Nested inner hits', +// 'search/100_stored_fields/Stored fields', +// 'search/10_source_filtering/docvalue_fields with default format', +// 'search/110_field_collapsing/field collapsing and from', +// 'search/110_field_collapsing/field collapsing and multiple inner_hits', +// 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', +// 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', +// 'search/110_field_collapsing/field collapsing, inner_hits and version', +// 'search/110_field_collapsing/field collapsing', +// 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', +// 'search/160_exists_query/Test exists query on _type field', +// 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', +// 'search/20_default_values/Basic search', +// 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', +// 'search/340_type_query/type query', +// 'search/40_indices_boost/Indices boost using object', +// 'search/70_response_filtering/Search with response filtering', +// 'search/90_search_after/search with search_after parameter', +// 'search_shards/10_basic/Search shards aliases with and without filters', +// 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', +// 'snapshot.get/10_basic/Get missing snapshot info throws an exception', +// 'snapshot.get/10_basic/Get snapshot info contains include_global_state', +// 'snapshot.get/10_basic/Get snapshot info when verbose is false', +// 'snapshot.get/10_basic/Get snapshot info with metadata', +// 'snapshot.get/10_basic/Get snapshot info', +// 'suggest/20_completion/Suggestions with source should work', +// 'termvectors/11_basic_with_types/Basic tests for termvector get', +// 'termvectors/20_issue7121/Term vector API should return ' found : false ' for docs between index and refresh', +// 'termvectors/21_issue7121_with_types/Term vector API should return ' found: false ' for docs between index and refresh', +// 'termvectors/31_realtime_with_types/Realtime Term Vectors', +// 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', +// 'update/14_shard_header_with_types/Update check shard header', +// 'update/15_result_with_types/Update result field', +// 'update/16_noop/Noop', +// 'update/21_doc_upsert_with_types/Doc upsert', +// 'update/24_doc_as_upsert_with_types/Doc as upsert', +// 'update/41_routing_with_types/Routing', +// 'update/61_refresh_with_types/Refresh', +// 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'update/81_source_filtering_with_types/Source filtering', +// 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', +// 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' +// +// ].join(',') +//} diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index 16ae2aa19870f..19898c5d7b7da 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -224,6 +224,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.NamedRegistry; +import org.elasticsearch.common.compatibility.RestApiCompatibleVersion; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.multibindings.MapBinder; @@ -351,10 +352,12 @@ import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.rest.action.document.RestDeleteAction; import org.elasticsearch.rest.action.document.RestGetAction; +import org.elasticsearch.rest.action.document.RestGetActionV7; import org.elasticsearch.rest.action.document.RestGetSourceAction; import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.rest.action.document.RestIndexAction.AutoIdHandler; import org.elasticsearch.rest.action.document.RestIndexAction.CreateHandler; +import org.elasticsearch.rest.action.document.RestIndexActionV7; import org.elasticsearch.rest.action.document.RestMultiGetAction; import org.elasticsearch.rest.action.document.RestMultiTermVectorsAction; import org.elasticsearch.rest.action.document.RestTermVectorsAction; @@ -776,6 +779,14 @@ public void initRestHandlers(Supplier nodesInCluster) { } } registerHandler.accept(new RestCatAction(catActions)); +// + if(RestApiCompatibleVersion.minimumSupported() == RestApiCompatibleVersion.V_7){ + registerHandler.accept(new RestIndexActionV7.CompatibleRestIndexAction()); + registerHandler.accept(new RestIndexActionV7.CompatibleCreateHandler()); + registerHandler.accept(new RestIndexActionV7.CompatibleAutoIdHandler(nodesInCluster)); + registerHandler.accept(new RestGetActionV7()); + } + } @Override diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java index 70b6ee4d49406..78d47f616a06a 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java @@ -14,6 +14,7 @@ import org.elasticsearch.action.support.replication.ReplicationResponse; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.compatibility.RestApiCompatibleVersion; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -41,6 +42,7 @@ * A base class for the response of a write operation that involves a single doc */ public abstract class DocWriteResponse extends ReplicationResponse implements WriteResponse, StatusToXContentObject { + static final String TYPE_FIELD_NAME = "_type"; private static final String _SHARDS = "_shards"; private static final String _INDEX = "_index"; @@ -293,6 +295,9 @@ private void writeWithoutShardId(StreamOutput out) throws IOException { @Override public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); + if (builder.getRestApiCompatibilityVersion() == RestApiCompatibleVersion.V_7) { + builder.field(TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME); + } innerToXContent(builder, params); builder.endObject(); return builder; diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index 12d87a950d913..e02766e7e50d7 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -12,11 +12,13 @@ import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.compatibility.RestApiCompatibleVersion; import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.document.DocumentField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.text.Text; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; @@ -40,6 +42,9 @@ public class GetResult implements Writeable, Iterable, ToXContentObject { + private static final String TYPE_FIELD_NAME = "_type"; + private static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); + public static final String _INDEX = "_index"; public static final String _ID = "_id"; private static final String _VERSION = "_version"; @@ -279,9 +284,12 @@ public XContentBuilder toXContentEmbedded(XContentBuilder builder, Params params } @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(_INDEX, index); + if (builder.getRestApiCompatibilityVersion() == RestApiCompatibleVersion.V_7) { + builder.field(TYPE_FIELD_NAME, SINGLE_MAPPING_TYPE); + } builder.field(_ID, id); if (isExists()) { if (version != -1) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java new file mode 100644 index 0000000000000..f10feced72653 --- /dev/null +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.rest.action.document; + +import org.elasticsearch.Version; +import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.compatibility.RestApiCompatibleVersion; +import org.elasticsearch.common.logging.DeprecationCategory; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.rest.RestRequest; + +import java.io.IOException; +import java.util.List; + +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.HEAD; + +public class RestGetActionV7 extends RestGetAction { + + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetActionV7.class); + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + + "document get requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; + + @Override + public String getName() { + return super.getName() + "_v7"; + } + + @Override + public List routes() { + return List.of(new Route(GET, "/{index}/{type}/{id}"), new Route(HEAD, "/{index}/{type}/{id}")); + } + + @Override + public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "get_with_types", TYPES_DEPRECATION_MESSAGE); + request.param("type"); + return super.prepareRequest(request, client); + } + + @Override + public RestApiCompatibleVersion compatibleWithVersion() { + return RestApiCompatibleVersion.V_7; + } +} diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 2c6aa2f3e3c55..91313a3661fde 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -42,7 +42,7 @@ public String getName() { return "document_index_action"; } - public static final class CreateHandler extends RestIndexAction { + public static class CreateHandler extends RestIndexAction { @Override public String getName() { @@ -70,7 +70,7 @@ void validateOpType(String opType) { } } - public static final class AutoIdHandler extends RestIndexAction { + public static class AutoIdHandler extends RestIndexAction { private final Supplier nodesInCluster; diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java new file mode 100644 index 0000000000000..a35b6adf46e57 --- /dev/null +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java @@ -0,0 +1,114 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.rest.action.document; + +import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.common.compatibility.RestApiCompatibleVersion; +import org.elasticsearch.common.logging.DeprecationCategory; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.rest.RestRequest; + +import java.io.IOException; +import java.util.List; +import java.util.function.Supplier; + +import static java.util.Collections.singletonList; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestRequest.Method.PUT; + +public class RestIndexActionV7 { + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in document " + + "index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, " + + "or /{index}/_create/{id})."; + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestIndexActionV7.class); + + private static void logDeprecationMessage() { + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "index_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.compatibleApiWarning("index_with_types", TYPES_DEPRECATION_MESSAGE); + } + + public static class CompatibleRestIndexAction extends RestIndexAction { + @Override + public String getName() { + return super.getName() + "_v7"; + } + + @Override + public List routes() { + return List.of(new Route(POST, "/{index}/{type}/{id}"), new Route(PUT, "/{index}/{type}/{id}")); + } + + @Override + public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { + logDeprecationMessage(); + request.param("type"); + return super.prepareRequest(request, client); + } + + @Override + public RestApiCompatibleVersion compatibleWithVersion() { + return RestApiCompatibleVersion.V_7; + } + } + + public static class CompatibleCreateHandler extends RestIndexAction.CreateHandler { + + @Override + public String getName() { + return "document_create_action_v7"; + } + + @Override + public List routes() { + return List.of(new Route(POST, "/{index}/{type}/{id}/_create"), new Route(PUT, "/{index}/{type}/{id}/_create")); + } + + @Override + public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { + logDeprecationMessage(); + request.param("type"); + return super.prepareRequest(request, client); + } + + @Override + public RestApiCompatibleVersion compatibleWithVersion() { + return RestApiCompatibleVersion.V_7; + } + } + + public static final class CompatibleAutoIdHandler extends RestIndexAction.AutoIdHandler { + + public CompatibleAutoIdHandler(Supplier nodesInCluster) { + super(nodesInCluster); + } + + @Override + public String getName() { + return "document_create_action_auto_id_v7"; + } + + @Override + public List routes() { + return singletonList(new Route(POST, "/{index}/{type}")); + } + + @Override + public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { + logDeprecationMessage(); + request.param("type"); + return super.prepareRequest(request, client); + } + + @Override + public RestApiCompatibleVersion compatibleWithVersion() { + return RestApiCompatibleVersion.V_7; + } + } +} From c83fdc19f2dfc01c2c83dc0fb06c68494d15e2eb Mon Sep 17 00:00:00 2001 From: pgomulka Date: Wed, 17 Feb 2021 16:15:44 +0100 Subject: [PATCH 19/32] import --- .../org/elasticsearch/rest/action/document/RestGetActionV7.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java index f10feced72653..9219518941e74 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java @@ -8,7 +8,6 @@ package org.elasticsearch.rest.action.document; -import org.elasticsearch.Version; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.compatibility.RestApiCompatibleVersion; import org.elasticsearch.common.logging.DeprecationCategory; From ec3cd228879505f512621737f01db1f95120c2c3 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Wed, 17 Feb 2021 16:17:21 +0100 Subject: [PATCH 20/32] move blacklist --- rest-api-spec/build.gradle | 329 +++++++++++++++++++++++++++++++++++++ server/build.gradle | 328 ------------------------------------ 2 files changed, 329 insertions(+), 328 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index f7e9dd85757b6..c6800a34b5ba3 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -22,3 +22,332 @@ testClusters.all { tasks.named("test").configure {enabled = false } tasks.named("jarHell").configure {enabled = false } + + +//tasks.named("yamlRestCompatTest").configure { +// systemProperty 'tests.rest.blacklist', [ +// 'bulk/11_basic_with_types/Array of objects', +// 'bulk/11_basic_with_types/Empty _id with op_type create', +// 'bulk/11_basic_with_types/Empty _id', +// 'bulk/11_basic_with_types/empty action', +// 'bulk/21_list_of_strings_with_types/List of strings', +// 'bulk/31_big_string_with_types/One big string', +// 'bulk/41_source_with_types/Source filtering', +// 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', +// 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', +// 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', +// 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', +// 'cat.aliases/10_basic/Alias against closed index', +// 'cat.aliases/10_basic/Alias name', +// 'cat.aliases/10_basic/Alias sorting', +// 'cat.aliases/10_basic/Column headers', +// 'cat.aliases/10_basic/Complex alias', +// 'cat.aliases/10_basic/Empty cluster', +// 'cat.aliases/10_basic/Multiple alias names', +// 'cat.aliases/10_basic/Select columns', +// 'cat.aliases/10_basic/Simple alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', +// 'cat.allocation/10_basic/All Nodes', +// 'cat.allocation/10_basic/Bytes', +// 'cat.allocation/10_basic/Column headers', +// 'cat.allocation/10_basic/Empty cluster', +// 'cat.allocation/10_basic/Node ID', +// 'cat.allocation/10_basic/One index', +// 'cat.allocation/10_basic/Select columns', +// 'cat.count/10_basic/Test cat count output', +// 'cat.fielddata/10_basic/Test cat fielddata output', +// 'cat.health/10_basic/Empty cluster', +// 'cat.health/10_basic/With ts parameter', +// 'cat.indices/10_basic/Test cat indices output (no indices)', +// 'cat.indices/10_basic/Test cat indices output for closed index', +// 'cat.indices/10_basic/Test cat indices output', +// 'cat.indices/10_basic/Test cat indices sort', +// 'cat.indices/10_basic/Test cat indices using health status', +// 'cat.indices/10_basic/Test cat indices using wildcards', +// 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', +// 'cat.indices/20_hidden/Test cat indices output for hidden index', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', +// 'cat.nodeattrs/10_basic/Test cat nodes attrs output', +// 'cat.nodes/10_basic/Additional disk information', +// 'cat.nodes/10_basic/Test cat nodes output with full_id set', +// 'cat.nodes/10_basic/Test cat nodes output', +// 'cat.recovery/10_basic/Test cat recovery output for closed index', +// 'cat.recovery/10_basic/Test cat recovery output', +// 'cat.repositories/10_basic/Test cat repositories output', +// 'cat.repositories/10_basic/Test cat repositories sort', +// 'cat.segments/10_basic/Test cat segments output', +// 'cat.segments/10_basic/Test cat segments using wildcards', +// 'cat.shards/10_basic/Help', +// 'cat.shards/10_basic/Test cat shards output', +// 'cat.shards/10_basic/Test cat shards sort', +// 'cat.shards/10_basic/Test cat shards using wildcards', +// 'cat.snapshots/10_basic/Help', +// 'cat.snapshots/10_basic/Test cat snapshots output', +// 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', +// 'cat.tasks/10_basic/Test cat tasks output', +// 'cat.templates/10_basic/Column headers', +// 'cat.templates/10_basic/Filtered templates', +// 'cat.templates/10_basic/Mixture of legacy and composable templates', +// 'cat.templates/10_basic/Normal templates', +// 'cat.templates/10_basic/Select columns', +// 'cat.thread_pool/10_basic/Test cat thread_pool output', +// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', +// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', +// 'count/11_basic_with_types/count body without query element', +// 'count/11_basic_with_types/count with body', +// 'count/11_basic_with_types/count with empty body', +// 'create/11_with_id_with_types/Create with ID', +// 'create/36_external_version_with_types/External version', +// 'create/41_routing_with_types/Routing', +// 'create/61_refresh_with_types/Refresh', +// 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', +// 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', +// 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', +// 'delete/13_basic_with_types/Basic', +// 'delete/14_shard_header_with_types/Delete check shard header', +// 'delete/15_result_with_types/Delete result field', +// 'delete/21_cas_with_types/Internal version', +// 'delete/27_external_version_with_types/External version', +// 'delete/28_external_gte_version_with_types/External GTE version', +// 'delete/31_routing_with_types/Routing', +// 'delete/51_refresh_with_types/Refresh', +// 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'delete/61_missing_with_types/Missing document with catch', +// 'delete/61_missing_with_types/Missing document with ignore', +// 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', +// 'exists/11_basic_with_types/Basic', +// 'exists/41_routing_with_types/Routing', +// 'exists/61_realtime_refresh_with_types/Realtime Refresh', +// 'exists/71_defaults_with_types/Client-side default type', +// 'explain/10_basic/Basic explain with alias', +// 'explain/10_basic/Basic explain', +// 'explain/11_basic_with_types/Basic explain with alias', +// 'explain/11_basic_with_types/Basic explain', +// 'explain/11_basic_with_types/Explain body without query element', +// 'explain/20_source_filtering/Source filtering', +// 'explain/21_source_filtering_with_types/Source filtering', +// 'explain/31_query_string_with_types/explain with query_string parameters', +// 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', +// 'field_caps/10_basic/Get date_nanos field caps', +// 'field_caps/30_filter/Field caps with index filter', +// 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', +// 'get/11_basic_with_types/Basic', +// 'get/16_default_values_with_types/Default values', +// 'get/21_stored_fields_with_types/Stored fields', +// 'get/41_routing_with_types/Routing', +// 'get/51_with_headers_with_types/REST test with headers', +// 'get/61_realtime_refresh_with_types/Realtime Refresh', +// 'get/71_source_filtering_with_types/Source filtering', +// 'get/81_missing_with_types/Missing document with catch', +// 'get/81_missing_with_types/Missing document with ignore', +// 'get/91_versions_with_types/Versions', +// 'get_source/11_basic_with_types/Basic with types', +// 'get_source/16_default_values_with_types/Default values', +// 'get_source/41_routing_with_types/Routing', +// 'get_source/61_realtime_refresh_with_types/Realtime', +// 'get_source/71_source_filtering_with_types/Source filtering', +// 'get_source/81_missing_with_types/Missing document with catch', +// 'get_source/81_missing_with_types/Missing document with ignore', +// 'get_source/86_source_missing_with_types/Missing document source with catch', +// 'get_source/86_source_missing_with_types/Missing document source with ignore', +// 'index/11_with_id_with_types/Index with ID', +// 'index/13_result_with_types/Index result field', +// 'index/16_without_id_with_types/Index without ID', +// 'index/21_optype_with_types/Optype', +// 'index/37_external_version_with_types/External version', +// 'index/38_external_gte_version_with_types/External GTE version', +// 'index/41_routing_with_types/Routing', +// 'index/61_refresh_with_types/Refresh', +// 'index/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', +// 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', +// 'indices.create/10_basic/Create index with explicit _doc type', +// 'indices.create/10_basic/Create index without soft deletes', +// 'indices.create/11_basic_with_types/Create index with aliases', +// 'indices.create/11_basic_with_types/Create index with mappings', +// 'indices.create/11_basic_with_types/Create index with settings', +// 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', +// 'indices.create/11_basic_with_types/Create index with write aliases', +// 'indices.create/11_basic_with_types/Create index', +// 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', +// 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', +// 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', +// 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', +// 'indices.flush/10_basic/Flush stats', +// 'indices.flush/10_basic/Index synced flush rest test', +// 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', +// 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', +// 'indices.get/11_basic_with_types/Test include_type_name', +// 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', +// 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', +// 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', +// 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', +// 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_mapping', +// 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', +// 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', +// 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', +// 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', +// 'indices.get_mapping/20_missing_type/Non-existent type returns 404', +// 'indices.get_mapping/20_missing_type/Type missing when no types exist', +// 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', +// 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', +// 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', +// 'indices.get_template/11_basic_with_types/Get template with no mappings', +// 'indices.get_template/11_basic_with_types/Get template', +// 'indices.open/10_basic/?wait_for_active_shards default is deprecated', +// 'indices.open/10_basic/?wait_for_active_shards=index-setting', +// 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', +// 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', +// 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', +// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', +// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', +// 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', +// 'indices.put_mapping/all_path_options_with_types/put mapping in * index', +// 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', +// 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', +// 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', +// 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', +// 'indices.put_mapping/all_path_options_with_types/put one mapping per index', +// 'indices.put_template/10_basic/Put template with explicit _doc type', +// 'indices.put_template/11_basic_with_types/Put multiple template', +// 'indices.put_template/11_basic_with_types/Put template with empty mappings', +// 'indices.put_template/11_basic_with_types/Put template', +// 'indices.rollover/10_basic/Rollover index via API', +// 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', +// 'indices.rollover/30_max_size_condition/Rollover with max_size condition', +// 'indices.rollover/40_mapping/Mappings with explicit _doc type', +// 'indices.rollover/41_mapping_with_types/Typeless mapping', +// 'indices.segments/10_basic/basic segments test', +// 'indices.segments/10_basic/closed segments test', +// 'indices.shard_stores/10_basic/basic index test', +// 'indices.shard_stores/10_basic/multiple indices test', +// 'indices.shrink/30_copy_settings/Copy settings during shrink index', +// 'indices.split/30_copy_settings/Copy settings during split index', +// 'indices.stats/15_types/Types - _all metric', +// 'indices.stats/15_types/Types - blank', +// 'indices.stats/15_types/Types - indexing metric', +// 'indices.stats/15_types/Types - multi metric', +// 'indices.stats/15_types/Types - multi', +// 'indices.stats/15_types/Types - one', +// 'indices.stats/15_types/Types - pattern', +// 'indices.stats/15_types/Types - star', +// 'indices.stats/20_translog/Translog retention settings are deprecated', +// 'indices.stats/20_translog/Translog retention without soft_deletes', +// 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', +// 'indices.upgrade/10_basic/Basic test for upgrade indices', +// 'indices.upgrade/10_basic/Upgrade indices allow no indices', +// 'indices.upgrade/10_basic/Upgrade indices disallow no indices', +// 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', +// 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', +// 'mget/10_basic/Basic multi-get', +// 'mget/11_default_index_type/Default index/type', +// 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', +// 'mget/16_basic_with_types/Basic multi-get', +// 'mget/17_default_index/Default index/type', +// 'mget/18_non_existent_index_with_types/Non-existent index', +// 'mget/19_missing_metadata_with_types/Missing metadata', +// 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', +// 'mget/22_ids_with_types/IDs', +// 'mget/23_stored_fields_with_types/Stored fields', +// 'mget/41_routing_with_types/Routing', +// 'mget/61_realtime_refresh_with_types/Realtime Refresh', +// 'mget/71_source_filtering_with_types/Source filtering - exclude field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and include field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', +// 'mget/71_source_filtering_with_types/Source filtering - include field', +// 'mget/71_source_filtering_with_types/Source filtering - include nested field', +// 'mget/71_source_filtering_with_types/Source filtering - true/false', +// 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', +// 'mlt/20_docs/Basic mlt query with docs', +// 'mlt/30_unlike/Basic mlt query with unlike', +// 'msearch/12_basic_with_types/Basic multi-search', +// 'msearch/12_basic_with_types/Least impact smoke test', +// 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', +// 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', +// 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', +// 'search.aggregation/10_histogram/Deprecated _time order', +// 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', +// 'search.aggregation/20_terms/Deprecated _term order', +// 'search.aggregation/280_geohash_grid/Basic test', +// 'search.aggregation/290_geotile_grid/Basic test', +// 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it' s cached ', +// 'search.inner_hits/10_basic/Nested doc version and seqIDs', +// 'search.inner_hits/10_basic/Nested inner hits', +// 'search/100_stored_fields/Stored fields', +// 'search/10_source_filtering/docvalue_fields with default format', +// 'search/110_field_collapsing/field collapsing and from', +// 'search/110_field_collapsing/field collapsing and multiple inner_hits', +// 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', +// 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', +// 'search/110_field_collapsing/field collapsing, inner_hits and version', +// 'search/110_field_collapsing/field collapsing', +// 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', +// 'search/160_exists_query/Test exists query on _type field', +// 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', +// 'search/20_default_values/Basic search', +// 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', +// 'search/340_type_query/type query', +// 'search/40_indices_boost/Indices boost using object', +// 'search/70_response_filtering/Search with response filtering', +// 'search/90_search_after/search with search_after parameter', +// 'search_shards/10_basic/Search shards aliases with and without filters', +// 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', +// 'snapshot.get/10_basic/Get missing snapshot info throws an exception', +// 'snapshot.get/10_basic/Get snapshot info contains include_global_state', +// 'snapshot.get/10_basic/Get snapshot info when verbose is false', +// 'snapshot.get/10_basic/Get snapshot info with metadata', +// 'snapshot.get/10_basic/Get snapshot info', +// 'suggest/20_completion/Suggestions with source should work', +// 'termvectors/11_basic_with_types/Basic tests for termvector get', +// 'termvectors/20_issue7121/Term vector API should return ' found : false ' for docs between index and refresh', +// 'termvectors/21_issue7121_with_types/Term vector API should return ' found: false ' for docs between index and refresh', +// 'termvectors/31_realtime_with_types/Realtime Term Vectors', +// 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', +// 'update/14_shard_header_with_types/Update check shard header', +// 'update/15_result_with_types/Update result field', +// 'update/16_noop/Noop', +// 'update/21_doc_upsert_with_types/Doc upsert', +// 'update/24_doc_as_upsert_with_types/Doc as upsert', +// 'update/41_routing_with_types/Routing', +// 'update/61_refresh_with_types/Refresh', +// 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'update/81_source_filtering_with_types/Source filtering', +// 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', +// 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' +// +// ].join(',') +//} diff --git a/server/build.gradle b/server/build.gradle index 0819a3cf19603..6ce202a7e8ce7 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -286,331 +286,3 @@ tasks.named("licenseHeaders").configure { excludes << 'org/apache/lucene/search/RegExp87*' excludes << 'org/apache/lucene/search/RegexpQuery87*' } - -//tasks.named("yamlRestCompatTest").configure { -// systemProperty 'tests.rest.blacklist', [ -// 'bulk/11_basic_with_types/Array of objects', -// 'bulk/11_basic_with_types/Empty _id with op_type create', -// 'bulk/11_basic_with_types/Empty _id', -// 'bulk/11_basic_with_types/empty action', -// 'bulk/21_list_of_strings_with_types/List of strings', -// 'bulk/31_big_string_with_types/One big string', -// 'bulk/41_source_with_types/Source filtering', -// 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', -// 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', -// 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', -// 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', -// 'cat.aliases/10_basic/Alias against closed index', -// 'cat.aliases/10_basic/Alias name', -// 'cat.aliases/10_basic/Alias sorting', -// 'cat.aliases/10_basic/Column headers', -// 'cat.aliases/10_basic/Complex alias', -// 'cat.aliases/10_basic/Empty cluster', -// 'cat.aliases/10_basic/Multiple alias names', -// 'cat.aliases/10_basic/Select columns', -// 'cat.aliases/10_basic/Simple alias', -// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', -// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', -// 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', -// 'cat.allocation/10_basic/All Nodes', -// 'cat.allocation/10_basic/Bytes', -// 'cat.allocation/10_basic/Column headers', -// 'cat.allocation/10_basic/Empty cluster', -// 'cat.allocation/10_basic/Node ID', -// 'cat.allocation/10_basic/One index', -// 'cat.allocation/10_basic/Select columns', -// 'cat.count/10_basic/Test cat count output', -// 'cat.fielddata/10_basic/Test cat fielddata output', -// 'cat.health/10_basic/Empty cluster', -// 'cat.health/10_basic/With ts parameter', -// 'cat.indices/10_basic/Test cat indices output (no indices)', -// 'cat.indices/10_basic/Test cat indices output for closed index', -// 'cat.indices/10_basic/Test cat indices output', -// 'cat.indices/10_basic/Test cat indices sort', -// 'cat.indices/10_basic/Test cat indices using health status', -// 'cat.indices/10_basic/Test cat indices using wildcards', -// 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', -// 'cat.indices/20_hidden/Test cat indices output for hidden index', -// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', -// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', -// 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', -// 'cat.nodeattrs/10_basic/Test cat nodes attrs output', -// 'cat.nodes/10_basic/Additional disk information', -// 'cat.nodes/10_basic/Test cat nodes output with full_id set', -// 'cat.nodes/10_basic/Test cat nodes output', -// 'cat.recovery/10_basic/Test cat recovery output for closed index', -// 'cat.recovery/10_basic/Test cat recovery output', -// 'cat.repositories/10_basic/Test cat repositories output', -// 'cat.repositories/10_basic/Test cat repositories sort', -// 'cat.segments/10_basic/Test cat segments output', -// 'cat.segments/10_basic/Test cat segments using wildcards', -// 'cat.shards/10_basic/Help', -// 'cat.shards/10_basic/Test cat shards output', -// 'cat.shards/10_basic/Test cat shards sort', -// 'cat.shards/10_basic/Test cat shards using wildcards', -// 'cat.snapshots/10_basic/Help', -// 'cat.snapshots/10_basic/Test cat snapshots output', -// 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', -// 'cat.tasks/10_basic/Test cat tasks output', -// 'cat.templates/10_basic/Column headers', -// 'cat.templates/10_basic/Filtered templates', -// 'cat.templates/10_basic/Mixture of legacy and composable templates', -// 'cat.templates/10_basic/Normal templates', -// 'cat.templates/10_basic/Select columns', -// 'cat.thread_pool/10_basic/Test cat thread_pool output', -// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', -// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', -// 'count/11_basic_with_types/count body without query element', -// 'count/11_basic_with_types/count with body', -// 'count/11_basic_with_types/count with empty body', -// 'create/11_with_id_with_types/Create with ID', -// 'create/36_external_version_with_types/External version', -// 'create/41_routing_with_types/Routing', -// 'create/61_refresh_with_types/Refresh', -// 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', -// 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', -// 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', -// 'delete/13_basic_with_types/Basic', -// 'delete/14_shard_header_with_types/Delete check shard header', -// 'delete/15_result_with_types/Delete result field', -// 'delete/21_cas_with_types/Internal version', -// 'delete/27_external_version_with_types/External version', -// 'delete/28_external_gte_version_with_types/External GTE version', -// 'delete/31_routing_with_types/Routing', -// 'delete/51_refresh_with_types/Refresh', -// 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'delete/61_missing_with_types/Missing document with catch', -// 'delete/61_missing_with_types/Missing document with ignore', -// 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', -// 'exists/11_basic_with_types/Basic', -// 'exists/41_routing_with_types/Routing', -// 'exists/61_realtime_refresh_with_types/Realtime Refresh', -// 'exists/71_defaults_with_types/Client-side default type', -// 'explain/10_basic/Basic explain with alias', -// 'explain/10_basic/Basic explain', -// 'explain/11_basic_with_types/Basic explain with alias', -// 'explain/11_basic_with_types/Basic explain', -// 'explain/11_basic_with_types/Explain body without query element', -// 'explain/20_source_filtering/Source filtering', -// 'explain/21_source_filtering_with_types/Source filtering', -// 'explain/31_query_string_with_types/explain with query_string parameters', -// 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', -// 'field_caps/10_basic/Get date_nanos field caps', -// 'field_caps/30_filter/Field caps with index filter', -// 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', -// 'get/11_basic_with_types/Basic', -// 'get/16_default_values_with_types/Default values', -// 'get/21_stored_fields_with_types/Stored fields', -// 'get/41_routing_with_types/Routing', -// 'get/51_with_headers_with_types/REST test with headers', -// 'get/61_realtime_refresh_with_types/Realtime Refresh', -// 'get/71_source_filtering_with_types/Source filtering', -// 'get/81_missing_with_types/Missing document with catch', -// 'get/81_missing_with_types/Missing document with ignore', -// 'get/91_versions_with_types/Versions', -// 'get_source/11_basic_with_types/Basic with types', -// 'get_source/16_default_values_with_types/Default values', -// 'get_source/41_routing_with_types/Routing', -// 'get_source/61_realtime_refresh_with_types/Realtime', -// 'get_source/71_source_filtering_with_types/Source filtering', -// 'get_source/81_missing_with_types/Missing document with catch', -// 'get_source/81_missing_with_types/Missing document with ignore', -// 'get_source/86_source_missing_with_types/Missing document source with catch', -// 'get_source/86_source_missing_with_types/Missing document source with ignore', -// 'index/11_with_id_with_types/Index with ID', -// 'index/13_result_with_types/Index result field', -// 'index/16_without_id_with_types/Index without ID', -// 'index/21_optype_with_types/Optype', -// 'index/37_external_version_with_types/External version', -// 'index/38_external_gte_version_with_types/External GTE version', -// 'index/41_routing_with_types/Routing', -// 'index/61_refresh_with_types/Refresh', -// 'index/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', -// 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', -// 'indices.create/10_basic/Create index with explicit _doc type', -// 'indices.create/10_basic/Create index without soft deletes', -// 'indices.create/11_basic_with_types/Create index with aliases', -// 'indices.create/11_basic_with_types/Create index with mappings', -// 'indices.create/11_basic_with_types/Create index with settings', -// 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', -// 'indices.create/11_basic_with_types/Create index with write aliases', -// 'indices.create/11_basic_with_types/Create index', -// 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', -// 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', -// 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', -// 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', -// 'indices.flush/10_basic/Flush stats', -// 'indices.flush/10_basic/Index synced flush rest test', -// 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', -// 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', -// 'indices.get/11_basic_with_types/Test include_type_name', -// 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', -// 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', -// 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', -// 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', -// 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /_mapping', -// 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', -// 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', -// 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', -// 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', -// 'indices.get_mapping/20_missing_type/Non-existent type returns 404', -// 'indices.get_mapping/20_missing_type/Type missing when no types exist', -// 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', -// 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', -// 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', -// 'indices.get_template/11_basic_with_types/Get template with no mappings', -// 'indices.get_template/11_basic_with_types/Get template', -// 'indices.open/10_basic/?wait_for_active_shards default is deprecated', -// 'indices.open/10_basic/?wait_for_active_shards=index-setting', -// 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', -// 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', -// 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', -// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', -// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', -// 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', -// 'indices.put_mapping/all_path_options_with_types/put mapping in * index', -// 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', -// 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', -// 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', -// 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', -// 'indices.put_mapping/all_path_options_with_types/put one mapping per index', -// 'indices.put_template/10_basic/Put template with explicit _doc type', -// 'indices.put_template/11_basic_with_types/Put multiple template', -// 'indices.put_template/11_basic_with_types/Put template with empty mappings', -// 'indices.put_template/11_basic_with_types/Put template', -// 'indices.rollover/10_basic/Rollover index via API', -// 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', -// 'indices.rollover/30_max_size_condition/Rollover with max_size condition', -// 'indices.rollover/40_mapping/Mappings with explicit _doc type', -// 'indices.rollover/41_mapping_with_types/Typeless mapping', -// 'indices.segments/10_basic/basic segments test', -// 'indices.segments/10_basic/closed segments test', -// 'indices.shard_stores/10_basic/basic index test', -// 'indices.shard_stores/10_basic/multiple indices test', -// 'indices.shrink/30_copy_settings/Copy settings during shrink index', -// 'indices.split/30_copy_settings/Copy settings during split index', -// 'indices.stats/15_types/Types - _all metric', -// 'indices.stats/15_types/Types - blank', -// 'indices.stats/15_types/Types - indexing metric', -// 'indices.stats/15_types/Types - multi metric', -// 'indices.stats/15_types/Types - multi', -// 'indices.stats/15_types/Types - one', -// 'indices.stats/15_types/Types - pattern', -// 'indices.stats/15_types/Types - star', -// 'indices.stats/20_translog/Translog retention settings are deprecated', -// 'indices.stats/20_translog/Translog retention without soft_deletes', -// 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', -// 'indices.upgrade/10_basic/Basic test for upgrade indices', -// 'indices.upgrade/10_basic/Upgrade indices allow no indices', -// 'indices.upgrade/10_basic/Upgrade indices disallow no indices', -// 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', -// 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', -// 'mget/10_basic/Basic multi-get', -// 'mget/11_default_index_type/Default index/type', -// 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', -// 'mget/16_basic_with_types/Basic multi-get', -// 'mget/17_default_index/Default index/type', -// 'mget/18_non_existent_index_with_types/Non-existent index', -// 'mget/19_missing_metadata_with_types/Missing metadata', -// 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', -// 'mget/22_ids_with_types/IDs', -// 'mget/23_stored_fields_with_types/Stored fields', -// 'mget/41_routing_with_types/Routing', -// 'mget/61_realtime_refresh_with_types/Realtime Refresh', -// 'mget/71_source_filtering_with_types/Source filtering - exclude field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and include field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', -// 'mget/71_source_filtering_with_types/Source filtering - include field', -// 'mget/71_source_filtering_with_types/Source filtering - include nested field', -// 'mget/71_source_filtering_with_types/Source filtering - true/false', -// 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', -// 'mlt/20_docs/Basic mlt query with docs', -// 'mlt/30_unlike/Basic mlt query with unlike', -// 'msearch/12_basic_with_types/Basic multi-search', -// 'msearch/12_basic_with_types/Least impact smoke test', -// 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', -// 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', -// 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', -// 'search.aggregation/10_histogram/Deprecated _time order', -// 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', -// 'search.aggregation/20_terms/Deprecated _term order', -// 'search.aggregation/280_geohash_grid/Basic test', -// 'search.aggregation/290_geotile_grid/Basic test', -// 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it' s cached ', -// 'search.inner_hits/10_basic/Nested doc version and seqIDs', -// 'search.inner_hits/10_basic/Nested inner hits', -// 'search/100_stored_fields/Stored fields', -// 'search/10_source_filtering/docvalue_fields with default format', -// 'search/110_field_collapsing/field collapsing and from', -// 'search/110_field_collapsing/field collapsing and multiple inner_hits', -// 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', -// 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', -// 'search/110_field_collapsing/field collapsing, inner_hits and version', -// 'search/110_field_collapsing/field collapsing', -// 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', -// 'search/160_exists_query/Test exists query on _type field', -// 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', -// 'search/20_default_values/Basic search', -// 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', -// 'search/340_type_query/type query', -// 'search/40_indices_boost/Indices boost using object', -// 'search/70_response_filtering/Search with response filtering', -// 'search/90_search_after/search with search_after parameter', -// 'search_shards/10_basic/Search shards aliases with and without filters', -// 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', -// 'snapshot.get/10_basic/Get missing snapshot info throws an exception', -// 'snapshot.get/10_basic/Get snapshot info contains include_global_state', -// 'snapshot.get/10_basic/Get snapshot info when verbose is false', -// 'snapshot.get/10_basic/Get snapshot info with metadata', -// 'snapshot.get/10_basic/Get snapshot info', -// 'suggest/20_completion/Suggestions with source should work', -// 'termvectors/11_basic_with_types/Basic tests for termvector get', -// 'termvectors/20_issue7121/Term vector API should return ' found : false ' for docs between index and refresh', -// 'termvectors/21_issue7121_with_types/Term vector API should return ' found: false ' for docs between index and refresh', -// 'termvectors/31_realtime_with_types/Realtime Term Vectors', -// 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', -// 'update/14_shard_header_with_types/Update check shard header', -// 'update/15_result_with_types/Update result field', -// 'update/16_noop/Noop', -// 'update/21_doc_upsert_with_types/Doc upsert', -// 'update/24_doc_as_upsert_with_types/Doc as upsert', -// 'update/41_routing_with_types/Routing', -// 'update/61_refresh_with_types/Refresh', -// 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'update/81_source_filtering_with_types/Source filtering', -// 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', -// 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' -// -// ].join(',') -//} From b99c751cfb0bfd3e858fd2ec85a16d4b83a5a51e Mon Sep 17 00:00:00 2001 From: pgomulka Date: Thu, 18 Feb 2021 11:13:38 +0100 Subject: [PATCH 21/32] testing not working --- rest-api-spec/build.gradle | 641 +++++++++++++++++++------------------ 1 file changed, 326 insertions(+), 315 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index c6800a34b5ba3..2cd562021135e 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -24,139 +24,139 @@ tasks.named("test").configure {enabled = false } tasks.named("jarHell").configure {enabled = false } -//tasks.named("yamlRestCompatTest").configure { -// systemProperty 'tests.rest.blacklist', [ -// 'bulk/11_basic_with_types/Array of objects', -// 'bulk/11_basic_with_types/Empty _id with op_type create', -// 'bulk/11_basic_with_types/Empty _id', -// 'bulk/11_basic_with_types/empty action', -// 'bulk/21_list_of_strings_with_types/List of strings', -// 'bulk/31_big_string_with_types/One big string', -// 'bulk/41_source_with_types/Source filtering', -// 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', -// 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', -// 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', -// 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', -// 'cat.aliases/10_basic/Alias against closed index', -// 'cat.aliases/10_basic/Alias name', -// 'cat.aliases/10_basic/Alias sorting', -// 'cat.aliases/10_basic/Column headers', -// 'cat.aliases/10_basic/Complex alias', -// 'cat.aliases/10_basic/Empty cluster', -// 'cat.aliases/10_basic/Multiple alias names', -// 'cat.aliases/10_basic/Select columns', -// 'cat.aliases/10_basic/Simple alias', -// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', -// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', -// 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', -// 'cat.allocation/10_basic/All Nodes', -// 'cat.allocation/10_basic/Bytes', -// 'cat.allocation/10_basic/Column headers', -// 'cat.allocation/10_basic/Empty cluster', -// 'cat.allocation/10_basic/Node ID', -// 'cat.allocation/10_basic/One index', -// 'cat.allocation/10_basic/Select columns', -// 'cat.count/10_basic/Test cat count output', -// 'cat.fielddata/10_basic/Test cat fielddata output', -// 'cat.health/10_basic/Empty cluster', -// 'cat.health/10_basic/With ts parameter', -// 'cat.indices/10_basic/Test cat indices output (no indices)', -// 'cat.indices/10_basic/Test cat indices output for closed index', -// 'cat.indices/10_basic/Test cat indices output', -// 'cat.indices/10_basic/Test cat indices sort', -// 'cat.indices/10_basic/Test cat indices using health status', -// 'cat.indices/10_basic/Test cat indices using wildcards', -// 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', -// 'cat.indices/20_hidden/Test cat indices output for hidden index', -// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', -// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', -// 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', -// 'cat.nodeattrs/10_basic/Test cat nodes attrs output', -// 'cat.nodes/10_basic/Additional disk information', -// 'cat.nodes/10_basic/Test cat nodes output with full_id set', -// 'cat.nodes/10_basic/Test cat nodes output', -// 'cat.recovery/10_basic/Test cat recovery output for closed index', -// 'cat.recovery/10_basic/Test cat recovery output', -// 'cat.repositories/10_basic/Test cat repositories output', -// 'cat.repositories/10_basic/Test cat repositories sort', -// 'cat.segments/10_basic/Test cat segments output', -// 'cat.segments/10_basic/Test cat segments using wildcards', -// 'cat.shards/10_basic/Help', -// 'cat.shards/10_basic/Test cat shards output', -// 'cat.shards/10_basic/Test cat shards sort', -// 'cat.shards/10_basic/Test cat shards using wildcards', -// 'cat.snapshots/10_basic/Help', -// 'cat.snapshots/10_basic/Test cat snapshots output', -// 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', -// 'cat.tasks/10_basic/Test cat tasks output', -// 'cat.templates/10_basic/Column headers', -// 'cat.templates/10_basic/Filtered templates', -// 'cat.templates/10_basic/Mixture of legacy and composable templates', -// 'cat.templates/10_basic/Normal templates', -// 'cat.templates/10_basic/Select columns', -// 'cat.thread_pool/10_basic/Test cat thread_pool output', -// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', -// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', -// 'count/11_basic_with_types/count body without query element', -// 'count/11_basic_with_types/count with body', -// 'count/11_basic_with_types/count with empty body', -// 'create/11_with_id_with_types/Create with ID', -// 'create/36_external_version_with_types/External version', -// 'create/41_routing_with_types/Routing', -// 'create/61_refresh_with_types/Refresh', -// 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', -// 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', -// 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', -// 'delete/13_basic_with_types/Basic', -// 'delete/14_shard_header_with_types/Delete check shard header', -// 'delete/15_result_with_types/Delete result field', -// 'delete/21_cas_with_types/Internal version', -// 'delete/27_external_version_with_types/External version', -// 'delete/28_external_gte_version_with_types/External GTE version', -// 'delete/31_routing_with_types/Routing', -// 'delete/51_refresh_with_types/Refresh', -// 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'delete/61_missing_with_types/Missing document with catch', -// 'delete/61_missing_with_types/Missing document with ignore', -// 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', -// 'exists/11_basic_with_types/Basic', -// 'exists/41_routing_with_types/Routing', -// 'exists/61_realtime_refresh_with_types/Realtime Refresh', -// 'exists/71_defaults_with_types/Client-side default type', -// 'explain/10_basic/Basic explain with alias', -// 'explain/10_basic/Basic explain', -// 'explain/11_basic_with_types/Basic explain with alias', -// 'explain/11_basic_with_types/Basic explain', -// 'explain/11_basic_with_types/Explain body without query element', -// 'explain/20_source_filtering/Source filtering', -// 'explain/21_source_filtering_with_types/Source filtering', -// 'explain/31_query_string_with_types/explain with query_string parameters', -// 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', -// 'field_caps/10_basic/Get date_nanos field caps', -// 'field_caps/30_filter/Field caps with index filter', -// 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', -// 'get/11_basic_with_types/Basic', -// 'get/16_default_values_with_types/Default values', -// 'get/21_stored_fields_with_types/Stored fields', -// 'get/41_routing_with_types/Routing', -// 'get/51_with_headers_with_types/REST test with headers', -// 'get/61_realtime_refresh_with_types/Realtime Refresh', -// 'get/71_source_filtering_with_types/Source filtering', -// 'get/81_missing_with_types/Missing document with catch', -// 'get/81_missing_with_types/Missing document with ignore', -// 'get/91_versions_with_types/Versions', -// 'get_source/11_basic_with_types/Basic with types', -// 'get_source/16_default_values_with_types/Default values', -// 'get_source/41_routing_with_types/Routing', -// 'get_source/61_realtime_refresh_with_types/Realtime', -// 'get_source/71_source_filtering_with_types/Source filtering', -// 'get_source/81_missing_with_types/Missing document with catch', -// 'get_source/81_missing_with_types/Missing document with ignore', -// 'get_source/86_source_missing_with_types/Missing document source with catch', -// 'get_source/86_source_missing_with_types/Missing document source with ignore', +tasks.named("yamlRestCompatTest").configure { + systemProperty 'tests.rest.blacklist', [ + 'bulk/11_basic_with_types/Array of objects', + 'bulk/11_basic_with_types/Empty _id with op_type create', + 'bulk/11_basic_with_types/Empty _id', + 'bulk/11_basic_with_types/empty action', + 'bulk/21_list_of_strings_with_types/List of strings', + 'bulk/31_big_string_with_types/One big string', + 'bulk/41_source_with_types/Source filtering', + 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', + 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', + 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', + 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', + 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', + 'cat.aliases/10_basic/Alias against closed index', + 'cat.aliases/10_basic/Alias name', + 'cat.aliases/10_basic/Alias sorting', + 'cat.aliases/10_basic/Column headers', + 'cat.aliases/10_basic/Complex alias', + 'cat.aliases/10_basic/Empty cluster', + 'cat.aliases/10_basic/Multiple alias names', + 'cat.aliases/10_basic/Select columns', + 'cat.aliases/10_basic/Simple alias', + 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', + 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', + 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', + 'cat.allocation/10_basic/All Nodes', + 'cat.allocation/10_basic/Bytes', + 'cat.allocation/10_basic/Column headers', + 'cat.allocation/10_basic/Empty cluster', + 'cat.allocation/10_basic/Node ID', + 'cat.allocation/10_basic/One index', + 'cat.allocation/10_basic/Select columns', + 'cat.count/10_basic/Test cat count output', + 'cat.fielddata/10_basic/Test cat fielddata output', + 'cat.health/10_basic/Empty cluster', + 'cat.health/10_basic/With ts parameter', + 'cat.indices/10_basic/Test cat indices output (no indices)', + 'cat.indices/10_basic/Test cat indices output for closed index', + 'cat.indices/10_basic/Test cat indices output', + 'cat.indices/10_basic/Test cat indices sort', + 'cat.indices/10_basic/Test cat indices using health status', + 'cat.indices/10_basic/Test cat indices using wildcards', + 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', + 'cat.indices/20_hidden/Test cat indices output for hidden index', + 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', + 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', + 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', + 'cat.nodeattrs/10_basic/Test cat nodes attrs output', + 'cat.nodes/10_basic/Additional disk information', + 'cat.nodes/10_basic/Test cat nodes output with full_id set', + 'cat.nodes/10_basic/Test cat nodes output', + 'cat.recovery/10_basic/Test cat recovery output for closed index', + 'cat.recovery/10_basic/Test cat recovery output', + 'cat.repositories/10_basic/Test cat repositories output', + 'cat.repositories/10_basic/Test cat repositories sort', + 'cat.segments/10_basic/Test cat segments output', + 'cat.segments/10_basic/Test cat segments using wildcards', + 'cat.shards/10_basic/Help', + 'cat.shards/10_basic/Test cat shards output', + 'cat.shards/10_basic/Test cat shards sort', + 'cat.shards/10_basic/Test cat shards using wildcards', + 'cat.snapshots/10_basic/Help', + 'cat.snapshots/10_basic/Test cat snapshots output', + 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', + 'cat.tasks/10_basic/Test cat tasks output', + 'cat.templates/10_basic/Column headers', + 'cat.templates/10_basic/Filtered templates', + 'cat.templates/10_basic/Mixture of legacy and composable templates', + 'cat.templates/10_basic/Normal templates', + 'cat.templates/10_basic/Select columns', + 'cat.thread_pool/10_basic/Test cat thread_pool output', + 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', + 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', + 'count/11_basic_with_types/count body without query element', + 'count/11_basic_with_types/count with body', + 'count/11_basic_with_types/count with empty body', + 'create/11_with_id_with_types/Create with ID', + 'create/36_external_version_with_types/External version', + 'create/41_routing_with_types/Routing', + 'create/61_refresh_with_types/Refresh', + 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', + 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', + 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', + 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', + 'delete/13_basic_with_types/Basic', + 'delete/14_shard_header_with_types/Delete check shard header', + 'delete/15_result_with_types/Delete result field', + 'delete/21_cas_with_types/Internal version', + 'delete/27_external_version_with_types/External version', + 'delete/28_external_gte_version_with_types/External GTE version', + 'delete/31_routing_with_types/Routing', + 'delete/51_refresh_with_types/Refresh', + 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', + 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', + 'delete/61_missing_with_types/Missing document with catch', + 'delete/61_missing_with_types/Missing document with ignore', + 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', + 'exists/11_basic_with_types/Basic', + 'exists/41_routing_with_types/Routing', + 'exists/61_realtime_refresh_with_types/Realtime Refresh', + 'exists/71_defaults_with_types/Client-side default type', + 'explain/10_basic/Basic explain with alias', + 'explain/10_basic/Basic explain', + 'explain/11_basic_with_types/Basic explain with alias', + 'explain/11_basic_with_types/Basic explain', + 'explain/11_basic_with_types/Explain body without query element', + 'explain/20_source_filtering/Source filtering', + 'explain/21_source_filtering_with_types/Source filtering', + 'explain/31_query_string_with_types/explain with query_string parameters', + 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', + 'field_caps/10_basic/Get date_nanos field caps', + 'field_caps/30_filter/Field caps with index filter', + 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', + 'get/11_basic_with_types/Basic', + 'get/16_default_values_with_types/Default values', + 'get/21_stored_fields_with_types/Stored fields', + 'get/41_routing_with_types/Routing', + 'get/51_with_headers_with_types/REST test with headers', + 'get/61_realtime_refresh_with_types/Realtime Refresh', + 'get/71_source_filtering_with_types/Source filtering', + 'get/81_missing_with_types/Missing document with catch', + 'get/81_missing_with_types/Missing document with ignore', + 'get/91_versions_with_types/Versions', + 'get_source/11_basic_with_types/Basic with types', + 'get_source/16_default_values_with_types/Default values', + 'get_source/41_routing_with_types/Routing', + 'get_source/61_realtime_refresh_with_types/Realtime', + 'get_source/71_source_filtering_with_types/Source filtering', + 'get_source/81_missing_with_types/Missing document with catch', + 'get_source/81_missing_with_types/Missing document with ignore', + 'get_source/86_source_missing_with_types/Missing document source with catch', + 'get_source/86_source_missing_with_types/Missing document source with ignore', // 'index/11_with_id_with_types/Index with ID', // 'index/13_result_with_types/Index result field', // 'index/16_without_id_with_types/Index without ID', @@ -169,185 +169,196 @@ tasks.named("jarHell").configure {enabled = false } // 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', // 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', // 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', -// 'indices.create/10_basic/Create index with explicit _doc type', -// 'indices.create/10_basic/Create index without soft deletes', -// 'indices.create/11_basic_with_types/Create index with aliases', -// 'indices.create/11_basic_with_types/Create index with mappings', -// 'indices.create/11_basic_with_types/Create index with settings', -// 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', -// 'indices.create/11_basic_with_types/Create index with write aliases', -// 'indices.create/11_basic_with_types/Create index', -// 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', -// 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', -// 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', -// 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', -// 'indices.flush/10_basic/Flush stats', -// 'indices.flush/10_basic/Index synced flush rest test', -// 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', -// 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', -// 'indices.get/11_basic_with_types/Test include_type_name', -// 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', -// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', -// 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', -// 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', -// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', -// 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', -// 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /_mapping', -// 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', -// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', -// 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', -// 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', -// 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', -// 'indices.get_mapping/20_missing_type/Non-existent type returns 404', -// 'indices.get_mapping/20_missing_type/Type missing when no types exist', -// 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', -// 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', -// 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', -// 'indices.get_template/11_basic_with_types/Get template with no mappings', -// 'indices.get_template/11_basic_with_types/Get template', -// 'indices.open/10_basic/?wait_for_active_shards default is deprecated', -// 'indices.open/10_basic/?wait_for_active_shards=index-setting', -// 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', -// 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', -// 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', -// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', -// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', -// 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', -// 'indices.put_mapping/all_path_options_with_types/put mapping in * index', -// 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', -// 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', -// 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', -// 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', -// 'indices.put_mapping/all_path_options_with_types/put one mapping per index', -// 'indices.put_template/10_basic/Put template with explicit _doc type', -// 'indices.put_template/11_basic_with_types/Put multiple template', -// 'indices.put_template/11_basic_with_types/Put template with empty mappings', -// 'indices.put_template/11_basic_with_types/Put template', -// 'indices.rollover/10_basic/Rollover index via API', -// 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', -// 'indices.rollover/30_max_size_condition/Rollover with max_size condition', -// 'indices.rollover/40_mapping/Mappings with explicit _doc type', -// 'indices.rollover/41_mapping_with_types/Typeless mapping', -// 'indices.segments/10_basic/basic segments test', -// 'indices.segments/10_basic/closed segments test', -// 'indices.shard_stores/10_basic/basic index test', -// 'indices.shard_stores/10_basic/multiple indices test', -// 'indices.shrink/30_copy_settings/Copy settings during shrink index', -// 'indices.split/30_copy_settings/Copy settings during split index', -// 'indices.stats/15_types/Types - _all metric', -// 'indices.stats/15_types/Types - blank', -// 'indices.stats/15_types/Types - indexing metric', -// 'indices.stats/15_types/Types - multi metric', -// 'indices.stats/15_types/Types - multi', -// 'indices.stats/15_types/Types - one', -// 'indices.stats/15_types/Types - pattern', -// 'indices.stats/15_types/Types - star', -// 'indices.stats/20_translog/Translog retention settings are deprecated', -// 'indices.stats/20_translog/Translog retention without soft_deletes', -// 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', -// 'indices.upgrade/10_basic/Basic test for upgrade indices', -// 'indices.upgrade/10_basic/Upgrade indices allow no indices', -// 'indices.upgrade/10_basic/Upgrade indices disallow no indices', -// 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', -// 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', -// 'mget/10_basic/Basic multi-get', -// 'mget/11_default_index_type/Default index/type', -// 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', -// 'mget/16_basic_with_types/Basic multi-get', -// 'mget/17_default_index/Default index/type', -// 'mget/18_non_existent_index_with_types/Non-existent index', -// 'mget/19_missing_metadata_with_types/Missing metadata', -// 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', -// 'mget/22_ids_with_types/IDs', -// 'mget/23_stored_fields_with_types/Stored fields', -// 'mget/41_routing_with_types/Routing', -// 'mget/61_realtime_refresh_with_types/Realtime Refresh', -// 'mget/71_source_filtering_with_types/Source filtering - exclude field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and include field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', -// 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', -// 'mget/71_source_filtering_with_types/Source filtering - include field', -// 'mget/71_source_filtering_with_types/Source filtering - include nested field', -// 'mget/71_source_filtering_with_types/Source filtering - true/false', -// 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', -// 'mlt/20_docs/Basic mlt query with docs', -// 'mlt/30_unlike/Basic mlt query with unlike', -// 'msearch/12_basic_with_types/Basic multi-search', -// 'msearch/12_basic_with_types/Least impact smoke test', -// 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', -// 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', -// 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', -// 'search.aggregation/10_histogram/Deprecated _time order', -// 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', -// 'search.aggregation/20_terms/Deprecated _term order', -// 'search.aggregation/280_geohash_grid/Basic test', -// 'search.aggregation/290_geotile_grid/Basic test', -// 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it' s cached ', -// 'search.inner_hits/10_basic/Nested doc version and seqIDs', -// 'search.inner_hits/10_basic/Nested inner hits', -// 'search/100_stored_fields/Stored fields', -// 'search/10_source_filtering/docvalue_fields with default format', -// 'search/110_field_collapsing/field collapsing and from', -// 'search/110_field_collapsing/field collapsing and multiple inner_hits', -// 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', -// 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', -// 'search/110_field_collapsing/field collapsing, inner_hits and version', -// 'search/110_field_collapsing/field collapsing', -// 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', -// 'search/160_exists_query/Test exists query on _type field', -// 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', -// 'search/20_default_values/Basic search', -// 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', -// 'search/340_type_query/type query', -// 'search/40_indices_boost/Indices boost using object', -// 'search/70_response_filtering/Search with response filtering', -// 'search/90_search_after/search with search_after parameter', -// 'search_shards/10_basic/Search shards aliases with and without filters', -// 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', -// 'snapshot.get/10_basic/Get missing snapshot info throws an exception', -// 'snapshot.get/10_basic/Get snapshot info contains include_global_state', -// 'snapshot.get/10_basic/Get snapshot info when verbose is false', -// 'snapshot.get/10_basic/Get snapshot info with metadata', -// 'snapshot.get/10_basic/Get snapshot info', -// 'suggest/20_completion/Suggestions with source should work', -// 'termvectors/11_basic_with_types/Basic tests for termvector get', -// 'termvectors/20_issue7121/Term vector API should return ' found : false ' for docs between index and refresh', -// 'termvectors/21_issue7121_with_types/Term vector API should return ' found: false ' for docs between index and refresh', -// 'termvectors/31_realtime_with_types/Realtime Term Vectors', -// 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', -// 'update/14_shard_header_with_types/Update check shard header', -// 'update/15_result_with_types/Update result field', -// 'update/16_noop/Noop', -// 'update/21_doc_upsert_with_types/Doc upsert', -// 'update/24_doc_as_upsert_with_types/Doc as upsert', -// 'update/41_routing_with_types/Routing', -// 'update/61_refresh_with_types/Refresh', -// 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'update/81_source_filtering_with_types/Source filtering', -// 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', -// 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' -// -// ].join(',') -//} + 'indices.create/10_basic/Create index with explicit _doc type', + 'indices.create/10_basic/Create index without soft deletes', + 'indices.create/11_basic_with_types/Create index with aliases', + 'indices.create/11_basic_with_types/Create index with mappings', + 'indices.create/11_basic_with_types/Create index with settings', + 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', + 'indices.create/11_basic_with_types/Create index with write aliases', + 'indices.create/11_basic_with_types/Create index', + 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', + 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', + 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', + 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', + 'indices.flush/10_basic/Flush stats', + 'indices.flush/10_basic/Index synced flush rest test', + 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', + 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', + 'indices.get/11_basic_with_types/Test include_type_name', + 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', + 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', + 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', + 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', + 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', + 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', + 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', + 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', + 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', + 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', + 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', + 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', + 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', + 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', + 'indices.get_mapping/11_basic_with_types/Get /_mapping', + 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', + 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', + 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', + 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', + 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', + 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', + 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', + 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', + 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', + 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', + 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', + 'indices.get_mapping/20_missing_type/Non-existent type returns 404', + 'indices.get_mapping/20_missing_type/Type missing when no types exist', + 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', + 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', + 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', + 'indices.get_template/11_basic_with_types/Get template with no mappings', + 'indices.get_template/11_basic_with_types/Get template', + 'indices.open/10_basic/?wait_for_active_shards default is deprecated', + 'indices.open/10_basic/?wait_for_active_shards=index-setting', + 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', + 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', + 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', + 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', + 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', + 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', + 'indices.put_mapping/all_path_options_with_types/put mapping in * index', + 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', + 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', + 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', + 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', + 'indices.put_mapping/all_path_options_with_types/put one mapping per index', + 'indices.put_template/10_basic/Put template with explicit _doc type', + 'indices.put_template/11_basic_with_types/Put multiple template', + 'indices.put_template/11_basic_with_types/Put template with empty mappings', + 'indices.put_template/11_basic_with_types/Put template', + 'indices.rollover/10_basic/Rollover index via API', + 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', + 'indices.rollover/30_max_size_condition/Rollover with max_size condition', + 'indices.rollover/40_mapping/Mappings with explicit _doc type', + 'indices.rollover/41_mapping_with_types/Typeless mapping', + 'indices.segments/10_basic/basic segments test', + 'indices.segments/10_basic/closed segments test', + 'indices.shard_stores/10_basic/basic index test', + 'indices.shard_stores/10_basic/multiple indices test', + 'indices.shrink/30_copy_settings/Copy settings during shrink index', + 'indices.split/30_copy_settings/Copy settings during split index', + 'indices.stats/15_types/Types - _all metric', + 'indices.stats/15_types/Types - blank', + 'indices.stats/15_types/Types - indexing metric', + 'indices.stats/15_types/Types - multi metric', + 'indices.stats/15_types/Types - multi', + 'indices.stats/15_types/Types - one', + 'indices.stats/15_types/Types - pattern', + 'indices.stats/15_types/Types - star', + 'indices.stats/20_translog/Translog retention settings are deprecated', + 'indices.stats/20_translog/Translog retention without soft_deletes', + 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', + 'indices.upgrade/10_basic/Basic test for upgrade indices', + 'indices.upgrade/10_basic/Upgrade indices allow no indices', + 'indices.upgrade/10_basic/Upgrade indices disallow no indices', + 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', + 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', + 'mget/10_basic/Basic multi-get', + 'mget/11_default_index_type/Default index/type', + 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', + 'mget/16_basic_with_types/Basic multi-get', + 'mget/17_default_index/Default index/type', + 'mget/18_non_existent_index_with_types/Non-existent index', + 'mget/19_missing_metadata_with_types/Missing metadata', + 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', + 'mget/22_ids_with_types/IDs', + 'mget/23_stored_fields_with_types/Stored fields', + 'mget/41_routing_with_types/Routing', + 'mget/61_realtime_refresh_with_types/Realtime Refresh', + 'mget/71_source_filtering_with_types/Source filtering - exclude field', + 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', + 'mget/71_source_filtering_with_types/Source filtering - ids and include field', + 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', + 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', + 'mget/71_source_filtering_with_types/Source filtering - include field', + 'mget/71_source_filtering_with_types/Source filtering - include nested field', + 'mget/71_source_filtering_with_types/Source filtering - true/false', + 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', + 'mlt/20_docs/Basic mlt query with docs', + 'mlt/30_unlike/Basic mlt query with unlike', + 'msearch/12_basic_with_types/Basic multi-search', + 'msearch/12_basic_with_types/Least impact smoke test', + 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', + 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', + 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', + 'search.aggregation/10_histogram/Deprecated _time order', + 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', + 'search.aggregation/20_terms/Deprecated _term order', + 'search.aggregation/280_geohash_grid/Basic test', + 'search.aggregation/290_geotile_grid/Basic test', + 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it\' s cached ', + 'search.inner_hits/10_basic/Nested doc version and seqIDs', + 'search.inner_hits/10_basic/Nested inner hits', + 'search/100_stored_fields/Stored fields', + 'search/10_source_filtering/docvalue_fields with default format', + 'search/110_field_collapsing/field collapsing and from', + 'search/110_field_collapsing/field collapsing and multiple inner_hits', + 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', + 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', + 'search/110_field_collapsing/field collapsing, inner_hits and version', + 'search/110_field_collapsing/field collapsing', + 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', + 'search/160_exists_query/Test exists query on _type field', + 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', + 'search/20_default_values/Basic search', + 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', + 'search/340_type_query/type query', + 'search/40_indices_boost/Indices boost using object', + 'search/70_response_filtering/Search with response filtering', + 'search/90_search_after/search with search_after parameter', + 'search_shards/10_basic/Search shards aliases with and without filters', + 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', + 'snapshot.get/10_basic/Get missing snapshot info throws an exception', + 'snapshot.get/10_basic/Get snapshot info contains include_global_state', + 'snapshot.get/10_basic/Get snapshot info when verbose is false', + 'snapshot.get/10_basic/Get snapshot info with metadata', + 'snapshot.get/10_basic/Get snapshot info', + 'suggest/20_completion/Suggestions with source should work', + 'termvectors/11_basic_with_types/Basic tests for termvector get', + 'termvectors/20_issue7121/Term vector API should return \' found : false \' for docs between index and refresh', + 'termvectors/21_issue7121_with_types/Term vector API should return \' found: false \' for docs between index and refresh', + 'termvectors/31_realtime_with_types/Realtime Term Vectors', + 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', + 'update/14_shard_header_with_types/Update check shard header', + 'update/15_result_with_types/Update result field', + 'update/16_noop/Noop', + 'update/21_doc_upsert_with_types/Doc upsert', + 'update/24_doc_as_upsert_with_types/Doc as upsert', + 'update/41_routing_with_types/Routing', + 'update/61_refresh_with_types/Refresh', + 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', + 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', + 'update/81_source_filtering_with_types/Source filtering', + 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', + 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' + + ].join(',') +} + +//tasks.named("transformV7RestTests").configure({ task -> +// task.replaceMatch("_type", "_doc") +// task.replaceMatch("_source.values", ["z", "x", "y"], "one") +// task.removeMatch("_source.blah") +// task.removeMatch("_source.junk", "two") +// task.addMatch("_source.added", [name: 'jake', likes: 'cheese'], "one") +// task.addWarning("one", "warning1", "warning2") +// task.addAllowedWarning("added allowed warning") +// task.removeWarning("one", "warning to remove") +//}) From 002ad68a197d93b57604a626db289f98f8ba4b31 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Tue, 23 Feb 2021 14:14:05 +0100 Subject: [PATCH 22/32] unmute all --- rest-api-spec/build.gradle | 656 ++++++++++++++++++------------------- 1 file changed, 328 insertions(+), 328 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 2cd562021135e..e329b494ee3a9 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -23,334 +23,334 @@ testClusters.all { tasks.named("test").configure {enabled = false } tasks.named("jarHell").configure {enabled = false } - -tasks.named("yamlRestCompatTest").configure { - systemProperty 'tests.rest.blacklist', [ - 'bulk/11_basic_with_types/Array of objects', - 'bulk/11_basic_with_types/Empty _id with op_type create', - 'bulk/11_basic_with_types/Empty _id', - 'bulk/11_basic_with_types/empty action', - 'bulk/21_list_of_strings_with_types/List of strings', - 'bulk/31_big_string_with_types/One big string', - 'bulk/41_source_with_types/Source filtering', - 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', - 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', - 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', - 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', - 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', - 'cat.aliases/10_basic/Alias against closed index', - 'cat.aliases/10_basic/Alias name', - 'cat.aliases/10_basic/Alias sorting', - 'cat.aliases/10_basic/Column headers', - 'cat.aliases/10_basic/Complex alias', - 'cat.aliases/10_basic/Empty cluster', - 'cat.aliases/10_basic/Multiple alias names', - 'cat.aliases/10_basic/Select columns', - 'cat.aliases/10_basic/Simple alias', - 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', - 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', - 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', - 'cat.allocation/10_basic/All Nodes', - 'cat.allocation/10_basic/Bytes', - 'cat.allocation/10_basic/Column headers', - 'cat.allocation/10_basic/Empty cluster', - 'cat.allocation/10_basic/Node ID', - 'cat.allocation/10_basic/One index', - 'cat.allocation/10_basic/Select columns', - 'cat.count/10_basic/Test cat count output', - 'cat.fielddata/10_basic/Test cat fielddata output', - 'cat.health/10_basic/Empty cluster', - 'cat.health/10_basic/With ts parameter', - 'cat.indices/10_basic/Test cat indices output (no indices)', - 'cat.indices/10_basic/Test cat indices output for closed index', - 'cat.indices/10_basic/Test cat indices output', - 'cat.indices/10_basic/Test cat indices sort', - 'cat.indices/10_basic/Test cat indices using health status', - 'cat.indices/10_basic/Test cat indices using wildcards', - 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', - 'cat.indices/20_hidden/Test cat indices output for hidden index', - 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', - 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', - 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', - 'cat.nodeattrs/10_basic/Test cat nodes attrs output', - 'cat.nodes/10_basic/Additional disk information', - 'cat.nodes/10_basic/Test cat nodes output with full_id set', - 'cat.nodes/10_basic/Test cat nodes output', - 'cat.recovery/10_basic/Test cat recovery output for closed index', - 'cat.recovery/10_basic/Test cat recovery output', - 'cat.repositories/10_basic/Test cat repositories output', - 'cat.repositories/10_basic/Test cat repositories sort', - 'cat.segments/10_basic/Test cat segments output', - 'cat.segments/10_basic/Test cat segments using wildcards', - 'cat.shards/10_basic/Help', - 'cat.shards/10_basic/Test cat shards output', - 'cat.shards/10_basic/Test cat shards sort', - 'cat.shards/10_basic/Test cat shards using wildcards', - 'cat.snapshots/10_basic/Help', - 'cat.snapshots/10_basic/Test cat snapshots output', - 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', - 'cat.tasks/10_basic/Test cat tasks output', - 'cat.templates/10_basic/Column headers', - 'cat.templates/10_basic/Filtered templates', - 'cat.templates/10_basic/Mixture of legacy and composable templates', - 'cat.templates/10_basic/Normal templates', - 'cat.templates/10_basic/Select columns', - 'cat.thread_pool/10_basic/Test cat thread_pool output', - 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', - 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', - 'count/11_basic_with_types/count body without query element', - 'count/11_basic_with_types/count with body', - 'count/11_basic_with_types/count with empty body', - 'create/11_with_id_with_types/Create with ID', - 'create/36_external_version_with_types/External version', - 'create/41_routing_with_types/Routing', - 'create/61_refresh_with_types/Refresh', - 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', - 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', - 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', - 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', - 'delete/13_basic_with_types/Basic', - 'delete/14_shard_header_with_types/Delete check shard header', - 'delete/15_result_with_types/Delete result field', - 'delete/21_cas_with_types/Internal version', - 'delete/27_external_version_with_types/External version', - 'delete/28_external_gte_version_with_types/External GTE version', - 'delete/31_routing_with_types/Routing', - 'delete/51_refresh_with_types/Refresh', - 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', - 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', - 'delete/61_missing_with_types/Missing document with catch', - 'delete/61_missing_with_types/Missing document with ignore', - 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', - 'exists/11_basic_with_types/Basic', - 'exists/41_routing_with_types/Routing', - 'exists/61_realtime_refresh_with_types/Realtime Refresh', - 'exists/71_defaults_with_types/Client-side default type', - 'explain/10_basic/Basic explain with alias', - 'explain/10_basic/Basic explain', - 'explain/11_basic_with_types/Basic explain with alias', - 'explain/11_basic_with_types/Basic explain', - 'explain/11_basic_with_types/Explain body without query element', - 'explain/20_source_filtering/Source filtering', - 'explain/21_source_filtering_with_types/Source filtering', - 'explain/31_query_string_with_types/explain with query_string parameters', - 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', - 'field_caps/10_basic/Get date_nanos field caps', - 'field_caps/30_filter/Field caps with index filter', - 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', - 'get/11_basic_with_types/Basic', - 'get/16_default_values_with_types/Default values', - 'get/21_stored_fields_with_types/Stored fields', - 'get/41_routing_with_types/Routing', - 'get/51_with_headers_with_types/REST test with headers', - 'get/61_realtime_refresh_with_types/Realtime Refresh', - 'get/71_source_filtering_with_types/Source filtering', - 'get/81_missing_with_types/Missing document with catch', - 'get/81_missing_with_types/Missing document with ignore', - 'get/91_versions_with_types/Versions', - 'get_source/11_basic_with_types/Basic with types', - 'get_source/16_default_values_with_types/Default values', - 'get_source/41_routing_with_types/Routing', - 'get_source/61_realtime_refresh_with_types/Realtime', - 'get_source/71_source_filtering_with_types/Source filtering', - 'get_source/81_missing_with_types/Missing document with catch', - 'get_source/81_missing_with_types/Missing document with ignore', - 'get_source/86_source_missing_with_types/Missing document source with catch', - 'get_source/86_source_missing_with_types/Missing document source with ignore', -// 'index/11_with_id_with_types/Index with ID', -// 'index/13_result_with_types/Index result field', -// 'index/16_without_id_with_types/Index without ID', -// 'index/21_optype_with_types/Optype', -// 'index/37_external_version_with_types/External version', -// 'index/38_external_gte_version_with_types/External GTE version', -// 'index/41_routing_with_types/Routing', -// 'index/61_refresh_with_types/Refresh', -// 'index/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', -// 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', -// 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', - 'indices.create/10_basic/Create index with explicit _doc type', - 'indices.create/10_basic/Create index without soft deletes', - 'indices.create/11_basic_with_types/Create index with aliases', - 'indices.create/11_basic_with_types/Create index with mappings', - 'indices.create/11_basic_with_types/Create index with settings', - 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', - 'indices.create/11_basic_with_types/Create index with write aliases', - 'indices.create/11_basic_with_types/Create index', - 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', - 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', - 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', - 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', - 'indices.flush/10_basic/Flush stats', - 'indices.flush/10_basic/Index synced flush rest test', - 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', - 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', - 'indices.get/11_basic_with_types/Test include_type_name', - 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', - 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', - 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', - 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', - 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', - 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', - 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', - 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', - 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', - 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', - 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', - 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', - 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', - 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', - 'indices.get_mapping/11_basic_with_types/Get /_mapping', - 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', - 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', - 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', - 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', - 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', - 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', - 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', - 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', - 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', - 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', - 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', - 'indices.get_mapping/20_missing_type/Non-existent type returns 404', - 'indices.get_mapping/20_missing_type/Type missing when no types exist', - 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', - 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', - 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', - 'indices.get_template/11_basic_with_types/Get template with no mappings', - 'indices.get_template/11_basic_with_types/Get template', - 'indices.open/10_basic/?wait_for_active_shards default is deprecated', - 'indices.open/10_basic/?wait_for_active_shards=index-setting', - 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', - 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', - 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', - 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', - 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', - 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', - 'indices.put_mapping/all_path_options_with_types/put mapping in * index', - 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', - 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', - 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', - 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', - 'indices.put_mapping/all_path_options_with_types/put one mapping per index', - 'indices.put_template/10_basic/Put template with explicit _doc type', - 'indices.put_template/11_basic_with_types/Put multiple template', - 'indices.put_template/11_basic_with_types/Put template with empty mappings', - 'indices.put_template/11_basic_with_types/Put template', - 'indices.rollover/10_basic/Rollover index via API', - 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', - 'indices.rollover/30_max_size_condition/Rollover with max_size condition', - 'indices.rollover/40_mapping/Mappings with explicit _doc type', - 'indices.rollover/41_mapping_with_types/Typeless mapping', - 'indices.segments/10_basic/basic segments test', - 'indices.segments/10_basic/closed segments test', - 'indices.shard_stores/10_basic/basic index test', - 'indices.shard_stores/10_basic/multiple indices test', - 'indices.shrink/30_copy_settings/Copy settings during shrink index', - 'indices.split/30_copy_settings/Copy settings during split index', - 'indices.stats/15_types/Types - _all metric', - 'indices.stats/15_types/Types - blank', - 'indices.stats/15_types/Types - indexing metric', - 'indices.stats/15_types/Types - multi metric', - 'indices.stats/15_types/Types - multi', - 'indices.stats/15_types/Types - one', - 'indices.stats/15_types/Types - pattern', - 'indices.stats/15_types/Types - star', - 'indices.stats/20_translog/Translog retention settings are deprecated', - 'indices.stats/20_translog/Translog retention without soft_deletes', - 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', - 'indices.upgrade/10_basic/Basic test for upgrade indices', - 'indices.upgrade/10_basic/Upgrade indices allow no indices', - 'indices.upgrade/10_basic/Upgrade indices disallow no indices', - 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', - 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', - 'mget/10_basic/Basic multi-get', - 'mget/11_default_index_type/Default index/type', - 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', - 'mget/16_basic_with_types/Basic multi-get', - 'mget/17_default_index/Default index/type', - 'mget/18_non_existent_index_with_types/Non-existent index', - 'mget/19_missing_metadata_with_types/Missing metadata', - 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', - 'mget/22_ids_with_types/IDs', - 'mget/23_stored_fields_with_types/Stored fields', - 'mget/41_routing_with_types/Routing', - 'mget/61_realtime_refresh_with_types/Realtime Refresh', - 'mget/71_source_filtering_with_types/Source filtering - exclude field', - 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', - 'mget/71_source_filtering_with_types/Source filtering - ids and include field', - 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', - 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', - 'mget/71_source_filtering_with_types/Source filtering - include field', - 'mget/71_source_filtering_with_types/Source filtering - include nested field', - 'mget/71_source_filtering_with_types/Source filtering - true/false', - 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', - 'mlt/20_docs/Basic mlt query with docs', - 'mlt/30_unlike/Basic mlt query with unlike', - 'msearch/12_basic_with_types/Basic multi-search', - 'msearch/12_basic_with_types/Least impact smoke test', - 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', - 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', - 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', - 'search.aggregation/10_histogram/Deprecated _time order', - 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', - 'search.aggregation/20_terms/Deprecated _term order', - 'search.aggregation/280_geohash_grid/Basic test', - 'search.aggregation/290_geotile_grid/Basic test', - 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it\' s cached ', - 'search.inner_hits/10_basic/Nested doc version and seqIDs', - 'search.inner_hits/10_basic/Nested inner hits', - 'search/100_stored_fields/Stored fields', - 'search/10_source_filtering/docvalue_fields with default format', - 'search/110_field_collapsing/field collapsing and from', - 'search/110_field_collapsing/field collapsing and multiple inner_hits', - 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', - 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', - 'search/110_field_collapsing/field collapsing, inner_hits and version', - 'search/110_field_collapsing/field collapsing', - 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', - 'search/160_exists_query/Test exists query on _type field', - 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', - 'search/20_default_values/Basic search', - 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', - 'search/340_type_query/type query', - 'search/40_indices_boost/Indices boost using object', - 'search/70_response_filtering/Search with response filtering', - 'search/90_search_after/search with search_after parameter', - 'search_shards/10_basic/Search shards aliases with and without filters', - 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', - 'snapshot.get/10_basic/Get missing snapshot info throws an exception', - 'snapshot.get/10_basic/Get snapshot info contains include_global_state', - 'snapshot.get/10_basic/Get snapshot info when verbose is false', - 'snapshot.get/10_basic/Get snapshot info with metadata', - 'snapshot.get/10_basic/Get snapshot info', - 'suggest/20_completion/Suggestions with source should work', - 'termvectors/11_basic_with_types/Basic tests for termvector get', - 'termvectors/20_issue7121/Term vector API should return \' found : false \' for docs between index and refresh', - 'termvectors/21_issue7121_with_types/Term vector API should return \' found: false \' for docs between index and refresh', - 'termvectors/31_realtime_with_types/Realtime Term Vectors', - 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', - 'update/14_shard_header_with_types/Update check shard header', - 'update/15_result_with_types/Update result field', - 'update/16_noop/Noop', - 'update/21_doc_upsert_with_types/Doc upsert', - 'update/24_doc_as_upsert_with_types/Doc as upsert', - 'update/41_routing_with_types/Routing', - 'update/61_refresh_with_types/Refresh', - 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', - 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', - 'update/81_source_filtering_with_types/Source filtering', - 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', - 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' - - ].join(',') -} +// +//tasks.named("yamlRestCompatTest").configure { +// systemProperty 'tests.rest.blacklist', [ +// 'bulk/11_basic_with_types/Array of objects', +// 'bulk/11_basic_with_types/Empty _id with op_type create', +// 'bulk/11_basic_with_types/Empty _id', +// 'bulk/11_basic_with_types/empty action', +// 'bulk/21_list_of_strings_with_types/List of strings', +// 'bulk/31_big_string_with_types/One big string', +// 'bulk/41_source_with_types/Source filtering', +// 'bulk/51_refresh_with_types/refresh=empty string immediately makes changes are visible in search', +// 'bulk/51_refresh_with_types/refresh=true immediately makes changes are visible in search', +// 'bulk/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'bulk/70_mix_typeless_typeful/bulk without types on an index that has types', +// 'bulk/81_cas_with_types/Compare And Swap Sequence Numbers', +// 'cat.aliases/10_basic/Alias against closed index', +// 'cat.aliases/10_basic/Alias name', +// 'cat.aliases/10_basic/Alias sorting', +// 'cat.aliases/10_basic/Column headers', +// 'cat.aliases/10_basic/Complex alias', +// 'cat.aliases/10_basic/Empty cluster', +// 'cat.aliases/10_basic/Multiple alias names', +// 'cat.aliases/10_basic/Select columns', +// 'cat.aliases/10_basic/Simple alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a hidden alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a hidden index with a visible alias', +// 'cat.aliases/40_hidden/Test cat aliases output with a visible index with a hidden alias', +// 'cat.allocation/10_basic/All Nodes', +// 'cat.allocation/10_basic/Bytes', +// 'cat.allocation/10_basic/Column headers', +// 'cat.allocation/10_basic/Empty cluster', +// 'cat.allocation/10_basic/Node ID', +// 'cat.allocation/10_basic/One index', +// 'cat.allocation/10_basic/Select columns', +// 'cat.count/10_basic/Test cat count output', +// 'cat.fielddata/10_basic/Test cat fielddata output', +// 'cat.health/10_basic/Empty cluster', +// 'cat.health/10_basic/With ts parameter', +// 'cat.indices/10_basic/Test cat indices output (no indices)', +// 'cat.indices/10_basic/Test cat indices output for closed index', +// 'cat.indices/10_basic/Test cat indices output', +// 'cat.indices/10_basic/Test cat indices sort', +// 'cat.indices/10_basic/Test cat indices using health status', +// 'cat.indices/10_basic/Test cat indices using wildcards', +// 'cat.indices/20_hidden/Test cat indices output for dot-hidden index and dot-prefixed pattern', +// 'cat.indices/20_hidden/Test cat indices output for hidden index', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a hidden alias', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index with a visible alias', +// 'cat.indices/20_hidden/Test cat indices output with a hidden index, dot-hidden alias and dot pattern', +// 'cat.nodeattrs/10_basic/Test cat nodes attrs output', +// 'cat.nodes/10_basic/Additional disk information', +// 'cat.nodes/10_basic/Test cat nodes output with full_id set', +// 'cat.nodes/10_basic/Test cat nodes output', +// 'cat.recovery/10_basic/Test cat recovery output for closed index', +// 'cat.recovery/10_basic/Test cat recovery output', +// 'cat.repositories/10_basic/Test cat repositories output', +// 'cat.repositories/10_basic/Test cat repositories sort', +// 'cat.segments/10_basic/Test cat segments output', +// 'cat.segments/10_basic/Test cat segments using wildcards', +// 'cat.shards/10_basic/Help', +// 'cat.shards/10_basic/Test cat shards output', +// 'cat.shards/10_basic/Test cat shards sort', +// 'cat.shards/10_basic/Test cat shards using wildcards', +// 'cat.snapshots/10_basic/Help', +// 'cat.snapshots/10_basic/Test cat snapshots output', +// 'cat.tasks/10_basic/Test cat tasks output with X-Opaque-Id', +// 'cat.tasks/10_basic/Test cat tasks output', +// 'cat.templates/10_basic/Column headers', +// 'cat.templates/10_basic/Filtered templates', +// 'cat.templates/10_basic/Mixture of legacy and composable templates', +// 'cat.templates/10_basic/Normal templates', +// 'cat.templates/10_basic/Select columns', +// 'cat.thread_pool/10_basic/Test cat thread_pool output', +// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion and specifying both node_ids and node_names', +// 'cluster.voting_config_exclusions/10_basic/Throw exception when adding voting config exclusion without specifying nodes', +// 'count/11_basic_with_types/count body without query element', +// 'count/11_basic_with_types/count with body', +// 'count/11_basic_with_types/count with empty body', +// 'create/11_with_id_with_types/Create with ID', +// 'create/36_external_version_with_types/External version', +// 'create/41_routing_with_types/Routing', +// 'create/61_refresh_with_types/Refresh', +// 'create/61_refresh_with_types/When refresh url parameter is an empty string that means \"refresh immediately\"', +// 'create/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'create/71_nested_with_types/Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed', +// 'create/71_nested_with_types/Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail', +// 'delete/13_basic_with_types/Basic', +// 'delete/14_shard_header_with_types/Delete check shard header', +// 'delete/15_result_with_types/Delete result field', +// 'delete/21_cas_with_types/Internal version', +// 'delete/27_external_version_with_types/External version', +// 'delete/28_external_gte_version_with_types/External GTE version', +// 'delete/31_routing_with_types/Routing', +// 'delete/51_refresh_with_types/Refresh', +// 'delete/51_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'delete/51_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'delete/61_missing_with_types/Missing document with catch', +// 'delete/61_missing_with_types/Missing document with ignore', +// 'delete/70_mix_typeless_typeful/DELETE with typeless API on an index that has types', +// 'exists/11_basic_with_types/Basic', +// 'exists/41_routing_with_types/Routing', +// 'exists/61_realtime_refresh_with_types/Realtime Refresh', +// 'exists/71_defaults_with_types/Client-side default type', +// 'explain/10_basic/Basic explain with alias', +// 'explain/10_basic/Basic explain', +// 'explain/11_basic_with_types/Basic explain with alias', +// 'explain/11_basic_with_types/Basic explain', +// 'explain/11_basic_with_types/Explain body without query element', +// 'explain/20_source_filtering/Source filtering', +// 'explain/21_source_filtering_with_types/Source filtering', +// 'explain/31_query_string_with_types/explain with query_string parameters', +// 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', +// 'field_caps/10_basic/Get date_nanos field caps', +// 'field_caps/30_filter/Field caps with index filter', +// 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', +// 'get/11_basic_with_types/Basic', +// 'get/16_default_values_with_types/Default values', +// 'get/21_stored_fields_with_types/Stored fields', +// 'get/41_routing_with_types/Routing', +// 'get/51_with_headers_with_types/REST test with headers', +// 'get/61_realtime_refresh_with_types/Realtime Refresh', +// 'get/71_source_filtering_with_types/Source filtering', +// 'get/81_missing_with_types/Missing document with catch', +// 'get/81_missing_with_types/Missing document with ignore', +// 'get/91_versions_with_types/Versions', +// 'get_source/11_basic_with_types/Basic with types', +// 'get_source/16_default_values_with_types/Default values', +// 'get_source/41_routing_with_types/Routing', +// 'get_source/61_realtime_refresh_with_types/Realtime', +// 'get_source/71_source_filtering_with_types/Source filtering', +// 'get_source/81_missing_with_types/Missing document with catch', +// 'get_source/81_missing_with_types/Missing document with ignore', +// 'get_source/86_source_missing_with_types/Missing document source with catch', +// 'get_source/86_source_missing_with_types/Missing document source with ignore', +//// 'index/11_with_id_with_types/Index with ID', +//// 'index/13_result_with_types/Index result field', +//// 'index/16_without_id_with_types/Index without ID', +//// 'index/21_optype_with_types/Optype', +//// 'index/37_external_version_with_types/External version', +//// 'index/38_external_gte_version_with_types/External GTE version', +//// 'index/41_routing_with_types/Routing', +//// 'index/61_refresh_with_types/Refresh', +//// 'index/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +//// 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +//// 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', +//// 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', +// 'indices.create/10_basic/Create index with explicit _doc type', +// 'indices.create/10_basic/Create index without soft deletes', +// 'indices.create/11_basic_with_types/Create index with aliases', +// 'indices.create/11_basic_with_types/Create index with mappings', +// 'indices.create/11_basic_with_types/Create index with settings', +// 'indices.create/11_basic_with_types/Create index with wait_for_active_shards set to all', +// 'indices.create/11_basic_with_types/Create index with write aliases', +// 'indices.create/11_basic_with_types/Create index', +// 'indices.create/20_mix_typeless_typeful/Create a typed index while there is a typeless template', +// 'indices.create/20_mix_typeless_typeful/Create a typeless index while there is a typed template', +// 'indices.create/20_mix_typeless_typeful/Implicitly create a typed index while there is a typeless template', +// 'indices.create/20_mix_typeless_typeful/Implicitly create a typeless index while there is a typed template', +// 'indices.flush/10_basic/Flush stats', +// 'indices.flush/10_basic/Index synced flush rest test', +// 'indices.forcemerge/10_basic/Check deprecation warning when incompatible only_expunge_deletes and max_num_segments values are both set', +// 'indices.get/11_basic_with_types/Test include_type_name dafaults to false', +// 'indices.get/11_basic_with_types/Test include_type_name', +// 'indices.get_field_mapping/10_basic/Get field mapping with local is deprecated', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by index only', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field, with another field that doesn\'t exist', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping by type & field', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping should work without index specifying type and fields', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with include_defaults', +// 'indices.get_field_mapping/11_basic_with_types/Get field mapping with no index and type', +// 'indices.get_field_mapping/21_missing_field_with_types/Return empty object if field doesn\'t exist, but type and index do', +// 'indices.get_field_mapping/30_missing_type/Raise 404 when type doesn\'t exist', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'*\' for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using \'_all\' for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping should work using comma_separated values for indices and types', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with * for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with *t1 for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with t* for fields', +// 'indices.get_field_mapping/51_field_wildcards_with_types/Get field mapping with wildcarded relative names', +// 'indices.get_field_mapping/60_mix_typeless_typeful/GET mapping with typeless API on an index that has types', +// 'indices.get_mapping/11_basic_with_types/Get /*/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_all/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /_mapping', +// 'indices.get_mapping/11_basic_with_types/Get /index*/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /index,index/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping with empty mappings', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/*', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/_all', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type*}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping/{type}', +// 'indices.get_mapping/11_basic_with_types/Get /{index}/_mapping', +// 'indices.get_mapping/20_missing_type/Existent and non-existent type returns 404 and the existing type', +// 'indices.get_mapping/20_missing_type/Existent and non-existent types returns 404 and the existing type', +// 'indices.get_mapping/20_missing_type/No type matching pattern returns 404', +// 'indices.get_mapping/20_missing_type/Non-existent type returns 404', +// 'indices.get_mapping/20_missing_type/Type missing when no types exist', +// 'indices.get_mapping/40_aliases/Getting mapping for aliases should return the real index as key', +// 'indices.get_mapping/61_empty_with_types/Check empty mapping when getting all mappings via /_mapping', +// 'indices.get_mapping/70_mix_typeless_typeful/GET mapping with typeless API on an index that has types', +// 'indices.get_template/11_basic_with_types/Get template with no mappings', +// 'indices.get_template/11_basic_with_types/Get template', +// 'indices.open/10_basic/?wait_for_active_shards default is deprecated', +// 'indices.open/10_basic/?wait_for_active_shards=index-setting', +// 'indices.put_mapping/10_basic/Put mappings with explicit _doc type', +// 'indices.put_mapping/11_basic_with_types/Create index with invalid mappings', +// 'indices.put_mapping/11_basic_with_types/Test Create and update mapping', +// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with _doc on an index that has types', +// 'indices.put_mapping/20_mix_typeless_typeful/PUT mapping with typeless API on an index that has types', +// 'indices.put_mapping/all_path_options_with_types/post a mapping with default analyzer twice', +// 'indices.put_mapping/all_path_options_with_types/put mapping in * index', +// 'indices.put_mapping/all_path_options_with_types/put mapping in _all index', +// 'indices.put_mapping/all_path_options_with_types/put mapping in list of indices', +// 'indices.put_mapping/all_path_options_with_types/put mapping in prefix* index', +// 'indices.put_mapping/all_path_options_with_types/put mapping with blank index', +// 'indices.put_mapping/all_path_options_with_types/put one mapping per index', +// 'indices.put_template/10_basic/Put template with explicit _doc type', +// 'indices.put_template/11_basic_with_types/Put multiple template', +// 'indices.put_template/11_basic_with_types/Put template with empty mappings', +// 'indices.put_template/11_basic_with_types/Put template', +// 'indices.rollover/10_basic/Rollover index via API', +// 'indices.rollover/20_max_doc_condition/Max docs rollover conditions matches only primary shards', +// 'indices.rollover/30_max_size_condition/Rollover with max_size condition', +// 'indices.rollover/40_mapping/Mappings with explicit _doc type', +// 'indices.rollover/41_mapping_with_types/Typeless mapping', +// 'indices.segments/10_basic/basic segments test', +// 'indices.segments/10_basic/closed segments test', +// 'indices.shard_stores/10_basic/basic index test', +// 'indices.shard_stores/10_basic/multiple indices test', +// 'indices.shrink/30_copy_settings/Copy settings during shrink index', +// 'indices.split/30_copy_settings/Copy settings during split index', +// 'indices.stats/15_types/Types - _all metric', +// 'indices.stats/15_types/Types - blank', +// 'indices.stats/15_types/Types - indexing metric', +// 'indices.stats/15_types/Types - multi metric', +// 'indices.stats/15_types/Types - multi', +// 'indices.stats/15_types/Types - one', +// 'indices.stats/15_types/Types - pattern', +// 'indices.stats/15_types/Types - star', +// 'indices.stats/20_translog/Translog retention settings are deprecated', +// 'indices.stats/20_translog/Translog retention without soft_deletes', +// 'indices.stats/20_translog/Translog stats on closed indices without soft-deletes', +// 'indices.upgrade/10_basic/Basic test for upgrade indices', +// 'indices.upgrade/10_basic/Upgrade indices allow no indices', +// 'indices.upgrade/10_basic/Upgrade indices disallow no indices', +// 'indices.upgrade/10_basic/Upgrade indices disallow unavailable', +// 'indices.upgrade/10_basic/Upgrade indices ignore unavailable', +// 'mget/10_basic/Basic multi-get', +// 'mget/11_default_index_type/Default index/type', +// 'mget/14_alias_to_multiple_indices/Multi Get with alias that resolves to multiple indices', +// 'mget/16_basic_with_types/Basic multi-get', +// 'mget/17_default_index/Default index/type', +// 'mget/18_non_existent_index_with_types/Non-existent index', +// 'mget/19_missing_metadata_with_types/Missing metadata', +// 'mget/21_alias_to_multiple_indices_with_types/Multi Get with alias that resolves to multiple indices', +// 'mget/22_ids_with_types/IDs', +// 'mget/23_stored_fields_with_types/Stored fields', +// 'mget/41_routing_with_types/Routing', +// 'mget/61_realtime_refresh_with_types/Realtime Refresh', +// 'mget/71_source_filtering_with_types/Source filtering - exclude field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and exclude field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and include field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and include nested field', +// 'mget/71_source_filtering_with_types/Source filtering - ids and true/false', +// 'mget/71_source_filtering_with_types/Source filtering - include field', +// 'mget/71_source_filtering_with_types/Source filtering - include nested field', +// 'mget/71_source_filtering_with_types/Source filtering - true/false', +// 'mget/80_deprecated_with_types/Deprecated parameters should fail in Multi Get query', +// 'mlt/20_docs/Basic mlt query with docs', +// 'mlt/30_unlike/Basic mlt query with unlike', +// 'msearch/12_basic_with_types/Basic multi-search', +// 'msearch/12_basic_with_types/Least impact smoke test', +// 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', +// 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', +// 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', +// 'search.aggregation/10_histogram/Deprecated _time order', +// 'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers', +// 'search.aggregation/20_terms/Deprecated _term order', +// 'search.aggregation/280_geohash_grid/Basic test', +// 'search.aggregation/290_geotile_grid/Basic test', +// 'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it\' s cached ', +// 'search.inner_hits/10_basic/Nested doc version and seqIDs', +// 'search.inner_hits/10_basic/Nested inner hits', +// 'search/100_stored_fields/Stored fields', +// 'search/10_source_filtering/docvalue_fields with default format', +// 'search/110_field_collapsing/field collapsing and from', +// 'search/110_field_collapsing/field collapsing and multiple inner_hits', +// 'search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests', +// 'search/110_field_collapsing/field collapsing, inner_hits and seq_no', +// 'search/110_field_collapsing/field collapsing, inner_hits and version', +// 'search/110_field_collapsing/field collapsing', +// 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', +// 'search/160_exists_query/Test exists query on _type field', +// 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', +// 'search/20_default_values/Basic search', +// 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', +// 'search/340_type_query/type query', +// 'search/40_indices_boost/Indices boost using object', +// 'search/70_response_filtering/Search with response filtering', +// 'search/90_search_after/search with search_after parameter', +// 'search_shards/10_basic/Search shards aliases with and without filters', +// 'snapshot.get/10_basic/Get missing snapshot info succeeds when ignore_unavailable is true', +// 'snapshot.get/10_basic/Get missing snapshot info throws an exception', +// 'snapshot.get/10_basic/Get snapshot info contains include_global_state', +// 'snapshot.get/10_basic/Get snapshot info when verbose is false', +// 'snapshot.get/10_basic/Get snapshot info with metadata', +// 'snapshot.get/10_basic/Get snapshot info', +// 'suggest/20_completion/Suggestions with source should work', +// 'termvectors/11_basic_with_types/Basic tests for termvector get', +// 'termvectors/20_issue7121/Term vector API should return \' found : false \' for docs between index and refresh', +// 'termvectors/21_issue7121_with_types/Term vector API should return \' found: false \' for docs between index and refresh', +// 'termvectors/31_realtime_with_types/Realtime Term Vectors', +// 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', +// 'update/14_shard_header_with_types/Update check shard header', +// 'update/15_result_with_types/Update result field', +// 'update/16_noop/Noop', +// 'update/21_doc_upsert_with_types/Doc upsert', +// 'update/24_doc_as_upsert_with_types/Doc as upsert', +// 'update/41_routing_with_types/Routing', +// 'update/61_refresh_with_types/Refresh', +// 'update/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', +// 'update/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', +// 'update/81_source_filtering_with_types/Source filtering', +// 'update/90_mix_typeless_typeful/Update call that introduces new field mappings', +// 'update/90_mix_typeless_typeful/Update with typeless API on an index that has types' +// +// ].join(',') +//} //tasks.named("transformV7RestTests").configure({ task -> // task.replaceMatch("_type", "_doc") From d6d729c06a3d0df2971dd7d30921d0252637991f Mon Sep 17 00:00:00 2001 From: pgomulka Date: Thu, 25 Feb 2021 17:07:03 +0100 Subject: [PATCH 23/32] cleanup --- rest-api-spec/build.gradle | 19 ------------------- .../elasticsearch/action/ActionModule.java | 3 ++- .../test/rest/yaml/section/DoSection.java | 1 + 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 984fe90c7d7f6..e326e17b13024 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -162,18 +162,6 @@ tasks.named("yamlRestCompatTest").configure { 'get_source/81_missing_with_types/Missing document with ignore', 'get_source/86_source_missing_with_types/Missing document source with catch', 'get_source/86_source_missing_with_types/Missing document source with ignore', -// 'index/10_with_id/Index with ID', -// 'index/11_with_id_with_types/Index with ID', -// 'index/13_result_with_types/Index result field', -// 'index/15_without_id/Index without ID', -// 'index/16_without_id_with_types/Index without ID', -// 'index/21_optype_with_types/Optype', -// 'index/37_external_version_with_types/External version', -// 'index/38_external_gte_version_with_types/External GTE version', -// 'index/41_routing_with_types/Routing', -// 'index/61_refresh_with_types/Refresh', -// 'index/61_refresh_with_types/When refresh url parameter is an empty string that means "refresh immediately"', -// 'index/61_refresh_with_types/refresh=wait_for waits until changes are visible in search', 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', 'indices.clone/10_basic/Clone index via API', @@ -371,11 +359,4 @@ tasks.named("yamlRestCompatTest").configure { tasks.named("transformV7RestTests").configure({ task -> task.replaceMatch("_type", "_doc") -// task.replaceMatch("_source.values", ["z", "x", "y"], "one") -// task.removeMatch("_source.blah") -// task.removeMatch("_source.junk", "two") -// task.addMatch("_source.added", [name: 'jake', likes: 'cheese'], "one") -// task.addWarning("one", "warning1", "warning2") -// task.addAllowedWarning("added allowed warning") -// task.removeWarning("one", "warning to remove") }) diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index 19898c5d7b7da..ba18060f8d11a 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -779,7 +779,8 @@ public void initRestHandlers(Supplier nodesInCluster) { } } registerHandler.accept(new RestCatAction(catActions)); -// + + // Rest Compatible API if(RestApiCompatibleVersion.minimumSupported() == RestApiCompatibleVersion.V_7){ registerHandler.accept(new RestIndexActionV7.CompatibleRestIndexAction()); registerHandler.accept(new RestIndexActionV7.CompatibleCreateHandler()); diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index bb4f346509d71..ceeca0e7ac75c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -320,6 +320,7 @@ void checkWarningHeaders(final List warningHeaders, final Version master final boolean matches = matcher.matches(); if (matches) { final String message = HeaderWarning.extractWarningValueFromWarningHeader(header, true); + //TODO remove once regex assertions and compatible logging strategy is settled if (message.startsWith("[types removal]") || message.startsWith("[Compatible API usage]")) { // We skip warnings related to types deprecation because they are *everywhere*. continue; From 0155e2f4022e62dff70191713ba0d701c0844e6a Mon Sep 17 00:00:00 2001 From: pgomulka Date: Tue, 9 Mar 2021 14:08:03 +0100 Subject: [PATCH 24/32] cleanup tests --- .../rest/action/document/RestGetActionV7.java | 14 ++++----- .../action/document/RestIndexActionV7.java | 30 ++++++++++--------- .../action/document/RestGetActionV7Tests.java | 4 +-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java index 8651b00e7ec71..0b630670986f4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java @@ -9,8 +9,7 @@ package org.elasticsearch.rest.action.document; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationCategory; -import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.rest.RestRequest; import java.io.IOException; @@ -21,10 +20,8 @@ public class RestGetActionV7 extends RestGetAction { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetActionV7.class); static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + "document get requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; - static final String COMPATIBLE_API_MESSAGE = "[Compatible API usage] Index API with types has been removed, use typeless endpoints."; @Override public String getName() { @@ -33,13 +30,16 @@ public String getName() { @Override public List routes() { - return List.of(new Route(GET, "/{index}/{type}/{id}"), new Route(HEAD, "/{index}/{type}/{id}")); + return List.of(Route.builder(GET, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build(), + Route.builder(HEAD, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "get_with_types", TYPES_DEPRECATION_MESSAGE); - deprecationLogger.compatibleApiWarning("get_with_types", COMPATIBLE_API_MESSAGE); request.param("type"); return super.prepareRequest(request, client); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java index 9d51baa18c43e..891e18bc59e6a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java @@ -10,8 +10,7 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.common.logging.DeprecationCategory; -import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.rest.RestRequest; import java.io.IOException; @@ -27,12 +26,6 @@ public class RestIndexActionV7 { + "index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, " + "or /{index}/_create/{id})."; - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestIndexActionV7.class); - - private static void logDeprecationMessage() { - deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "index_with_types", TYPES_DEPRECATION_MESSAGE); - } - public static class CompatibleRestIndexAction extends RestIndexAction { @Override public String getName() { @@ -41,12 +34,16 @@ public String getName() { @Override public List routes() { - return List.of(new Route(POST, "/{index}/{type}/{id}"), new Route(PUT, "/{index}/{type}/{id}")); + return List.of(Route.builder(POST, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build(), + Route.builder(PUT, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - logDeprecationMessage(); request.param("type"); return super.prepareRequest(request, client); } @@ -61,12 +58,16 @@ public String getName() { @Override public List routes() { - return List.of(new Route(POST, "/{index}/{type}/{id}/_create"), new Route(PUT, "/{index}/{type}/{id}/_create")); + return List.of(Route.builder(POST, "/{index}/{type}/{id}/_create") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build(), + Route.builder(PUT, "/{index}/{type}/{id}/_create") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - logDeprecationMessage(); request.param("type"); return super.prepareRequest(request, client); } @@ -85,12 +86,13 @@ public String getName() { @Override public List routes() { - return singletonList(new Route(POST, "/{index}/{type}")); + return singletonList(Route.builder(POST, "/{index}/{type}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - logDeprecationMessage(); request.param("type"); return super.prepareRequest(request, client); } diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java index 75f7795931f06..02010fe2a36f6 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java @@ -41,7 +41,7 @@ public void testTypeInPathWithGet() { Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader) ).withPath("/some_index/some_type/some_id"); dispatchRequest(deprecatedRequest.withMethod(RestRequest.Method.GET).build()); - assertWarnings(RestGetActionV7.TYPES_DEPRECATION_MESSAGE, RestGetActionV7.COMPATIBLE_API_MESSAGE); + assertWarnings(RestGetActionV7.TYPES_DEPRECATION_MESSAGE); } public void testTypeInPathWithHead() { @@ -49,6 +49,6 @@ public void testTypeInPathWithHead() { Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader) ).withPath("/some_index/some_type/some_id"); dispatchRequest(deprecatedRequest.withMethod(RestRequest.Method.HEAD).build()); - assertWarnings(RestGetActionV7.TYPES_DEPRECATION_MESSAGE, RestGetActionV7.COMPATIBLE_API_MESSAGE); + assertWarnings(RestGetActionV7.TYPES_DEPRECATION_MESSAGE); } } From 8566123a5ac0224c296feabb57dca6b68b6ed79a Mon Sep 17 00:00:00 2001 From: pgomulka Date: Tue, 9 Mar 2021 14:12:55 +0100 Subject: [PATCH 25/32] remove assertion skip --- .../org/elasticsearch/test/rest/yaml/section/DoSection.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 55c4d950b327e..29a009332a093 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -388,11 +388,6 @@ void checkWarningHeaders(final List warningHeaders, final Version master final boolean matches = matcher.matches(); if (matches) { final String message = HeaderWarning.extractWarningValueFromWarningHeader(header, true); - //TODO remove once regex assertions and compatible logging strategy is settled - if (message.startsWith("[types removal]") || message.startsWith("[Compatible API usage]")) { - // We skip warnings related to types deprecation because they are *everywhere*. - continue; - } if (allowed.contains(message)) { continue; } From 80dd793077a3141031e7cb73bf691aefde3ad237 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Tue, 9 Mar 2021 14:22:46 +0100 Subject: [PATCH 26/32] skip section --- rest-api-spec/build.gradle | 1 + .../org/elasticsearch/test/rest/yaml/section/DoSection.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 73a2f9e1232e8..8e8c86b8cfb0c 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -370,4 +370,5 @@ tasks.named("yamlRestCompatTest").configure { tasks.named("transformV7RestTests").configure({ task -> task.replaceMatch("_type", "_doc") +// task.addWarning("[types removal].*") }) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 29a009332a093..86b0acd894f6d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -388,6 +388,10 @@ void checkWarningHeaders(final List warningHeaders, final Version master final boolean matches = matcher.matches(); if (matches) { final String message = HeaderWarning.extractWarningValueFromWarningHeader(header, true); + if (message.startsWith("[types removal]") ) { + // We skip warnings related to types deprecation because they are *everywhere*. + continue; + } if (allowed.contains(message)) { continue; } From af12ce3f7052ad069a38c63979821e533909f485 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Tue, 16 Mar 2021 11:59:18 +0100 Subject: [PATCH 27/32] surgical appproach --- rest-api-spec/build.gradle | 4 +- .../elasticsearch/action/ActionModule.java | 11 -- .../rest/action/document/RestGetAction.java | 15 ++- .../rest/action/document/RestGetActionV7.java | 46 -------- .../rest/action/document/RestIndexAction.java | 31 +++++- .../action/document/RestIndexActionV7.java | 100 ------------------ ...onV7Tests.java => RestGetActionTests.java} | 8 +- .../action/document/RestIndexActionTests.java | 37 +++++++ .../document/RestIndexActionV7Tests.java | 77 -------------- 9 files changed, 85 insertions(+), 244 deletions(-) delete mode 100644 server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java delete mode 100644 server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java rename server/src/test/java/org/elasticsearch/rest/action/document/{RestGetActionV7Tests.java => RestGetActionTests.java} (88%) delete mode 100644 server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionV7Tests.java diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 8e8c86b8cfb0c..fd10a2a06965d 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -168,8 +168,8 @@ tasks.named("yamlRestCompatTest").configure { 'get_source/81_missing_with_types/Missing document with ignore', 'get_source/86_source_missing_with_types/Missing document source with catch', 'get_source/86_source_missing_with_types/Missing document source with ignore', - 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', - 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', + 'index/70_mix_typeless_typeful/Index call that introduces new field mappings', // failing due to include_type_name #48632 + 'index/70_mix_typeless_typeful/Index with typeless API on an index that has types', // failing due to include_type_name #48632 'indices.clone/10_basic/Clone index via API', 'indices.create/10_basic/Create index with explicit _doc type', 'indices.create/10_basic/Create index without soft deletes', diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index bece95525ef76..cecdd2ac6fb19 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -224,7 +224,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.NamedRegistry; -import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.multibindings.MapBinder; @@ -352,12 +351,10 @@ import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.rest.action.document.RestDeleteAction; import org.elasticsearch.rest.action.document.RestGetAction; -import org.elasticsearch.rest.action.document.RestGetActionV7; import org.elasticsearch.rest.action.document.RestGetSourceAction; import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.rest.action.document.RestIndexAction.AutoIdHandler; import org.elasticsearch.rest.action.document.RestIndexAction.CreateHandler; -import org.elasticsearch.rest.action.document.RestIndexActionV7; import org.elasticsearch.rest.action.document.RestMultiGetAction; import org.elasticsearch.rest.action.document.RestMultiTermVectorsAction; import org.elasticsearch.rest.action.document.RestTermVectorsAction; @@ -780,14 +777,6 @@ public void initRestHandlers(Supplier nodesInCluster) { } registerHandler.accept(new RestCatAction(catActions)); - // Rest Compatible API - if(RestApiVersion.minimumSupported() == RestApiVersion.V_7){ - registerHandler.accept(new RestIndexActionV7.CompatibleRestIndexAction()); - registerHandler.accept(new RestIndexActionV7.CompatibleCreateHandler()); - registerHandler.accept(new RestIndexActionV7.CompatibleAutoIdHandler(nodesInCluster)); - registerHandler.accept(new RestGetActionV7()); - } - } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index 9532cfbcdc997..649647a864321 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.common.Strings; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; @@ -29,6 +30,8 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetAction extends BaseRestHandler { + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + + "document get requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; @Override public String getName() { @@ -39,11 +42,21 @@ public String getName() { public List routes() { return List.of( new Route(GET, "/{index}/_doc/{id}"), - new Route(HEAD, "/{index}/_doc/{id}")); + new Route(HEAD, "/{index}/_doc/{id}"), + Route.builder(GET, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build(), + Route.builder(HEAD, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { + if(request.getRestApiVersion() == RestApiVersion.V_7) { + request.param("type"); // consume and ignore the type + } + GetRequest getRequest = new GetRequest(request.param("index"), request.param("id")); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java deleted file mode 100644 index 0b630670986f4..0000000000000 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetActionV7.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.rest.action.document; - -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.RestApiVersion; -import org.elasticsearch.rest.RestRequest; - -import java.io.IOException; -import java.util.List; - -import static org.elasticsearch.rest.RestRequest.Method.GET; -import static org.elasticsearch.rest.RestRequest.Method.HEAD; - -public class RestGetActionV7 extends RestGetAction { - - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " - + "document get requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; - - @Override - public String getName() { - return super.getName() + "_v7"; - } - - @Override - public List routes() { - return List.of(Route.builder(GET, "/{index}/{type}/{id}") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build(), - Route.builder(HEAD, "/{index}/{type}/{id}") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build()); - } - - @Override - public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - request.param("type"); - return super.prepareRequest(request, client); - } -} diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index f5671c8ed8338..239e950d6ea8d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -14,6 +14,7 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -29,11 +30,21 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestIndexAction extends BaseRestHandler { + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in document " + + "index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, " + + "or /{index}/_create/{id})."; + @Override public List routes() { return List.of( new Route(POST, "/{index}/_doc/{id}"), - new Route(PUT, "/{index}/_doc/{id}")); + new Route(PUT, "/{index}/_doc/{id}"), + Route.builder(POST, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build(), + Route.builder(PUT, "/{index}/{type}/{id}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override @@ -52,7 +63,13 @@ public String getName() { public List routes() { return List.of( new Route(POST, "/{index}/_create/{id}"), - new Route(PUT, "/{index}/_create/{id}")); + new Route(PUT, "/{index}/_create/{id}"), + Route.builder(POST, "/{index}/{type}/{id}/_create") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build(), + Route.builder(PUT, "/{index}/{type}/{id}/_create") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override @@ -84,7 +101,11 @@ public String getName() { @Override public List routes() { - return List.of(new Route(POST, "/{index}/_doc")); + return List.of( + new Route(POST, "/{index}/_doc"), + Route.builder(POST, "/{index}/{type}") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) + .build()); } @Override @@ -100,6 +121,10 @@ public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { + if(request.getRestApiVersion() == RestApiVersion.V_7) { + request.param("type"); // consume and ignore the type + } + IndexRequest indexRequest = new IndexRequest(request.param("index")); indexRequest.id(request.param("id")); indexRequest.routing(request.param("routing")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java deleted file mode 100644 index 891e18bc59e6a..0000000000000 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexActionV7.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.rest.action.document; - -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.common.RestApiVersion; -import org.elasticsearch.rest.RestRequest; - -import java.io.IOException; -import java.util.List; -import java.util.function.Supplier; - -import static java.util.Collections.singletonList; -import static org.elasticsearch.rest.RestRequest.Method.POST; -import static org.elasticsearch.rest.RestRequest.Method.PUT; - -public class RestIndexActionV7 { - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in document " - + "index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, " - + "or /{index}/_create/{id})."; - - public static class CompatibleRestIndexAction extends RestIndexAction { - @Override - public String getName() { - return super.getName() + "_v7"; - } - - @Override - public List routes() { - return List.of(Route.builder(POST, "/{index}/{type}/{id}") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build(), - Route.builder(PUT, "/{index}/{type}/{id}") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build()); - } - - @Override - public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - request.param("type"); - return super.prepareRequest(request, client); - } - } - - public static class CompatibleCreateHandler extends RestIndexAction.CreateHandler { - - @Override - public String getName() { - return "document_create_action_v7"; - } - - @Override - public List routes() { - return List.of(Route.builder(POST, "/{index}/{type}/{id}/_create") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build(), - Route.builder(PUT, "/{index}/{type}/{id}/_create") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build()); - } - - @Override - public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - request.param("type"); - return super.prepareRequest(request, client); - } - } - - public static final class CompatibleAutoIdHandler extends RestIndexAction.AutoIdHandler { - - public CompatibleAutoIdHandler(Supplier nodesInCluster) { - super(nodesInCluster); - } - - @Override - public String getName() { - return "document_create_action_auto_id_v7"; - } - - @Override - public List routes() { - return singletonList(Route.builder(POST, "/{index}/{type}") - .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7) - .build()); - } - - @Override - public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException { - request.param("type"); - return super.prepareRequest(request, client); - } - } -} diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java similarity index 88% rename from server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java rename to server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java index 02010fe2a36f6..874170ae7ddaa 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionV7Tests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java @@ -23,13 +23,13 @@ import static org.hamcrest.Matchers.instanceOf; -public class RestGetActionV7Tests extends RestActionTestCase { +public class RestGetActionTests extends RestActionTestCase { final List contentTypeHeader = Collections.singletonList("application/vnd.elasticsearch+json;compatible-with="+ RestApiVersion.V_7.major); @Before public void setUpAction() { - controller().registerHandler(new RestGetActionV7()); + controller().registerHandler(new RestGetAction()); verifyingClient.setExecuteVerifier((actionType, request) -> { assertThat(request, instanceOf(GetRequest.class)); return Mockito.mock(GetResponse.class); @@ -41,7 +41,7 @@ public void testTypeInPathWithGet() { Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader) ).withPath("/some_index/some_type/some_id"); dispatchRequest(deprecatedRequest.withMethod(RestRequest.Method.GET).build()); - assertWarnings(RestGetActionV7.TYPES_DEPRECATION_MESSAGE); + assertWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE); } public void testTypeInPathWithHead() { @@ -49,6 +49,6 @@ public void testTypeInPathWithHead() { Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader) ).withPath("/some_index/some_type/some_id"); dispatchRequest(deprecatedRequest.withMethod(RestRequest.Method.HEAD).build()); - assertWarnings(RestGetActionV7.TYPES_DEPRECATION_MESSAGE); + assertWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE); } } diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java index b864ac16b17f2..0efa728e765e9 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.shard.ShardId; @@ -28,6 +29,9 @@ import org.elasticsearch.test.rest.RestActionTestCase; import org.junit.Before; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.equalTo; @@ -35,6 +39,9 @@ public class RestIndexActionTests extends RestActionTestCase { + final List contentTypeHeader = + Collections.singletonList("application/vnd.elasticsearch+json;compatible-with="+ RestApiVersion.V_7.major); + private final AtomicReference clusterStateSupplier = new AtomicReference<>(); @Before @@ -84,4 +91,34 @@ private void checkAutoIdOpType(Version minClusterVersion, DocWriteRequest.OpType dispatchRequest(autoIdRequest); assertThat(executeCalled.get(), equalTo(true)); } + + public void testTypeInPath() { + // using CompatibleRestIndexAction + RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.PUT) + .withHeaders(Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader)) + .withPath("/some_index/some_type/some_id") + .build(); + dispatchRequest(deprecatedRequest); + assertWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE); + } + + public void testCreateWithTypeInPath() { + // using CompatibleCreateHandler + RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.PUT) + .withHeaders(Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader)) + .withPath("/some_index/some_type/some_id/_create") + .build(); + dispatchRequest(deprecatedRequest); + assertWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE); + } + + public void testAutoIdWithType() { + // using CompatibleAutoIdHandler + RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.POST) + .withHeaders(Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader)) + .withPath("/some_index/some_type/") + .build(); + dispatchRequest(deprecatedRequest); + assertWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE); + } } diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionV7Tests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionV7Tests.java deleted file mode 100644 index b56d2d1c231d4..0000000000000 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionV7Tests.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.rest.action.document; - -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.RestApiVersion; -import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.test.rest.RestActionTestCase; -import org.junit.Before; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import static org.hamcrest.Matchers.instanceOf; - -public class RestIndexActionV7Tests extends RestActionTestCase { - - final List contentTypeHeader = - Collections.singletonList("application/vnd.elasticsearch+json;compatible-with="+ RestApiVersion.V_7.major); - - - private final AtomicReference clusterStateSupplier = new AtomicReference<>(); - - @Before - public void setUpAction() { - controller().registerHandler(new RestIndexActionV7.CompatibleRestIndexAction()); - controller().registerHandler(new RestIndexActionV7.CompatibleCreateHandler()); - controller().registerHandler(new RestIndexActionV7.CompatibleAutoIdHandler(() -> clusterStateSupplier.get().nodes())); - - verifyingClient.setExecuteVerifier((actionType, request) -> { - assertThat(request, instanceOf(IndexRequest.class)); - return new IndexResponse(new ShardId("test", "test", 0), "id", 0, 0, 0, true); - }); - } - - public void testTypeInPath() { - // using CompatibleRestIndexAction - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.PUT) - .withHeaders(Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader)) - .withPath("/some_index/some_type/some_id") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestIndexActionV7.TYPES_DEPRECATION_MESSAGE); - } - - public void testCreateWithTypeInPath() { - // using CompatibleCreateHandler - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.PUT) - .withHeaders(Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader)) - .withPath("/some_index/some_type/some_id/_create") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestIndexActionV7.TYPES_DEPRECATION_MESSAGE); - } - - public void testAutoIdWithType() { - // using CompatibleAutoIdHandler - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.POST) - .withHeaders(Map.of("Content-Type", contentTypeHeader, "Accept", contentTypeHeader)) - .withPath("/some_index/some_type/") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestIndexActionV7.TYPES_DEPRECATION_MESSAGE); - } -} From a6993299bc593e144e108b2114a952139837034a Mon Sep 17 00:00:00 2001 From: pgomulka Date: Tue, 16 Mar 2021 12:59:30 +0100 Subject: [PATCH 28/32] remove empty space --- server/src/main/java/org/elasticsearch/action/ActionModule.java | 1 - server/src/main/java/org/elasticsearch/index/get/GetResult.java | 2 +- .../org/elasticsearch/rest/action/document/RestGetAction.java | 2 +- .../org/elasticsearch/rest/action/document/RestIndexAction.java | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index cecdd2ac6fb19..16ae2aa19870f 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -776,7 +776,6 @@ public void initRestHandlers(Supplier nodesInCluster) { } } registerHandler.accept(new RestCatAction(catActions)); - } @Override diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index 3e83cbc862612..add338cc426ab 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -284,7 +284,7 @@ public XContentBuilder toXContentEmbedded(XContentBuilder builder, Params params } @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(_INDEX, index); if (builder.getRestApiVersion() == RestApiVersion.V_7) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index 649647a864321..a6a47f0baebb6 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java @@ -53,7 +53,7 @@ public List routes() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - if(request.getRestApiVersion() == RestApiVersion.V_7) { + if (request.getRestApiVersion() == RestApiVersion.V_7) { request.param("type"); // consume and ignore the type } diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 239e950d6ea8d..50ca7acb37d17 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -121,7 +121,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - if(request.getRestApiVersion() == RestApiVersion.V_7) { + if (request.getRestApiVersion() == RestApiVersion.V_7) { request.param("type"); // consume and ignore the type } From 8dcea4c60daadab37f024954eebfcef0ec9cd7e8 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Wed, 17 Mar 2021 07:34:48 +0100 Subject: [PATCH 29/32] enable get tests and use allowed warnings --- rest-api-spec/build.gradle | 21 ++++--------------- .../test/rest/yaml/section/DoSection.java | 5 +---- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 40bd43635a5ac..e8101d069f359 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -143,22 +143,9 @@ tasks.named("yamlRestCompatTest").configure { 'explain/40_mix_typeless_typeful/Explain with typeless API on an index that has types', 'field_caps/10_basic/Get date_nanos field caps', 'field_caps/30_filter/Field caps with index filter', - 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types', - 'get/10_basic/Basic', - 'get/11_basic_with_types/Basic', - 'get/15_default_values/Default values', - 'get/16_default_values_with_types/Default values', - 'get/20_stored_fields/Stored fields', - 'get/21_stored_fields_with_types/Stored fields', - 'get/41_routing_with_types/Routing', - 'get/50_with_headers/REST test with headers', - 'get/51_with_headers_with_types/REST test with headers', - 'get/61_realtime_refresh_with_types/Realtime Refresh', - 'get/70_source_filtering/Source filtering', - 'get/71_source_filtering_with_types/Source filtering', - 'get/81_missing_with_types/Missing document with catch', - 'get/81_missing_with_types/Missing document with ignore', - 'get/91_versions_with_types/Versions', + 'get/100_mix_typeless_typeful/GET with typeless API on an index that has types',// failing due to include_type_name #48632 + 'get/21_stored_fields_with_types/Stored fields', // failing due to include_type_name #48632 + 'get/71_source_filtering_with_types/Source filtering',// failing due to include_type_name #48632 'get_source/11_basic_with_types/Basic with types', 'get_source/16_default_values_with_types/Default values', 'get_source/41_routing_with_types/Routing', @@ -367,5 +354,5 @@ tasks.named("yamlRestCompatTest").configure { tasks.named("transformV7RestTests").configure({ task -> task.replaceMatch("_type", "_doc") -// task.addWarning("[types removal].*") + task.addAllowedWarningRegex("\\[types removal\\].*") }) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 86b0acd894f6d..54f5f2783466d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -388,10 +388,7 @@ void checkWarningHeaders(final List warningHeaders, final Version master final boolean matches = matcher.matches(); if (matches) { final String message = HeaderWarning.extractWarningValueFromWarningHeader(header, true); - if (message.startsWith("[types removal]") ) { - // We skip warnings related to types deprecation because they are *everywhere*. - continue; - } + if (allowed.contains(message)) { continue; } From ee88fab657f9ca7d7ebf57255643fc340b9d4e4a Mon Sep 17 00:00:00 2001 From: pgomulka Date: Thu, 18 Mar 2021 10:08:54 +0100 Subject: [PATCH 30/32] make classes final and remove empty line --- .../elasticsearch/rest/action/document/RestIndexAction.java | 4 ++-- .../org/elasticsearch/test/rest/yaml/section/DoSection.java | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 50ca7acb37d17..7756a6f3c241c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -52,7 +52,7 @@ public String getName() { return "document_index_action"; } - public static class CreateHandler extends RestIndexAction { + public static final class CreateHandler extends RestIndexAction { @Override public String getName() { @@ -86,7 +86,7 @@ void validateOpType(String opType) { } } - public static class AutoIdHandler extends RestIndexAction { + public static final class AutoIdHandler extends RestIndexAction { private final Supplier nodesInCluster; diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 54f5f2783466d..29a009332a093 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -388,7 +388,6 @@ void checkWarningHeaders(final List warningHeaders, final Version master final boolean matches = matcher.matches(); if (matches) { final String message = HeaderWarning.extractWarningValueFromWarningHeader(header, true); - if (allowed.contains(message)) { continue; } From 5899451cad78ad1cdfb1d719c73e17532336b08e Mon Sep 17 00:00:00 2001 From: pgomulka Date: Mon, 22 Mar 2021 09:29:37 +0100 Subject: [PATCH 31/32] use Mapping service type fields --- .../main/java/org/elasticsearch/action/DocWriteResponse.java | 3 +-- .../src/main/java/org/elasticsearch/index/get/GetResult.java | 5 +---- .../java/org/elasticsearch/index/mapper/MapperService.java | 1 + .../java/org/elasticsearch/action/DocWriteResponseTests.java | 4 ++-- .../rest/action/document/RestGetActionTests.java | 3 +-- .../rest/action/document/RestIndexActionTests.java | 3 +-- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java index 162fb99279fff..11719ec413fdd 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java @@ -42,7 +42,6 @@ * A base class for the response of a write operation that involves a single doc */ public abstract class DocWriteResponse extends ReplicationResponse implements WriteResponse, StatusToXContentObject { - static final String TYPE_FIELD_NAME = "_type"; private static final String _SHARDS = "_shards"; private static final String _INDEX = "_index"; @@ -296,7 +295,7 @@ private void writeWithoutShardId(StreamOutput out) throws IOException { public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (builder.getRestApiVersion() == RestApiVersion.V_7) { - builder.field(TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME); + builder.field(MapperService.TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME); } innerToXContent(builder, params); builder.endObject(); diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index add338cc426ab..9f595a7a2d722 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -18,7 +18,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.text.Text; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; @@ -42,8 +41,6 @@ public class GetResult implements Writeable, Iterable, ToXContentObject { - private static final String TYPE_FIELD_NAME = "_type"; - private static final Text SINGLE_MAPPING_TYPE = new Text(MapperService.SINGLE_MAPPING_NAME); public static final String _INDEX = "_index"; public static final String _ID = "_id"; @@ -288,7 +285,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.startObject(); builder.field(_INDEX, index); if (builder.getRestApiVersion() == RestApiVersion.V_7) { - builder.field(TYPE_FIELD_NAME, SINGLE_MAPPING_TYPE); + builder.field(MapperService.TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME); } builder.field(_ID, id); if (isExists()) { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java index af87c3fd60e89..36cc35160dc43 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -77,6 +77,7 @@ public enum MergeReason { } public static final String SINGLE_MAPPING_NAME = "_doc"; + public static final String TYPE_FIELD_NAME = "_type"; public static final Setting INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING = Setting.longSetting("index.mapping.nested_fields.limit", 50L, 0, Property.Dynamic, Property.IndexScope); // maximum allowed number of nested json objects across all fields in a single document diff --git a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java index 290abf7b92bb3..f20e8ccaaa23e 100644 --- a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java @@ -115,7 +115,7 @@ public void testTypeWhenCompatible() throws IOException { response.toXContent(builder, ToXContent.EMPTY_PARAMS); try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(builder))) { - assertThat(parser.map(), hasEntry(DocWriteResponse.TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME)); + assertThat(parser.map(), hasEntry(MapperService.TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME)); } } @@ -124,7 +124,7 @@ public void testTypeWhenCompatible() throws IOException { response.toXContent(builder, ToXContent.EMPTY_PARAMS); try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(builder))) { - assertThat(parser.map(), not(hasKey(DocWriteResponse.TYPE_FIELD_NAME))); + assertThat(parser.map(), not(hasKey(MapperService.TYPE_FIELD_NAME))); } } } diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java index 874170ae7ddaa..2e403e4a7d015 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java @@ -24,8 +24,7 @@ import static org.hamcrest.Matchers.instanceOf; public class RestGetActionTests extends RestActionTestCase { - final List contentTypeHeader = - Collections.singletonList("application/vnd.elasticsearch+json;compatible-with="+ RestApiVersion.V_7.major); + final List contentTypeHeader = Collections.singletonList(randomCompatibleMediaType(RestApiVersion.V_7)); @Before public void setUpAction() { diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java index 0efa728e765e9..41379f80e0c55 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java @@ -39,8 +39,7 @@ public class RestIndexActionTests extends RestActionTestCase { - final List contentTypeHeader = - Collections.singletonList("application/vnd.elasticsearch+json;compatible-with="+ RestApiVersion.V_7.major); + final List contentTypeHeader = Collections.singletonList(randomCompatibleMediaType(RestApiVersion.V_7)); private final AtomicReference clusterStateSupplier = new AtomicReference<>(); From 7993dd1546a107a85cb2ddaa694ab91f1cb288c5 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Mon, 22 Mar 2021 09:33:59 +0100 Subject: [PATCH 32/32] empty line --- server/src/main/java/org/elasticsearch/index/get/GetResult.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index 9f595a7a2d722..9d3da1c5239f9 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -41,7 +41,6 @@ public class GetResult implements Writeable, Iterable, ToXContentObject { - public static final String _INDEX = "_index"; public static final String _ID = "_id"; private static final String _VERSION = "_version";