@Test
  public void testGetQueryLogForReplCommands() throws Exception {
    // Prepare
    String primaryDb = testName.getMethodName() + "_" + System.currentTimeMillis();
    String replicaDb = primaryDb + "_replica";
    String primaryTblName = primaryDb + ".t1";
    Path replDir = new Path(conf.get("test.data.files"));
    HiveStatement stmt = (HiveStatement) con.createStatement();
    assertNotNull("Statement is null", stmt);
    
    replDir = new Path(replDir, primaryDb + "_repl");
    FileSystem fs = FileSystem.get(replDir.toUri(), conf);
    fs.mkdirs(replDir);

    try {
      // Prepare
      stmt.execute("set hive.exec.parallel = true");
      stmt.execute("set hive.server2.logging.operation.level = execution");
      stmt.execute("set hive.metastore.transactional.event.listeners =" +
              " org.apache.hive.hcatalog.listener.DbNotificationListener");
      stmt.execute("set hive.metastore.dml.events = true");
      stmt.execute("set hive.repl.cm.enabled = true");
      stmt.execute("set hive.repl.cmrootdir = cmroot");
      stmt.execute("set " + ConfVars.HIVE_TXN_MANAGER.varname + "=" + ConfVars.HIVE_TXN_MANAGER.defaultStrVal);
      stmt.execute("create database " + primaryDb + " with dbproperties('repl.source.for'='1,2,3')");
      stmt.execute("create table " + primaryTblName + " (id int)");
      stmt.execute("insert into " + primaryTblName + " values (1), (2)");
      stmt.close();

      // Test query logs for bootstrap dump and load
      String[] expectedBootstrapDumpLogs = {
        "REPL::START",
        "REPL::TABLE_DUMP",
        "REPL::END"
      };

      // Bootstrap dump
      stmt = (HiveStatement) con.createStatement();
      advanceDumpDir();
      ResultSet replDumpRslt = stmt.executeQuery("repl dump " + primaryDb +
              " with ('hive.repl.rootdir' = '" + replDir + "')");
      assertTrue(replDumpRslt.next());
      List<String> logs = stmt.getQueryLog(false, 10000);
      stmt.close();
      LOG.info("Query_Log for Bootstrap Dump");
      verifyFetchedLog(logs, expectedBootstrapDumpLogs);

      String[] expectedBootstrapLoadLogs = {
        "REPL::START",
        "REPL::TABLE_LOAD",
        "REPL::END"
      };

      // Bootstrap load
      stmt = (HiveStatement) con.createStatement();
      stmt.execute("repl load " + primaryDb + " into " + replicaDb +
              " with ('hive.repl.rootdir' = '" + replDir + "')");
      logs = stmt.getQueryLog(false, 10000);
      stmt.close();
      LOG.info("Query_Log for Bootstrap Load");
      verifyFetchedLog(logs, expectedBootstrapLoadLogs);

      // Perform operation for incremental replication
      stmt = (HiveStatement) con.createStatement();
      stmt.execute("insert into " + primaryTblName + " values (3), (4)");
      stmt.close();

      // Test query logs for incremental dump and load
      String[] expectedIncrementalDumpLogs = {
        "REPL::START",
        "REPL::EVENT_DUMP",
        "REPL::END"
      };

      // Incremental dump
      stmt = (HiveStatement) con.createStatement();
      advanceDumpDir();
      replDumpRslt = stmt.executeQuery("repl dump " + primaryDb +
              " with ('hive.repl.rootdir' = '" + replDir + "')");
      assertTrue(replDumpRslt.next());
      logs = stmt.getQueryLog(false, 10000);
      stmt.close();
      LOG.info("Query_Log for Incremental Dump");
      verifyFetchedLog(logs, expectedIncrementalDumpLogs);

      String[] expectedIncrementalLoadLogs = {
        "REPL::START",
        "REPL::EVENT_LOAD",
        "REPL::END"
      };

      // Incremental load
      stmt = (HiveStatement) con.createStatement();
      stmt.execute("repl load " + primaryDb + " into " + replicaDb +
              " with ('hive.repl.rootdir' = '" + replDir + "')");
      logs = stmt.getQueryLog(false, 10000);
      LOG.info("Query_Log for Incremental Load");
      verifyFetchedLog(logs, expectedIncrementalLoadLogs);
    } finally {
      fs.delete(replDir, true);
      // DB cleanup
      stmt.execute("drop database if exists " + primaryDb + " cascade");
      stmt.execute("drop database if exists " + replicaDb + " cascade");
      stmt.execute("set hive.exec.parallel = false");
      stmt.execute("set hive.server2.logging.operation.level = verbose");
      stmt.execute("set hive.metastore.dml.events = false");
      stmt.execute("set hive.metastore.transactional.event.listeners = ");
      stmt.close();
    }
  }
Test getting query log method in Jdbc for REPL commands
@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java