From 9e9b835213309b00c8c08ccac66b207e0b3cd851 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 29 Sep 2015 07:49:44 -0400 Subject: [PATCH] Move watcher REST tests that require groovy to smoke-test-watcher-with-groovy See https://github.com/elastic/x-plugins/issues/724 Original commit: elastic/x-pack-elasticsearch@ab95aef8e34f6e456bd782a9ba5cd0f0d87a2177 --- qa/pom.xml | 1 + .../integration-tests.xml | 32 +++ qa/smoke-test-watcher-with-groovy/pom.xml | 188 ++++++++++++++++++ .../test/watcher_groovy}/10_basic.yaml | 0 .../test/watcher_groovy}/20_minimal_body.yaml | 0 .../test/watcher_groovy}/30_inline_watch.yaml | 0 .../smoketest/WatcherRestTestCase.java | 81 ++++++++ .../smoketest/WatcherWithGroovyIT.java | 17 ++ 8 files changed, 319 insertions(+) create mode 100644 qa/smoke-test-watcher-with-groovy/integration-tests.xml create mode 100644 qa/smoke-test-watcher-with-groovy/pom.xml rename {watcher/src/test/resources/rest-api-spec/test/execute_watch => qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy}/10_basic.yaml (100%) rename {watcher/src/test/resources/rest-api-spec/test/execute_watch => qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy}/20_minimal_body.yaml (100%) rename {watcher/src/test/resources/rest-api-spec/test/execute_watch => qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy}/30_inline_watch.yaml (100%) create mode 100644 qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherRestTestCase.java create mode 100644 qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherWithGroovyIT.java diff --git a/qa/pom.xml b/qa/pom.xml index b5061593262..a402f1793f5 100644 --- a/qa/pom.xml +++ b/qa/pom.xml @@ -308,6 +308,7 @@ smoke-test-plugins-ssl--> shield-core-rest-tests smoke-test-watcher-with-shield + smoke-test-watcher-with-groovy shield-example-realm shield-tribe-node-tests shield-client-tests diff --git a/qa/smoke-test-watcher-with-groovy/integration-tests.xml b/qa/smoke-test-watcher-with-groovy/integration-tests.xml new file mode 100644 index 00000000000..db4e3d96a6b --- /dev/null +++ b/qa/smoke-test-watcher-with-groovy/integration-tests.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + diff --git a/qa/smoke-test-watcher-with-groovy/pom.xml b/qa/smoke-test-watcher-with-groovy/pom.xml new file mode 100644 index 00000000000..4be0245ec8d --- /dev/null +++ b/qa/smoke-test-watcher-with-groovy/pom.xml @@ -0,0 +1,188 @@ + + + + + + 4.0.0 + + + org.elasticsearch.qa + x-plugins-qa + 3.0.0-SNAPSHOT + + + smoke-test-watcher-with-groovy + QA: Smoke Test Watcher's Groovy integration + Installs Watcher and runs some REST tests that use groovy scripting + + + true + ${project.basedir}/integration-tests.xml + watcher_groovy + false + + + + + org.elasticsearch.plugin + license + ${elasticsearch.version} + test + + + org.elasticsearch.plugin + watcher + ${project.version} + test + + + + + + + + ${elasticsearch.tools.directory}/rest-api-spec + rest-api-spec + + + api/info.json + api/cluster.health.json + api/cluster.state.json + + + + + ../../watcher/src/test/resources/rest-api-spec + true + rest-api-spec + + api/*.json + + + + + ${project.basedir}/rest-api-spec + true + rest-api-spec + + test/**/*.yaml + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + integ-setup-dependencies + pre-integration-test + + copy + + + ${skip.integ.tests} + true + ${integ.deps}/plugins + + + + + org.elasticsearch.distribution.zip + elasticsearch + ${elasticsearch.version} + zip + true + ${integ.deps} + + + + + org.elasticsearch.plugin + license + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + watcher + ${elasticsearch.version} + zip + true + + + + + org.elasticsearch.plugin + lang-groovy + ${elasticsearch.version} + zip + true + + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + integ-setup + pre-integration-test + + run + + + + + + + + + ${skip.integ.tests} + + + + + integ-teardown + post-integration-test + + run + + + + + + ${skip.integ.tests} + + + + + + + + diff --git a/watcher/src/test/resources/rest-api-spec/test/execute_watch/10_basic.yaml b/qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy/10_basic.yaml similarity index 100% rename from watcher/src/test/resources/rest-api-spec/test/execute_watch/10_basic.yaml rename to qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy/10_basic.yaml diff --git a/watcher/src/test/resources/rest-api-spec/test/execute_watch/20_minimal_body.yaml b/qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy/20_minimal_body.yaml similarity index 100% rename from watcher/src/test/resources/rest-api-spec/test/execute_watch/20_minimal_body.yaml rename to qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy/20_minimal_body.yaml diff --git a/watcher/src/test/resources/rest-api-spec/test/execute_watch/30_inline_watch.yaml b/qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy/30_inline_watch.yaml similarity index 100% rename from watcher/src/test/resources/rest-api-spec/test/execute_watch/30_inline_watch.yaml rename to qa/smoke-test-watcher-with-groovy/rest-api-spec/test/watcher_groovy/30_inline_watch.yaml diff --git a/qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherRestTestCase.java b/qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherRestTestCase.java new file mode 100644 index 00000000000..2173cd82578 --- /dev/null +++ b/qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherRestTestCase.java @@ -0,0 +1,81 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.watcher.test.rest; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.elasticsearch.common.network.NetworkAddress; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.plugin.LicensePlugin; +import org.elasticsearch.node.Node; +import org.elasticsearch.test.ESIntegTestCase.ClusterScope; +import org.elasticsearch.test.junit.annotations.TestLogging; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.parser.RestTestParseException; +import org.elasticsearch.watcher.WatcherPlugin; +import org.junit.After; +import org.junit.Before; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.URI; + +import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; + + +@ESRestTestCase.Rest +@ClusterScope(scope = SUITE, numClientNodes = 1, transportClientRatio = 0, numDataNodes = 1, randomDynamicTemplates = false) +@TestLogging("_root:DEBUG") +public abstract class WatcherRestTestCase extends ESRestTestCase { + + public WatcherRestTestCase(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ESRestTestCase.createParameters(0, 1); + } + + @Before + public void startWatcher() throws Exception { + try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) { + InetSocketAddress address = cluster().httpAddresses()[0]; + HttpPut request = new HttpPut(new URI("http", null, NetworkAddress.formatAddress(address.getAddress()), address.getPort(), "/_watcher/_start", null, null)); + client.execute(request); + } + } + + @After + public void stopWatcher() throws Exception { + try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) { + InetSocketAddress address = cluster().httpAddresses()[0]; + HttpPut request = new HttpPut(new URI("http", null, NetworkAddress.formatAddress(address.getAddress()), address.getPort(), "/_watcher/_stop", null, null)); + client.execute(request); + } + } + + @Override + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(Node.HTTP_ENABLED, true) + .build(); + } + + @Override + protected Settings transportClientSettings() { + return Settings.builder() + .put(Node.HTTP_ENABLED, true) + .build(); + } + +} diff --git a/qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherWithGroovyIT.java b/qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherWithGroovyIT.java new file mode 100644 index 00000000000..fd8232869d4 --- /dev/null +++ b/qa/smoke-test-watcher-with-groovy/src/test/java/org/elasticsearch/smoketest/WatcherWithGroovyIT.java @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.watcher.test.rest; + +import org.elasticsearch.test.rest.RestTestCandidate; + +/** Runs rest tests against external cluster */ +public class WatcherWithGroovyIT extends WatcherRestTestCase { + + public WatcherWithGroovyIT(RestTestCandidate testCandidate) { + super(testCandidate); + } + +}