Merge pull request elastic/elasticsearch#968 from rmuir/integ_tests

packaging, config, and file permissions are busted

Original commit: elastic/x-pack-elasticsearch@74787a2123
This commit is contained in:
Robert Muir 2015-07-09 12:58:03 -04:00
commit f91059d1a9
7 changed files with 113 additions and 6 deletions

View File

@ -0,0 +1,61 @@
<?xml version="1.0"?>
<project name="commercial-integration-tests">
<import file="${elasticsearch.integ.antfile.default}"/>
<!-- unzip core release artifact, install license plugin, install plugin, then start ES -->
<target name="start-external-cluster-with-plugin" depends="stop-external-cluster" unless="${shouldskip}">
<local name="integ.home"/>
<local name="integ.repo.home"/>
<local name="integ.plugin.url"/>
<local name="integ.pid"/>
<delete dir="${integ.scratch}"/>
<unzip src="${org.elasticsearch:elasticsearch:zip}"
dest="${integ.scratch}"/>
<property name="integ.home" location="${integ.scratch}/elasticsearch-${elasticsearch.version}"/>
<property name="integ.repo.home" location="${integ.home}/repo"/>
<!-- begin commercial plugin mods -->
<local name="integ.license.plugin.url"/>
<makeurl property="integ.license.plugin.url" file="${org.elasticsearch:elasticsearch-license-plugin:zip}"/>
<echo>Installing license plugin...</echo>
<run-script dir="${integ.home}" script="bin/plugin"
args="-u ${integ.license.plugin.url} -i elasticsearch-license-plugin"/>
<!-- end commercial plugin mods -->
<makeurl property="integ.plugin.url" file="${project.build.directory}/releases/${project.artifactId}-${project.version}.zip"/>
<echo>Installing plugin ${project.artifactId}...</echo>
<run-script dir="${integ.home}" script="bin/plugin"
args="-u ${integ.plugin.url} -i ${project.artifactId}"/>
<!-- execute -->
<echo>Starting up external cluster...</echo>
<run-script dir="${integ.home}" script="bin/elasticsearch" spawn="true"
args="${integ.args} -Des.path.repo=${integ.repo.home}"/>
<!-- begin shield plugin mods -->
<run-script dir="${integ.home}" script="bin/shield/esusers"
args="useradd test_user -p changeme -r admin"/>
<!-- seems waitfor task doesnt support basic auth?
we do the next best thing, wait for the socket, then verify with get
<waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
<http url="http://test_user:changeme@127.0.0.1:9200"/>
</waitfor>
-->
<waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
<socket server="127.0.0.1" port="9200"/>
</waitfor>
<local name="temp.file"/>
<tempfile property="temp.file" destdir="${java.io.tmpdir}"/>
<get src="http://127.0.0.1:9200" dest="${temp.file}" username="test_user" password="changeme" verbose="true" retries="10"/>
<!-- end shield plugin mods -->
<extract-pid property="integ.pid"/>
<echo>External cluster started PID ${integ.pid}</echo>
</target>
</project>

10
pom.xml
View File

@ -47,10 +47,9 @@
</repositories>
<properties>
<!-- TODO: enable these once we add logic to install license plugin -->
<skip.integ.tests>true</skip.integ.tests>
<elasticsearch.license.header>dev-tools/elasticsearch_license_header.txt</elasticsearch.license.header>
<elasticsearch.license.headerDefinition>dev-tools/license_header_definition.xml</elasticsearch.license.headerDefinition>
<elasticsearch.integ.antfile>dev-tools/integration-tests.xml</elasticsearch.integ.antfile>
<license.plugin.version>2.0.0-SNAPSHOT</license.plugin.version>
<tests.rest.blacklist>indices.get/10_basic/*allow_no_indices*,cat.count/10_basic/Test cat count output,cat.aliases/10_basic/Empty cluster,indices.segments/10_basic/no segments test,indices.clear_cache/10_basic/clear_cache test,indices.status/10_basic/Indices status test,cat.indices/10_basic/Test cat indices output,cat.recovery/10_basic/Test cat recovery output,cat.shards/10_basic/Test cat shards output,termvector/20_issue7121/*,index/10_with_id/Index with ID,indices.get_alias/20_emtpy/*,cat.segments/10_basic/Test cat segments output,indices.put_settings/10_basic/Test indices settings allow_no_indices,indices.put_settings/10_basic/Test indices settings ignore_unavailable,indices.refresh/10_basic/Indices refresh test no-match wildcard,indices.stats/10_index/Index - star*,indices.recovery/10_basic/Indices recovery test*,template/30_render_search_template/*</tests.rest.blacklist>
</properties>
@ -96,6 +95,13 @@
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-license-plugin</artifactId>
<version>${license.plugin.version}</version>
<type>zip</type>
<scope>test</scope>
</dependency>
<!-- needed for tests that use templating -->
<dependency>
<groupId>com.github.spullara.mustache.java</groupId>

View File

@ -241,7 +241,9 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
if (state.compareAndSet(State.STARTED, State.STOPPING)) {
try {
queueConsumer.interrupt();
bulkProcessor.flush();
if (bulkProcessor != null) {
bulkProcessor.flush();
}
} finally {
state.set(State.STOPPED);
}
@ -254,7 +256,9 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
}
try {
bulkProcessor.close();
if (bulkProcessor != null) {
bulkProcessor.close();
}
} finally {
if (indexToRemoteCluster) {
if (client != null) {

View File

@ -23,6 +23,7 @@ import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.node.Node;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.shield.User;
import org.elasticsearch.shield.authc.AuthenticationService;
import org.elasticsearch.shield.authc.AuthenticationToken;
@ -124,7 +125,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest {
if (remoteIndexing) {
// start a small single-node cluster to test remote indexing against
logger.info("--> remote indexing enabled");
Settings s = Settings.builder().put("shield.enabled", "false").put("path.home", createTempDir()).build();
Settings s = Settings.builder().put(ShieldPlugin.ENABLED_SETTING_NAME, false).put("path.home", createTempDir()).build();
remoteNode = nodeBuilder().clusterName(REMOTE_TEST_CLUSTER).data(true).settings(s).node();
remoteClient = remoteNode.client();

View File

@ -7,6 +7,7 @@ package org.elasticsearch.shield.test;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.shield.ShieldPlugin;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
@ -17,6 +18,6 @@ public class ShieldAssertions {
assertThat(e.status(), is(RestStatus.UNAUTHORIZED));
assertThat(e.getHeaderKeys(), hasSize(1));
assertThat(e.getHeader("WWW-Authenticate"), notNullValue());
assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"shield\""));
assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + ShieldPlugin.NAME + "\""));
}
}

View File

@ -167,6 +167,13 @@ public abstract class ShieldIntegrationTest extends ElasticsearchIntegrationTest
.build();
}
@Override
protected Settings externalClusterClientSettings() {
return Settings.builder()
.put("shield.user", ShieldSettingsSource.DEFAULT_USER_NAME + ":" + ShieldSettingsSource.DEFAULT_PASSWORD)
.build();
}
/**
* Allows for us to get the system key that is being used for the cluster
* @return the system key bytes

View File

@ -0,0 +1,27 @@
/*
* 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.test;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.rest.ElasticsearchRestTestCase;
import org.elasticsearch.test.rest.RestTestCandidate;
import org.elasticsearch.test.rest.parser.RestTestParseException;
import java.io.IOException;
/** Runs rest tests against external cluster */
public class ShieldRestIT extends ShieldRestTestCase {
public ShieldRestIT(@Name("yaml") RestTestCandidate testCandidate) {
super(testCandidate);
}
@ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
return ElasticsearchRestTestCase.createParameters(0, 1);
}
}