Use ThirdParty annotation and remove duplicate test config.

See elastic/elasticsearch-parent#41
This commit is contained in:
Robert Muir 2015-05-13 22:59:35 -04:00
parent 3823c40471
commit e5ceabf734
7 changed files with 55 additions and 114 deletions

84
pom.xml
View File

@ -44,7 +44,6 @@ governing permissions and limitations under the License. -->
<properties>
<!-- You can add any specific project property here -->
<tests.security.manager>true</tests.security.manager>
</properties>
<dependencies>
@ -118,89 +117,6 @@ governing permissions and limitations under the License. -->
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
<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>1</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.azure>${tests.azure}</tests.azure>
<tests.config>${tests.config}</tests.config>
<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.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>

View File

@ -0,0 +1,43 @@
package org.apache.lucene.store;
/*
* 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 org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.bootstrap.BootstrapForTesting;
import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
import com.carrotsearch.randomizedtesting.annotations.Listeners;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
/**
* Extends Lucene's BaseDirectoryTestCase with ES test behavior.
*/
@Listeners({
ReproduceInfoPrinter.class
})
@TimeoutSuite(millis = TimeUnits.HOUR)
@LuceneTestCase.SuppressReproduceLine
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
public abstract class ElasticSearchBaseDirectoryTestCase extends BaseDirectoryTestCase {
static {
BootstrapForTesting.ensureInitialized();
}
}

View File

@ -22,7 +22,7 @@ package org.apache.lucene.store;
import java.io.IOException;
import java.nio.file.Path;
public class SmbMMapDirectoryTest extends BaseDirectoryTestCase {
public class SmbMMapDirectoryTest extends ElasticSearchBaseDirectoryTestCase {
@Override
protected Directory getDirectory(Path file) throws IOException {

View File

@ -22,7 +22,7 @@ package org.apache.lucene.store;
import java.io.IOException;
import java.nio.file.Path;
public class SmbSimpleFSDirectoryTest extends BaseDirectoryTestCase {
public class SmbSimpleFSDirectoryTest extends ElasticSearchBaseDirectoryTestCase {
@Override
protected Directory getDirectory(Path file) throws IOException {

View File

@ -28,11 +28,10 @@ import org.hamcrest.Matchers;
import org.junit.Test;
/**
* This test needs Azure to run and -Dtests.azure=true to be set
* This test needs Azure to run and -Dtests.thirdparty=true to be set
* and -Des.config=/path/to/elasticsearch.yml
* @see org.elasticsearch.cloud.azure.AbstractAzureTest
*/
@AbstractAzureTest.AzureTest
@ElasticsearchIntegrationTest.ClusterScope(
scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 1,

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cloud.azure;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
@ -27,32 +26,17 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.env.FailedToResolveConfigException;
import org.elasticsearch.plugins.PluginsService;
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;
import org.elasticsearch.test.ElasticsearchIntegrationTest.ThirdParty;
/**
*
* Base class for Azure tests that require credentials.
* <p>
* You must specify {@code -Dtests.thirdparty=true -Dtests.config=/path/to/config}
* in order to run these tests.
*/
@ThirdParty
public abstract class AbstractAzureTest extends ElasticsearchIntegrationTest {
/**
* Annotation for tests that require Azure to run. Azure tests are disabled by default.
* See README file for details.
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@TestGroup(enabled = false, sysProperty = SYSPROP_AZURE)
public @interface AzureTest {
}
/**
*/
public static final String SYSPROP_AZURE = "tests.azure";
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.builder()
@ -72,10 +56,10 @@ public abstract class AbstractAzureTest extends ElasticsearchIntegrationTest {
if (Strings.hasText(System.getProperty("tests.config"))) {
settings.loadFromUrl(environment.resolveConfig(System.getProperty("tests.config")));
} else {
fail("to run integration tests, you need to set -Dtest.azure=true and -Dtests.config=/path/to/elasticsearch.yml");
throw new IllegalStateException("to run integration tests, you need to set -Dtests.thirdparty=true and -Dtests.config=/path/to/elasticsearch.yml");
}
} catch (FailedToResolveConfigException exception) {
fail("your test configuration file is incorrect: " + System.getProperty("tests.config"));
throw new IllegalStateException("your test configuration file is incorrect: " + System.getProperty("tests.config"), exception);
}
return settings.build();
}

View File

@ -52,11 +52,10 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
/**
* This test needs Azure to run and -Dtests.azure=true to be set
* This test needs Azure to run and -Dtests.thirdparty=true to be set
* and -Dtests.config=/path/to/elasticsearch.yml
* @see org.elasticsearch.cloud.azure.AbstractAzureTest
*/
@AbstractAzureTest.AzureTest
@ElasticsearchIntegrationTest.ClusterScope(
scope = ElasticsearchIntegrationTest.Scope.SUITE,
numDataNodes = 1,