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); + } + +}