diff --git itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index 85e3bda..3f47749 100644 --- itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -537,10 +537,11 @@ public void clearPostTestEffects() throws Exception { /** * Clear out any side effects of running tests */ - public void clearTestSideEffects() throws Exception { + public void clearTablesCreatedDuringTests() throws Exception { if (System.getenv(QTEST_LEAVE_FILES) != null) { return; } + // Delete any tables other than the source tables // and any databases other than the default database. for (String dbName : db.getAllDatabases()) { @@ -574,9 +575,11 @@ public void clearTestSideEffects() throws Exception { try { Path p = new Path(testWarehouse); FileSystem fileSystem = p.getFileSystem(conf); - for (FileStatus status : fileSystem.listStatus(p)) { - if (status.isDir() && !srcTables.contains(status.getPath().getName())) { - fileSystem.delete(status.getPath(), true); + if (fileSystem.exists(p)) { + for (FileStatus status : fileSystem.listStatus(p)) { + if (status.isDir() && !srcTables.contains(status.getPath().getName())) { + fileSystem.delete(status.getPath(), true); + } } } } catch (IllegalArgumentException e) { @@ -590,6 +593,18 @@ public void clearTestSideEffects() throws Exception { db.dropRole(roleName); } } + } + + /** + * Clear out any side effects of running tests + */ + public void clearTestSideEffects() throws Exception { + if (System.getenv(QTEST_LEAVE_FILES) != null) { + return; + } + + clearTablesCreatedDuringTests(); + // allocate and initialize a new conf since a test can // modify conf by using 'set' commands conf = new HiveConf (Driver.class); @@ -606,6 +621,8 @@ public void cleanUp() throws Exception { return; } + clearTablesCreatedDuringTests(); + SessionState.get().getConf().setBoolean("hive.test.shutdown.phase", true); String cleanupCommands = readEntireFileIntoString(new File(cleanupScript));