@Test
  public void testHeartbeaterReplicationTxn() throws Exception {
    MetastoreConf.ConfVars timeThresholdConfVar = MetastoreConf.ConfVars.REPL_TXN_TIMEOUT;
    Assert.assertTrue(txnMgr instanceof DbTxnManager);

    addTableInput();
    LockException exception = null;
    String replPolicy = "default.*";
    // Case 1: If there's no delay for the heartbeat, txn should be able to commit
    txnMgr.replOpenTxn(replPolicy, Arrays.asList(1L), "fred");
    runReaper();
    try {
      CommitTxnRequest commitTxnRequest = new CommitTxnRequest(1);
      commitTxnRequest.setReplPolicy(replPolicy);
      commitTxnRequest.setTxn_type(TxnType.REPL_CREATED);
      txnMgr.replCommitTxn(commitTxnRequest);
    } catch (LockException e) {
      exception = e;
    }
    Assert.assertNull("Txn commit should be successful", exception);
    txnMgr.replOpenTxn(replPolicy, Arrays.asList(1L), "jerry");
    Thread.sleep(MetastoreConf.getTimeVar(conf, timeThresholdConfVar, TimeUnit.MILLISECONDS));
    runReaper();
    try {
      CommitTxnRequest commitTxnRequest = new CommitTxnRequest(1);
      commitTxnRequest.setReplPolicy(replPolicy);
      commitTxnRequest.setTxn_type(TxnType.REPL_CREATED);
      txnMgr.replCommitTxn(commitTxnRequest);
    } catch (LockException e) {
      exception = e;
    }
    Assert.assertNull("This CommitTxnRequest is no op since transaction is already aborted by reaper.", exception);
    try {
      txnMgr.replRollbackTxn(replPolicy, 1L);
    } catch (LockException e) {
      exception = e;
    }
    Assert.assertNull("This AbortTxnRequest is no op since transaction is already aborted by reaper.", exception);
    Assert.assertEquals(1, Metrics.getOrCreateCounter(MetricsConstants.TOTAL_NUM_TIMED_OUT_TXNS).getCount());
  }
Same as testHeartbeater, but testing cleanup of replication txns (TxnType.REPL_CREATED)
Note: in TestDbTxnManager metastore.repl.txn.timeout is set to 30s for testing purposes.
ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager.java