Program: 7570
Project: 7570
Buggy source:
@Test(timeout=60000) public void testHA() throws Exception {
  HBaseTestingUtility hBaseTestingUtility=new HBaseTestingUtility();
  hBaseTestingUtility.startMiniDFSCluster(1);
  Configuration hConf=hBaseTestingUtility.getConfiguration();
  hConf.setBoolean("String_Node_Str",true);
  InMemoryZKServer zkServer=InMemoryZKServer.builder().build();
  zkServer.startAndWait();
  try {
    CConfiguration cConf=CConfiguration.create();
    cConf.unset(Constants.CFG_HDFS_USER);
    cConf.set(Constants.Zookeeper.QUORUM,zkServer.getConnectionStr());
    cConf.set(Constants.CFG_LOCAL_DATA_DIR,tmpFolder.newFolder().getAbsolutePath());
    Injector injector=Guice.createInjector(new ConfigModule(cConf),new ZKClientModule(),new LocationRuntimeModule().getInMemoryModules(),new DiscoveryRuntimeModule().getDistributedModules(),new DataFabricModules().getDistributedModules());
    ZKClientService zkClient=injector.getInstance(ZKClientService.class);
    zkClient.startAndWait();
    final OrderedColumnarTable table=createTable("String_Node_Str",cConf);
    try {
      TransactionSystemClient txClient=injector.getInstance(TransactionSystemClient.class);
      TransactionExecutor txExecutor=new DefaultTransactionExecutor(txClient,ImmutableList.of((TransactionAware)table));
      TransactionService first=createTxService(zkServer.getConnectionStr(),Networks.getRandomPort(),hConf,tmpFolder.newFolder());
      first.startAndWait();
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,null,"String_Node_Str");
      TransactionService second=createTxService(zkServer.getConnectionStr(),Networks.getRandomPort(),hConf,tmpFolder.newFolder());
      second.startAndWait();
      TimeUnit.SECONDS.sleep(1);
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,"String_Node_Str","String_Node_Str");
      first.stopAndWait();
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,"String_Node_Str","String_Node_Str");
      TransactionService third=createTxService(zkServer.getConnectionStr(),Networks.getRandomPort(),hConf,tmpFolder.newFolder());
      third.start();
      second.stopAndWait();
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,"String_Node_Str","String_Node_Str");
      third.stop();
    }
  finally {
      dropTable("String_Node_Str",cConf);
      zkClient.stopAndWait();
    }
  }
  finally {
    zkServer.stop();
  }
}

Fixed version (ground truth):
@Test(timeout=60000) public void testHA() throws Exception {
  HBaseTestingUtility hBaseTestingUtility=new HBaseTestingUtility();
  hBaseTestingUtility.startMiniDFSCluster(1);
  Configuration hConf=hBaseTestingUtility.getConfiguration();
  hConf.setBoolean("String_Node_Str",true);
  InMemoryZKServer zkServer=InMemoryZKServer.builder().build();
  zkServer.startAndWait();
  try {
    CConfiguration cConf=CConfiguration.create();
    cConf.unset(Constants.CFG_HDFS_USER);
    cConf.set(Constants.Zookeeper.QUORUM,zkServer.getConnectionStr());
    cConf.set(Constants.CFG_LOCAL_DATA_DIR,tmpFolder.newFolder().getAbsolutePath());
    Injector injector=Guice.createInjector(new ConfigModule(cConf),new ZKClientModule(),new LocationRuntimeModule().getInMemoryModules(),new DiscoveryRuntimeModule().getDistributedModules(),new AbstractModule(){
      @Override protected void configure(){
        bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
      }
    }
,new DataFabricModules().getDistributedModules());
    ZKClientService zkClient=injector.getInstance(ZKClientService.class);
    zkClient.startAndWait();
    final OrderedColumnarTable table=createTable("String_Node_Str",cConf);
    try {
      TransactionSystemClient txClient=injector.getInstance(TransactionSystemClient.class);
      TransactionExecutor txExecutor=new DefaultTransactionExecutor(txClient,ImmutableList.of((TransactionAware)table));
      TransactionService first=createTxService(zkServer.getConnectionStr(),Networks.getRandomPort(),hConf,tmpFolder.newFolder());
      first.startAndWait();
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,null,"String_Node_Str");
      TransactionService second=createTxService(zkServer.getConnectionStr(),Networks.getRandomPort(),hConf,tmpFolder.newFolder());
      second.startAndWait();
      TimeUnit.SECONDS.sleep(1);
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,"String_Node_Str","String_Node_Str");
      first.stopAndWait();
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,"String_Node_Str","String_Node_Str");
      TransactionService third=createTxService(zkServer.getConnectionStr(),Networks.getRandomPort(),hConf,tmpFolder.newFolder());
      third.start();
      second.stopAndWait();
      Assert.assertNotNull(txClient.startShort());
      verifyGetAndPut(table,txExecutor,"String_Node_Str","String_Node_Str");
      third.stop();
    }
  finally {
      dropTable("String_Node_Str",cConf);
      zkClient.stopAndWait();
    }
  }
  finally {
    zkServer.stop();
  }
}