diff --git a/dev-tools/smoke_test_plugins.py b/dev-tools/smoke_test_plugins.py deleted file mode 100644 index da6c2c95209..00000000000 --- a/dev-tools/smoke_test_plugins.py +++ /dev/null @@ -1,172 +0,0 @@ -# Licensed to Elasticsearch under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on -# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -import datetime -import traceback -import json -import os -import shutil -import signal -import socket -import subprocess -import tempfile -import threading -import time - -from http.client import HTTPConnection - -LOG = os.environ.get('ES_SMOKE_TEST_PLUGINS_LOG', '/tmp/elasticsearch_smoke_test_plugins.log') - -print('Logging to %s' % LOG) - -if os.path.exists(LOG): - raise RuntimeError('please remove old log %s first' % LOG) - -try: - JAVA_HOME = os.environ['JAVA7_HOME'] -except KeyError: - try: - JAVA_HOME = os.environ['JAVA_HOME'] - except KeyError: - raise RuntimeError(""" - Please set JAVA_HOME in the env before running release tool - On OSX use: export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`""") - -JAVA_ENV = 'export JAVA_HOME="%s" PATH="%s/bin:$PATH" JAVACMD="%s/bin/java"' % (JAVA_HOME, JAVA_HOME, JAVA_HOME) - -try: - # make sure mvn3 is used if mvn3 is available - # some systems use maven 2 as default - subprocess.check_output('mvn3 --version', shell=True, stderr=subprocess.STDOUT) - MVN = 'mvn3' -except subprocess.CalledProcessError: - MVN = 'mvn' - -def log(msg): - f = open(LOG, mode='ab') - f.write(('\n'+msg).encode('utf-8')) - f.close() - -def run(command, quiet=False): - log('%s: RUN: %s\n' % (datetime.datetime.now(), command)) - if os.system('%s >> %s 2>&1' % (command, LOG)): - msg = ' FAILED: %s [see log %s]' % (command, LOG) - if not quiet: - print(msg) - raise RuntimeError(msg) - -def readServerOutput(p, startupEvent, failureEvent): - try: - while True: - line = p.stdout.readline() - if len(line) == 0: - p.poll() - if not startupEvent.isSet(): - failureEvent.set() - startupEvent.set() - print('ES: **process exit**\n') - break - line = line.decode('utf-8').rstrip() - if line.endswith('started') and not startupEvent.isSet(): - startupEvent.set() - print('ES: %s' % line) - except: - print() - print('Exception reading Elasticsearch output:') - traceback.print_exc() - failureEvent.set() - startupEvent.set() - -if __name__ == '__main__': - print('Build release bits...') - - run('%s; %s clean package -DskipTests' % (JAVA_ENV, MVN)) - - for f in os.listdir('distribution/tar/target/releases/'): - if f.endswith('.tar.gz'): - artifact = f - break - else: - raise RuntimeError('could not find elasticsearch release under distribution/tar/target/releases/') - - tmp_dir = tempfile.mkdtemp() - p = None - try: - # Extract artifact: - run('tar -xzf distribution/tar/target/releases/%s -C %s' % (artifact, tmp_dir)) - es_install_dir = os.path.join(tmp_dir, artifact[:-7]) - es_plugin_path = os.path.join(es_install_dir, 'bin/plugin') - installed_plugin_names = set() - print('Find plugins:') - for name in os.listdir('plugins'): - if name not in ('target', 'pom.xml'): - url = 'file://%s/plugins/%s/target/releases/elasticsearch-%s-2.0.0-beta1-SNAPSHOT.zip' % (os.path.abspath('.'), name, name) - print(' install plugin %s...' % name) - run('%s; %s install %s --url %s' % (JAVA_ENV, es_plugin_path, name, url)) - installed_plugin_names.add(name) - - print('Start Elasticsearch') - - env = os.environ.copy() - env['JAVA_HOME'] = JAVA_HOME - env['PATH'] = '%s/bin:%s' % (JAVA_HOME, env['PATH']) - env['JAVA_CMD'] = '%s/bin/java' % JAVA_HOME - - startupEvent = threading.Event() - failureEvent = threading.Event() - p = subprocess.Popen(('%s/bin/elasticsearch' % es_install_dir, - '-Des.node.name=smoke_tester', - '-Des.cluster.name=smoke_tester_cluster' - '-Des.discovery.zen.ping.multicast.enabled=false', - '-Des.logger.level=debug', - '-Des.script.inline=on', - '-Des.script.indexed=on'), - stdout = subprocess.PIPE, - stderr = subprocess.STDOUT, - env = env) - thread = threading.Thread(target=readServerOutput, args=(p, startupEvent, failureEvent)) - thread.setDaemon(True) - thread.start() - - startupEvent.wait(1200) - if failureEvent.isSet(): - raise RuntimeError('ES failed to start') - - print('Confirm plugins are installed') - conn = HTTPConnection('127.0.0.1', 9200, 20); - conn.request('GET', '/_nodes?plugin=true&pretty=true') - res = conn.getresponse() - if res.status == 200: - nodes = json.loads(res.read().decode("utf-8"))['nodes'] - for _, node in nodes.items(): - node_plugins = node['plugins'] - for node_plugin in node_plugins: - plugin_name = node_plugin['name'] - if plugin_name not in installed_plugin_names: - raise RuntimeError('Unexpeced plugin %s' % plugin_name) - installed_plugin_names.remove(plugin_name) - if len(installed_plugin_names) > 0: - raise RuntimeError('Plugins not loaded %s' % installed_plugin_names) - else: - raise RuntimeError('Expected HTTP 200 but got %s' % res.status) - finally: - if p is not None: - try: - os.kill(p.pid, signal.SIGKILL) - except ProcessLookupError: - pass - shutil.rmtree(tmp_dir) - diff --git a/dev-tools/src/main/resources/ant/integration-tests.xml b/dev-tools/src/main/resources/ant/integration-tests.xml index 4cd6b4728f8..8378fff5012 100644 --- a/dev-tools/src/main/resources/ant/integration-tests.xml +++ b/dev-tools/src/main/resources/ant/integration-tests.xml @@ -15,13 +15,6 @@ - - - @@ -37,14 +30,19 @@ - + + + + execute: ${script.base} @{args} + + - + @@ -119,31 +117,60 @@ + + + + + + + + + + + + + Starting up external cluster... - + + + + + - + - - + - External cluster started PID ${integ.pid} + External cluster started PID @{es.pidfile} @@ -162,12 +189,11 @@ - - + + - - + + diff --git a/pom.xml b/pom.xml index 188ed85015e..1e7ca1a6c75 100644 --- a/pom.xml +++ b/pom.xml @@ -1463,5 +1463,6 @@ org.eclipse.jdt.ui.text.custom_code_templates=core distribution plugins + qa diff --git a/qa/pom.xml b/qa/pom.xml new file mode 100644 index 00000000000..a5d68c1beaf --- /dev/null +++ b/qa/pom.xml @@ -0,0 +1,320 @@ + + + + 4.0.0 + + org.elasticsearch.qa + elasticsearch-qa + 2.0.0-beta1-SNAPSHOT + pom + QA: Parent POM + 2015 + + + org.elasticsearch + elasticsearch-parent + 2.0.0-beta1-SNAPSHOT + + + + + + + + + org.hamcrest + hamcrest-all + test + + + org.apache.lucene + lucene-test-framework + test + + + org.elasticsearch + elasticsearch + test-jar + test + + + + + org.elasticsearch + elasticsearch + provided + + + org.apache.lucene + lucene-core + provided + + + org.apache.lucene + lucene-backward-codecs + provided + + + org.apache.lucene + lucene-analyzers-common + provided + + + org.apache.lucene + lucene-queries + provided + + + org.apache.lucene + lucene-memory + provided + + + org.apache.lucene + lucene-highlighter + provided + + + org.apache.lucene + lucene-queryparser + provided + + + org.apache.lucene + lucene-suggest + provided + + + org.apache.lucene + lucene-join + provided + + + org.apache.lucene + lucene-spatial + provided + + + org.apache.lucene + lucene-expressions + provided + + + com.spatial4j + spatial4j + provided + + + com.vividsolutions + jts + provided + + + com.github.spullara.mustache.java + compiler + provided + + + com.google.guava + guava + provided + + + com.carrotsearch + hppc + provided + + + joda-time + joda-time + provided + + + org.joda + joda-convert + provided + + + com.fasterxml.jackson.core + jackson-core + provided + + + com.fasterxml.jackson.dataformat + jackson-dataformat-smile + provided + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + provided + + + com.fasterxml.jackson.dataformat + jackson-dataformat-cbor + provided + + + io.netty + netty + provided + + + com.ning + compress-lzf + provided + + + com.tdunning + t-digest + provided + + + org.apache.commons + commons-lang3 + provided + + + commons-cli + commons-cli + provided + + + org.codehaus.groovy + groovy-all + indy + provided + + + log4j + log4j + provided + + + log4j + apache-log4j-extras + provided + + + org.slf4j + slf4j-api + provided + + + net.java.dev.jna + jna + provided + + + + + + org.apache.httpcomponents + httpclient + test + + + + + + + + src/main/resources + true + + **/*.properties + + + + + + + src/test/java + + **/*.json + **/*.txt + + + + src/test/resources + + elasticsearch.yml + **/*.properties + + + + src/test/resources + true + + elasticsearch.yml + **/*.properties + + + + + ${project.basedir}/rest-api-spec + true + rest-api-spec + + api/*.json + test/**/*.yaml + + + + + ${elasticsearch.tools.directory}/rest-api-spec + rest-api-spec + + + api/info.json + api/cluster.health.json + api/cluster.state.json + + api/index.json + api/get.json + api/update.json + api/search.json + api/indices.analyze.json + api/indices.create.json + api/indices.refresh.json + api/nodes.info.json + api/count.json + + + + + ${elasticsearch.tools.directory}/shared-test-resources + false + + + + + + + com.carrotsearch.randomizedtesting + junit4-maven-plugin + + + integ-tests + + + 1 + + + 127.0.0.1:${integ.transport.port} + + + + + + + + + + + smoke-test-plugins + + diff --git a/qa/smoke-test-plugins/integration-tests.xml b/qa/smoke-test-plugins/integration-tests.xml new file mode 100644 index 00000000000..d00d8c37bab --- /dev/null +++ b/qa/smoke-test-plugins/integration-tests.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qa/smoke-test-plugins/pom.xml b/qa/smoke-test-plugins/pom.xml new file mode 100644 index 00000000000..417dcdc767a --- /dev/null +++ b/qa/smoke-test-plugins/pom.xml @@ -0,0 +1,238 @@ + + + + 4.0.0 + + + org.elasticsearch.qa + elasticsearch-qa + 2.0.0-beta1-SNAPSHOT + + + + + smoke-test-plugins + QA: Smoke Test Plugins + Loads up all of our plugins + + + true + ${project.basedir}/integration-tests.xml + smoke_test_plugins + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + integ-setup-dependencies + pre-integration-test + + copy + + + + true + ${integ.deps}/plugins + + + + + org.elasticsearch.distribution.zip + elasticsearch + ${elasticsearch.version} + zip + true + ${integ.deps} + + + + + org.elasticsearch.plugin + elasticsearch-analysis-kuromoji + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-smartcn + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-stempel + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-phonetic + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-icu + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-cloud-gce + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-cloud-azure + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-cloud-aws + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-site-example + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-lang-python + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-lang-javascript + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-delete-by-query + ${elasticsearch.version} + zip + true + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + count-expected-plugins + validate + + run + + + + + + + + Found ${expected.plugin.count} plugins in ${plugins.dir} + + true + + + + + integ-setup + pre-integration-test + + run + + + + + + + + + + + + + integ-teardown + post-integration-test + + run + + + + + + + + + + + ant-contrib + ant-contrib + 1.0b3 + + + ant + ant + + + + + org.apache.ant + ant-nodeps + 1.8.1 + + + + + + + diff --git a/qa/smoke-test-plugins/rest-api-spec/test/smoke_test_plugins/10_basic.yaml b/qa/smoke-test-plugins/rest-api-spec/test/smoke_test_plugins/10_basic.yaml new file mode 100644 index 00000000000..dbb09225fce --- /dev/null +++ b/qa/smoke-test-plugins/rest-api-spec/test/smoke_test_plugins/10_basic.yaml @@ -0,0 +1,13 @@ +# Integration tests for smoke testing plugins +# +"Correct Plugin Count": + - do: + cluster.state: {} + + # Get master node id + - set: { master_node: master } + + - do: + nodes.info: {} + + - length: { nodes.$master.plugins: ${expected.plugin.count} } diff --git a/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsIT.java b/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsIT.java new file mode 100644 index 00000000000..6e0243b2a04 --- /dev/null +++ b/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsIT.java @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.smoketest; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.parser.RestTestParseException; + +import java.io.IOException; + +public class SmokeTestPluginsIT extends ESRestTestCase { + + public SmokeTestPluginsIT(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ESRestTestCase.createParameters(0, 1); + } +} +