public void cleanUp() throws Exception {
    if (!isSessionStateStarted) {
      startSessionState(qTestResultProcessor.canReuseSession());
    }
    if (System.getenv(QTEST_LEAVE_FILES) != null) {
      return;
    }
    conf.setBoolean("hive.test.shutdown.phase", true);

    clearKeysCreatedInTests();

    String metastoreDb = QTestSystemProperties.getMetaStoreDb();
    if (metastoreDb == null || "derby".equalsIgnoreCase(metastoreDb)) {
      // otherwise, the docker container is already destroyed by this time
      cleanupFromFile();
    }

    // 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");
  }
Clear out any side effects of running tests
itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java