Move tests to elasticsearch test framework

Closes #46.
This commit is contained in:
David Pilato 2014-01-13 14:44:56 +01:00
parent 04f15cd56b
commit 9cc331b12d
6 changed files with 223 additions and 28 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
/.idea
/target
.DS_Store
.local-execution-hints.log
*.iml
/.settings
/.project

135
pom.xml
View File

@ -31,7 +31,15 @@
</parent>
<properties>
<elasticsearch.version>0.90.4</elasticsearch.version>
<elasticsearch.version>0.90.10</elasticsearch.version>
<lucene.version>4.6.0</lucene.version>
<tests.output>onerror</tests.output>
<tests.jvms>1</tests.jvms>
<tests.shuffle>true</tests.shuffle>
<tests.output>onerror</tests.output>
<tests.client.ratio></tests.client.ratio>
<tests.jvm.argline></tests.jvm.argline>
<es.logger.level>INFO</es.logger.level>
</properties>
<repositories>
@ -42,6 +50,13 @@
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>${lucene.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
@ -49,6 +64,14 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
@ -87,13 +110,6 @@
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
@ -107,6 +123,15 @@
<version>1.3.RC2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
@ -120,14 +145,102 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
<version>2.0.14</version>
<executions>
<execution>
<id>tests</id>
<phase>test</phase>
<goals>
<goal>junit4</goal>
</goals>
<configuration>
<heartbeat>20</heartbeat>
<jvmOutputAction>pipe,warn</jvmOutputAction>
<leaveTemporary>true</leaveTemporary>
<listeners>
<report-ant-xml mavenExtensions="true"
dir="${project.build.directory}/surefire-reports"/>
<report-text
showThrowable="true"
showStackTraces="true"
showOutput="${tests.output}"
showStatusOk="false"
showStatusError="true"
showStatusFailure="true"
showStatusIgnored="true"
showSuiteSummary="true"
timestamps="false"/>
<report-execution-times file="${basedir}/.local-execution-hints.log"/>
</listeners>
<assertions>
<enable/>
</assertions>
<parallelism>${tests.jvms}</parallelism>
<balancers>
<execution-times>
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
</execution-times>
</balancers>
<includes>
<include>**/*Tests.class</include>
<include>**/*Test.class</include>
</includes>
<excludes>
<exclude>**/Abstract*.class</exclude>
<exclude>**/*StressTest.class</exclude>
</excludes>
<argLine>
${tests.jvm.argline}
</argLine>
<jvmArgs>
<param>-Xmx512m</param>
<param>-Xss256k</param>
<param>-XX:MaxDirectMemorySize=512m</param>
<param>-Des.logger.prefix=</param>
</jvmArgs>
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
<sysouts>${tests.verbose}</sysouts>
<seed>${tests.seed}</seed>
<haltOnFailure>${tests.failfast}</haltOnFailure>
<systemProperties>
<!-- RandomizedTesting library system properties -->
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
<tests.iters>${tests.iters}</tests.iters>
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
<tests.failfast>${tests.failfast}</tests.failfast>
<tests.class>${tests.class}</tests.class>
<tests.method>${tests.method}</tests.method>
<tests.nightly>${tests.nightly}</tests.nightly>
<tests.badapples>${tests.badapples}</tests.badapples>
<tests.weekly>${tests.weekly}</tests.weekly>
<tests.slow>${tests.slow}</tests.slow>
<tests.aws>${tests.aws}</tests.aws>
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
<tests.slow>${tests.slow}</tests.slow>
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
<tests.integration>${tests.integration}</tests.integration>
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
<es.node.mode>${es.node.mode}</es.node.mode>
<es.config>${es.config}</es.config>
<es.logger.level>${es.logger.level}</es.logger.level>
<java.awt.headless>true</java.awt.headless>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
<skip>true</skip>
</configuration>
</plugin>
<plugin>

View File

@ -0,0 +1,63 @@
/*
* Licensed to Elasticsearch (the "Author") under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Author 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.cloud.aws;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
*
*/
public abstract class AbstractAwsTest extends ElasticsearchIntegrationTest {
/**
* Annotation for tests that require AWS to run. AWS tests are disabled by default.
* <p/>
* To enable test add -Dtests.aws=true -Des.config=/path/to/elasticsearch.yml
* <p/>
* The elasticsearch.yml file should contain the following keys
* <pre>
* cloud:
* aws:
* access_key: AKVAIQBF2RECL7FJWGJQ
* secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
* region: "us-west"
*
* discovery:
# type: ec2
* </pre>
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@TestGroup(enabled = false, sysProperty = SYSPROP_AWS)
public @interface AwsTest {
}
/**
*/
public static final String SYSPROP_AWS = "tests.aws";
}

View File

@ -20,22 +20,31 @@
package org.elasticsearch.discovery.ec2;
import org.elasticsearch.node.NodeBuilder;
import org.junit.Ignore;
import org.elasticsearch.cloud.aws.AbstractAwsTest;
import org.elasticsearch.cloud.aws.AbstractAwsTest.AwsTest;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
import org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
import org.junit.Test;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
/**
* Just an empty Node Start test to check eveything if fine when
* starting.
* This test is marked as ignored.
* If you want to run your own test, please modify first test/resources/elasticsearch.yml file
* with your own AWS credentials
* This test requires AWS to run.
*/
public class Ec2DiscoveryITest {
@AwsTest
@ClusterScope(scope = Scope.TEST, numNodes = 0)
public class Ec2DiscoveryITest extends AbstractAwsTest {
@Test @Ignore
@Test
public void testStart() {
NodeBuilder.nodeBuilder().node();
Settings nodeSettings = settingsBuilder()
.put("cloud.enabled", true)
.put("discovery.type", "ec2")
.build();
cluster().startNode(nodeSettings);
}
}

View File

@ -1,10 +1,10 @@
# Replace this access_key / secret_key with your own if you want
# to run tests
cloud:
aws:
access_key: AKVAIQBF2RECL7FJWGJQ
secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
discovery:
type: ec2
# Replace this access_key / secret_key and bucket name with your own if you want
# to run tests.
#cloud:
# aws:
# access_key: AKVAIQBF2RECL7FJWGJQ
# secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
#
#discovery:
# type: ec2

View File

@ -0,0 +1,9 @@
es.logger.level=INFO
log4j.rootLogger=${es.logger.level}, out
log4j.appender.out=org.apache.log4j.ConsoleAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.conversionPattern=[%d{ISO8601}][%-5p][%-25c] %m%n
log4j.logger.org.elasticsearch.snapshots=TRACE
log4j.logger.org.elasticsearch.index.snapshots=TRACE
log4j.logger.com.amazonaws=INFO