HBASE-8428 Tighten up IntegrationTestsDriver filter
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1475996 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
939da7c026
commit
7b3dc4f7ba
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
<programlisting>mvn test-compile</programlisting>
|
||||
Then launch the tests with:
|
||||
<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>. 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.
|
||||
<programlisting>bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver</programlisting>
|
||||
Pass <code>-h</code> to get usage on this sweet tool. Running the IntegrationTestsDriver without any argument will launch tests found under <code>hbase-it/src/test</code>, having <code>@Category(IntegrationTests.class)</code> annotation,
|
||||
and a name starting with <code>IntegrationTests</code>. 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 <link xlink:href="https://issues.apache.org/jira/browse/HBASE-6201">HBASE-6201</link>).
|
||||
</para>
|
||||
|
||||
|
|
Loading…
Reference in New Issue