[TEST] move REST tests to their own test group

Closes #7795
This commit is contained in:
javanna 2014-09-19 09:54:14 +02:00 committed by Luca Cavanna
parent 9f6d6d540b
commit 4fa924494d
2 changed files with 32 additions and 7 deletions

View File

@ -101,6 +101,21 @@ public abstract class AbstractRandomizedTest extends RandomizedTest {
*/ */
public static final String TESTS_BACKWARDS_COMPATIBILITY_PATH = "tests.bwc.path"; public static final String TESTS_BACKWARDS_COMPATIBILITY_PATH = "tests.bwc.path";
/**
* Annotation for REST tests
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@TestGroup(enabled = true, sysProperty = TESTS_REST)
public @interface Rest {
}
/**
* Property that allows to control whether the REST tests are run (default) or not
*/
public static final String TESTS_REST = "tests.rest";
/** /**
* Annotation for integration tests * Annotation for integration tests
*/ */

View File

@ -19,9 +19,12 @@
package org.elasticsearch.test.rest; package org.elasticsearch.test.rest;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.lucene.util.AbstractRandomizedTest;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
@ -54,13 +57,10 @@ import java.util.Set;
//tests distribution disabled for now since it causes reporting problems, //tests distribution disabled for now since it causes reporting problems,
// due to the non unique suite name // due to the non unique suite name
//@ReplicateOnEachVm //@ReplicateOnEachVm
@AbstractRandomizedTest.Rest
@ClusterScope(randomDynamicTemplates = false) @ClusterScope(randomDynamicTemplates = false)
public class ElasticsearchRestTests extends ElasticsearchIntegrationTest { public class ElasticsearchRestTests extends ElasticsearchIntegrationTest {
/**
* Property that allows to control whether the REST tests need to be run (default) or not (false)
*/
public static final String REST_TESTS = "tests.rest";
/** /**
* Property that allows to control which REST tests get run. Supports comma separated list of tests * Property that allows to control which REST tests get run. Supports comma separated list of tests
* or directories that contain tests e.g. -Dtests.rest.suite=index,get,create/10_with_id * or directories that contain tests e.g. -Dtests.rest.suite=index,get,create/10_with_id
@ -105,9 +105,19 @@ public class ElasticsearchRestTests extends ElasticsearchIntegrationTest {
@ParametersFactory @ParametersFactory
public static Iterable<Object[]> parameters() throws IOException, RestTestParseException { public static Iterable<Object[]> parameters() throws IOException, RestTestParseException {
//skip REST tests if disabled through -Dtests.rest=false TestGroup testGroup = Rest.class.getAnnotation(TestGroup.class);
assumeTrue(systemPropertyAsBoolean(REST_TESTS, true)); String sysProperty = TestGroup.Utilities.getSysProperty(Rest.class);
boolean enabled;
try {
enabled = RandomizedTest.systemPropertyAsBoolean(sysProperty, testGroup.enabled());
} catch (IllegalArgumentException e) {
// Ignore malformed system property, disable the group if malformed though.
enabled = false;
}
if (!enabled) {
return Lists.newArrayList();
}
//parse tests only if rest test group is enabled, otherwise rest tests might not even be available on file system
List<RestTestCandidate> restTestCandidates = collectTestCandidates(); List<RestTestCandidate> restTestCandidates = collectTestCandidates();
List<Object[]> objects = Lists.newArrayList(); List<Object[]> objects = Lists.newArrayList();
for (RestTestCandidate restTestCandidate : restTestCandidates) { for (RestTestCandidate restTestCandidate : restTestCandidates) {