You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2012/12/04 23:56:19 UTC
svn commit: r1417230 - in /hbase/trunk:
hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java
hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java
src/docbkx/developer.xml
Author: stack
Date: Tue Dec 4 22:56:18 2012
New Revision: 1417230
URL: http://svn.apache.org/viewvc?rev=1417230&view=rev
Log:
HBASE-7249 add test name filter to IntegrationTestsDriver
Modified:
hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java
hbase/trunk/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java
hbase/trunk/src/docbkx/developer.xml
Modified: hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java?rev=1417230&r1=1417229&r2=1417230&view=diff
==============================================================================
--- hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java (original)
+++ hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java Tue Dec 4 22:56:18 2012
@@ -50,7 +50,7 @@ public class ClassTestFinder extends Cla
return new Class<?>[0];
}
- private static class TestFileNameFilter implements FileNameFilter, ResourcePathFilter {
+ public static class TestFileNameFilter implements FileNameFilter, ResourcePathFilter {
private static final Pattern hadoopCompactRe =
Pattern.compile("hbase-hadoop\\d?-compat");
@@ -73,7 +73,7 @@ public class ClassTestFinder extends Cla
* - one or more of its methods is annotated with org.junit.Test OR
* - the class is annotated with Suite.SuiteClasses
* */
- private static class TestClassFilter implements ClassFilter {
+ public static class TestClassFilter implements ClassFilter {
private Class<?> categoryAnnotation = null;
public TestClassFilter(Class<?> categoryAnnotation) {
this.categoryAnnotation = categoryAnnotation;
Modified: hbase/trunk/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java?rev=1417230&r1=1417229&r2=1417230&view=diff
==============================================================================
--- hbase/trunk/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java (original)
+++ hbase/trunk/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java Tue Dec 4 22:56:18 2012
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase;
import java.io.IOException;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.commons.cli.CommandLine;
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
@@ -38,30 +39,55 @@ import org.apache.commons.logging.LogFac
* already deployed distributed cluster.
*/
public class IntegrationTestsDriver extends AbstractHBaseTool {
+ private static final String TESTS_ARG = "test";
private static final Log LOG = LogFactory.getLog(IntegrationTestsDriver.class);
+ private IntegrationTestFilter intTestFilter = new IntegrationTestFilter();
public static void main(String[] args) throws Exception {
int ret = ToolRunner.run(new IntegrationTestsDriver(), args);
System.exit(ret);
}
+ private class IntegrationTestFilter extends ClassTestFinder.TestClassFilter {
+ private Pattern testFilterRe = Pattern.compile(".*");
+ public IntegrationTestFilter() {
+ super(IntegrationTests.class);
+ }
+
+ public void setPattern(String pattern) {
+ testFilterRe = Pattern.compile(pattern);
+ }
+
+ @Override
+ public boolean isCandidateClass(Class<?> c) {
+ return super.isCandidateClass(c) && testFilterRe.matcher(c.getName()).find();
+ }
+ }
+
@Override
protected void addOptions() {
+ addOptWithArg(TESTS_ARG, "a Java regular expression to filter tests on");
}
@Override
protected void processOptions(CommandLine cmd) {
+ String testFilterString = cmd.getOptionValue(TESTS_ARG, null);
+ if (testFilterString != null) {
+ intTestFilter.setPattern(testFilterString);
+ }
}
/**
- * Returns test classes annotated with @Category(IntegrationTests.class)
+ * Returns test classes annotated with @Category(IntegrationTests.class),
+ * according to the filter specific on the command line (if any).
*/
private Class<?>[] findIntegrationTestClasses()
throws ClassNotFoundException, LinkageError, IOException {
- ClassTestFinder classFinder = new ClassTestFinder(IntegrationTests.class);
- Set<Class<?>> classes = classFinder.findClasses(true);
- return classes.toArray(new Class<?>[classes.size()]);
- }
+ ClassTestFinder.TestFileNameFilter nameFilter = new ClassTestFinder.TestFileNameFilter();
+ ClassFinder classFinder = new ClassFinder(nameFilter, nameFilter, intTestFilter);
+ Set<Class<?>> classes = classFinder.findClasses(true);
+ return classes.toArray(new Class<?>[classes.size()]);
+ }
@Override
Modified: hbase/trunk/src/docbkx/developer.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/docbkx/developer.xml?rev=1417230&r1=1417229&r2=1417230&view=diff
==============================================================================
--- hbase/trunk/src/docbkx/developer.xml (original)
+++ hbase/trunk/src/docbkx/developer.xml Tue Dec 4 22:56:18 2012
@@ -669,10 +669,11 @@ If you have an already-setup HBase clust
run test-compile first. The configuration will be picked by the bin/hbase script.
<programlisting>mvn test-compile</programlisting>
Then launch the tests with:
-<programlisting>bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver</programlisting>
+<programlisting>bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver [-test=class_regex]</programlisting>
This execution will launch the tests under <code>hbase-it/src/test</code>, having <code>@Category(IntegrationTests.class)</code> annotation,
-and a name starting with <code>IntegrationTests</code>. It uses Junit to run the tests. Currently there is no support for running integration tests against a distributed cluster using maven (see <link xlink:href="https://issues.apache.org/jira/browse/HBASE-6201">HBASE-6201</link>).
+and a name starting with <code>IntegrationTests</code>. If specified, class_regex will be used to filter test classes. The regex is checked against full class name; so, part of class name can be used.
+IntegrationTestsDriver uses Junit to run the tests. Currently there is no support for running integration tests against a distributed cluster using maven (see <link xlink:href="https://issues.apache.org/jira/browse/HBASE-6201">HBASE-6201</link>).
</para>
<para>