in phoenix5-hive/src/it/java/org/apache/hadoop/hive/ql/QTestUtil.java [975:1023]
public void cleanUp(String tname) throws Exception {
boolean canReuseSession = (tname == null) || !qNoSessionReuseQuerySet.contains(tname);
if(!isSessionStateStarted) {
startSessionState(canReuseSession);
}
if (System.getenv(QTEST_LEAVE_FILES) != null) {
return;
}
clearTablesCreatedDuringTests();
clearUDFsCreatedDuringTests();
clearKeysCreatedInTests();
File cleanupFile = new File(cleanupScript);
if (cleanupFile.isFile()) {
String cleanupCommands = readEntireFileIntoString(cleanupFile);
LOG.info("Cleanup (" + cleanupScript + "):\n" + cleanupCommands);
if(cliDriver == null) {
cliDriver = new CliDriver();
}
SessionState.get().getConf().setBoolean("hive.test.shutdown.phase", true);
int result = cliDriver.processLine(cleanupCommands);
if (result != 0) {
LOG.error("Failed during cleanup processLine with code={}. Ignoring", result);
// TODO Convert this to an Assert.fail once HIVE-14682 is fixed
}
SessionState.get().getConf().setBoolean("hive.test.shutdown.phase", false);
} else {
LOG.info("No cleanup script detected. Skipping.");
}
// delete any contents in the warehouse dir
Path p = new Path(testWarehouse);
FileSystem fs = p.getFileSystem(conf);
try {
FileStatus [] ls = fs.listStatus(p);
for (int i=0; (ls != null) && (i<ls.length); i++) {
fs.delete(ls[i].getPath(), true);
}
} catch (FileNotFoundException e) {
// Best effort
}
// TODO: Clean up all the other paths that are created.
FunctionRegistry.unregisterTemporaryUDF("test_udaf");
FunctionRegistry.unregisterTemporaryUDF("test_error");
}