Added 'IntegrationTests' annotation to filter integration tests

Tests now support ignoring integartion tests by passing
'-Dtests.integration=false' to the test runner either via IDE or
maven to only run fast unittests.
This commit is contained in:
Simon Willnauer 2013-09-11 22:12:38 +02:00
parent ff54cba807
commit c2675bac50
3 changed files with 19 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import com.carrotsearch.randomizedtesting.LifecycleScope;
import com.carrotsearch.randomizedtesting.RandomizedContext;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.annotations.Listeners;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import com.carrotsearch.randomizedtesting.annotations.TestMethodProviders;
import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
@ -42,6 +43,7 @@ import org.junit.runner.RunWith;
import java.io.Closeable;
import java.io.File;
import java.lang.annotation.*;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
@ -60,6 +62,16 @@ import java.util.logging.Logger;
// NOTE: this class is in o.a.lucene.util since it uses some classes that are related
// to the test framework that didn't make sense to copy but are package private access
public class AbstractRandomizedTest extends RandomizedTest {
/**
* Annotation for integration tests
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@TestGroup(enabled = true, sysProperty = SYSPROP_INTEGRATION)
public @interface IntegrationTests {}
// --------------------------------------------------------------------
// Test groups, system properties and other annotations modifying tests
// --------------------------------------------------------------------
@ -69,6 +81,8 @@ public class AbstractRandomizedTest extends RandomizedTest {
/** @see #ignoreAfterMaxFailures*/
public static final String SYSPROP_FAILFAST = "tests.failfast";
public static final String SYSPROP_INTEGRATION = "tests.integration";
// -----------------------------------------------------------------
// Truly immutable fields and constants, initialized once and valid

View File

@ -20,6 +20,7 @@
package org.elasticsearch;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.util.AbstractRandomizedTest.IntegrationTests;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -39,11 +40,12 @@ import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
@Ignore
@IntegrationTests
public abstract class AbstractNodesTests extends ElasticsearchTestCase {
private static Map<String, Node> nodes = newHashMap();

View File

@ -20,6 +20,7 @@ package org.elasticsearch;
import com.google.common.base.Joiner;
import com.google.common.collect.Iterators;
import org.apache.lucene.util.AbstractRandomizedTest.IntegrationTests;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
@ -80,6 +81,7 @@ import static org.hamcrest.Matchers.equalTo;
* transient settings the baseclass will raise and error.
*/
@Ignore
@IntegrationTests
public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
private static TestCluster cluster;