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