HBASE-19310 Avoid an NPE IntegrationTestImportTsv when outside of the context of JUnit

Signed-off-by: Michael Stack <stack@apache.org>
Signed-off-by: Ted Yu <tedyu@apache.org>
This commit is contained in:
Josh Elser 2017-11-21 13:34:51 -05:00
parent 548ebbc574
commit b0b6064293
1 changed files with 9 additions and 3 deletions

View File

@ -185,13 +185,15 @@ public class IntegrationTestImportTsv extends Configured implements Tool {
@Test
public void testGenerateAndLoad() throws Exception {
generateAndLoad(TableName.valueOf(name.getMethodName()));
}
void generateAndLoad(final TableName table) throws Exception {
LOG.info("Running test testGenerateAndLoad.");
final TableName table = TableName.valueOf(name.getMethodName());
String cf = "d";
Path hfiles = new Path(
util.getDataTestDirOnTestFS(table.getNameAsString()), "hfiles");
Map<String, String> args = new HashMap<>();
args.put(ImportTsv.BULK_OUTPUT_CONF_KEY, hfiles.toString());
args.put(ImportTsv.COLUMNS_CONF_KEY,
@ -226,7 +228,11 @@ public class IntegrationTestImportTsv extends Configured implements Tool {
// adding more test methods? Don't forget to add them here... or consider doing what
// IntegrationTestsDriver does.
provisionCluster();
testGenerateAndLoad();
TableName tableName = TableName.valueOf("IntegrationTestImportTsv");
if (util.getAdmin().tableExists(tableName)) {
util.deleteTable(tableName);
}
generateAndLoad(tableName);
releaseCluster();
return 0;