@Test
public void testTruncateInvalidTxBefore() throws Exception {

  Transaction tx1 = txClient.startLong();
  TimeUnit.MILLISECONDS.sleep(1);
  long beforeTx2 = System.currentTimeMillis();
  Transaction tx2 = txClient.startLong();
  // Try before invalidation
  Assert.assertEquals(0, txClient.getInvalidSize());
  TransactionAdmin txAdmin = new TransactionAdmin(new PrintStream(System.out), new PrintStream(System.err));
  int status = txAdmin.doMain(new String[]{"--truncate-invalid-tx-before", String.valueOf(beforeTx2)}, conf);
  // Assert command failed due to in-progress transactions
  Assert.assertEquals(1, status);
  // Assert no change to invalid size
  Assert.assertEquals(0, txClient.getInvalidSize());
  txClient.invalidate(tx1.getTransactionId());
  txClient.invalidate(tx2.getTransactionId());
  Assert.assertEquals(2, txClient.getInvalidSize());
  status = txAdmin.doMain(new String[]{"--truncate-invalid-tx-before", String.valueOf(beforeTx2)}, conf);
  Assert.assertEquals(0, status);
  Assert.assertEquals(1, txClient.getInvalidSize());
}