diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java
index 0a8eaa1c2bc..65650ea4bfd 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestsDriver.java
@@ -39,7 +39,8 @@ import org.apache.commons.logging.LogFactory;
* already deployed distributed cluster.
*/
public class IntegrationTestsDriver extends AbstractHBaseTool {
- private static final String TESTS_ARG = "test";
+ private static final String SHORT_REGEX_ARG = "r";
+ private static final String LONG_REGEX_ARG = "regex";
private static final Log LOG = LogFactory.getLog(IntegrationTestsDriver.class);
private IntegrationTestFilter intTestFilter = new IntegrationTestFilter();
@@ -49,7 +50,7 @@ public class IntegrationTestsDriver extends AbstractHBaseTool {
}
private class IntegrationTestFilter extends ClassTestFinder.TestClassFilter {
- private Pattern testFilterRe = Pattern.compile(".*");
+ private Pattern testFilterRe = Pattern.compile(".*\\.IntegrationTest.*");
public IntegrationTestFilter() {
super(IntegrationTests.class);
}
@@ -60,18 +61,25 @@ public class IntegrationTestsDriver extends AbstractHBaseTool {
@Override
public boolean isCandidateClass(Class> c) {
- return super.isCandidateClass(c) && testFilterRe.matcher(c.getName()).find();
+ return testFilterRe.matcher(c.getName()).find() &&
+ // Our pattern will match the below NON-IntegrationTest. Rather than
+ // do exotic regex, just filter it out here
+ !c.getName().contains("IntegrationTestingUtility") &&
+ super.isCandidateClass(c);
}
}
@Override
protected void addOptions() {
- addOptWithArg(TESTS_ARG, "a Java regular expression to filter tests on");
+ addOptWithArg(SHORT_REGEX_ARG, LONG_REGEX_ARG,
+ "Java regex to use selecting tests to run: e.g. .*TestBig.*" +
+ " will select all tests that include TestBig in their name. Default: " +
+ ".*IntegrationTest.*");
}
@Override
protected void processOptions(CommandLine cmd) {
- String testFilterString = cmd.getOptionValue(TESTS_ARG, null);
+ String testFilterString = cmd.getOptionValue(SHORT_REGEX_ARG, null);
if (testFilterString != null) {
intTestFilter.setPattern(testFilterString);
}
@@ -95,8 +103,10 @@ public class IntegrationTestsDriver extends AbstractHBaseTool {
//this is called from the command line, so we should set to use the distributed cluster
IntegrationTestingUtility.setUseDistributedCluster(conf);
Class>[] classes = findIntegrationTestClasses();
- LOG.info("Found " + classes.length + " integration tests to run");
-
+ LOG.info("Found " + classes.length + " integration tests to run:");
+ for (int i = 0; i < classes.length; i++) {
+ LOG.info(" " + classes[i]);
+ }
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
Result result = junit.run(classes);
@@ -104,4 +114,4 @@ public class IntegrationTestsDriver extends AbstractHBaseTool {
return result.wasSuccessful() ? 0 : 1;
}
-}
\ No newline at end of file
+}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
index e3633c94fff..e0c170d762b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
@@ -43,7 +43,8 @@ public abstract class AbstractHBaseTool implements Tool {
private static final int EXIT_SUCCESS = 0;
private static final int EXIT_FAILURE = 1;
- private static final String HELP_OPTION = "help";
+ private static final String SHORT_HELP_OPTION = "h";
+ private static final String LONG_HELP_OPTION = "help";
private static final Log LOG = LogFactory.getLog(AbstractHBaseTool.class);
@@ -94,7 +95,8 @@ public abstract class AbstractHBaseTool implements Tool {
return EXIT_FAILURE;
}
- if (cmd.hasOption(HELP_OPTION) || !sanityCheckOptions(cmd)) {
+ if (cmd.hasOption(SHORT_HELP_OPTION) || cmd.hasOption(LONG_HELP_OPTION) ||
+ !sanityCheckOptions(cmd)) {
printUsage();
return EXIT_FAILURE;
}
@@ -123,7 +125,7 @@ public abstract class AbstractHBaseTool implements Tool {
}
private CommandLine parseArgs(String[] args) throws ParseException {
- options.addOption(HELP_OPTION, false, "Show usage");
+ options.addOption(SHORT_HELP_OPTION, LONG_HELP_OPTION, false, "Show usage");
addOptions();
CommandLineParser parser = new BasicParser();
return parser.parse(options, args);
@@ -149,10 +151,18 @@ public abstract class AbstractHBaseTool implements Tool {
options.addOption(opt, false, description);
}
+ protected void addOptNoArg(String shortOpt, String longOpt, String description) {
+ options.addOption(shortOpt, longOpt, false, description);
+ }
+
protected void addOptWithArg(String opt, String description) {
options.addOption(opt, true, description);
}
+ protected void addOptWithArg(String shortOpt, String longOpt, String description) {
+ options.addOption(shortOpt, longOpt, true, description);
+ }
+
/**
* Parse a number and enforce a range.
*/
diff --git a/src/main/docbkx/developer.xml b/src/main/docbkx/developer.xml
index 521b242156f..86bd145c1d3 100644
--- a/src/main/docbkx/developer.xml
+++ b/src/main/docbkx/developer.xml
@@ -723,10 +723,10 @@ If you have an already-setup HBase cluster, you can launch the integration tests
run test-compile first. The configuration will be picked by the bin/hbase script.
mvn test-compile
Then launch the tests with:
-bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver [-test=class_regex]
-
-This execution will launch the tests under hbase-it/src/test, having @Category(IntegrationTests.class) annotation,
-and a name starting with IntegrationTests. 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.
+bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver
+Pass -h to get usage on this sweet tool. Running the IntegrationTestsDriver without any argument will launch tests found under hbase-it/src/test, having @Category(IntegrationTests.class) annotation,
+and a name starting with IntegrationTests. See the usage, by passing -h, to see how to filter test classes.
+You can pass a regex which is checked against the 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 HBASE-6201).