@Test
  public void testQueryloglocParentDirNotExist() throws Exception {
    String parentTmpDir = tmpdir + "/HIVE2654";
    Path parentDirPath = new Path(parentTmpDir);
    try {
      fs.delete(parentDirPath, true);
    } catch (Exception e) {
    }
    try {
      String actualDir = parentTmpDir + "/test";
      HiveConf conf = getHiveConf();
      conf.set(HiveConf.ConfVars.HIVE_HISTORY_FILE_LOC.toString(), actualDir);
      SessionState ss = new CliSessionState(conf);
      HiveHistory hiveHistory = new HiveHistoryImpl(ss);
      Path actualPath = new Path(actualDir);
      if (!fs.exists(actualPath)) {
        fail("Query location path is not exist :" + actualPath.toString());
      }
    } finally {
      try {
        fs.delete(parentDirPath, true);
      } catch (Exception e) {
      }
    }
  }
Check history file output for this query.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/history/TestHiveHistory.java