@Test
  public void testDeleteWithOpenTxn() throws Exception {
    if (!Objects.equals(client.getConfigValue(String.valueOf(ConfVars.THRIFT_URIS), ""), "")) {
      System.out.println("It is not possible to create open transaction from here in Remote mode. So, skipping the test case");
      return;
    }
    String testCaseNS = "delwithopentxn";
    String replPolicy = "db100";
    // insert
    ScheduledQuery schq = createScheduledQuery3(createKey(replPolicy, testCaseNS));
    ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
    r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
    r.setScheduledQuery(schq);
    client.scheduledQueryMaintenance(r);
    // wait 2 sec to have the query execution
    Thread.sleep(2000);
    // invoke poll to create a dependent execution
    ScheduledQueryPollRequest pollRequest = new ScheduledQueryPollRequest(testCaseNS);
    client.scheduledQueryPoll(pollRequest);
    Configuration conf = metaStore.getConf();
    cleanDb(conf);
    setConfValues(conf);
    prepDb(conf);
    String query = "select \"DB_ID\" from \"DBS\" where \"NAME\" = '" + "default" + "' and \"CTLG_NAME\" = '" + "hive" + "'";
    String[] output = queryToString(conf, query).split("\n");
    if (output.length == 1) {
      query = "INSERT INTO \"DBS\"(\"DB_ID\", \"NAME\", \"CTLG_NAME\", \"DB_LOCATION_URI\")  VALUES (1, '" + "default" + "','" + "hive" + "','dummy')";
        try (Statement stmt = getConnection(conf).createStatement()) {
            stmt.executeUpdate(query);
        }
    }

    query = "INSERT INTO \"DBS\"(\"DB_ID\", \"NAME\", \"CTLG_NAME\", \"DB_LOCATION_URI\")  VALUES (2, '" + replPolicy + "','" + "hive" + "','dummy')";
      try (Statement stmt = getConnection(conf).createStatement()) {
          stmt.executeUpdate(query);
      }
      List<Long> openTxnIds = new ArrayList<>(Arrays.asList(1L, 2L));
    client.replOpenTxn(replPolicy + ".*", openTxnIds, "hive", TxnType.REPL_CREATED);
    String[] replTxnMapOutput = queryToString(conf, "SELECT \"RTM_SRC_TXN_ID\" FROM \"REPL_TXN_MAP\"").split("\n");
    assertEquals(3, replTxnMapOutput.length);
    // delete scheduled query
    r.setType(ScheduledQueryMaintenanceRequestType.DROP);
    client.scheduledQueryMaintenance(r);
    // validate repl_txn_map table
    replTxnMapOutput = queryToString(conf, "SELECT \"RTM_SRC_TXN_ID\" FROM \"REPL_TXN_MAP\"").split("\n");
    assertEquals(1, replTxnMapOutput.length);
    cleanDb(conf);
  }
Tests handling of scheduled queries related calls to the metastore.

Checks whether expected state changes are being done to the HMS database.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java