Program: 7769
Project: 7769
Buggy source:
@Test public void testTimeSeriesRecordsCount() throws Exception {
  final ApplicationWithPrograms app=TestHelper.deployApplicationWithManager(AppWithMapReduce.class);
  OperationExecutor opex=injector.getInstance(OperationExecutor.class);
  LocationFactory locationFactory=injector.getInstance(LocationFactory.class);
  DataSetAccessor dataSetAccessor=injector.getInstance(DataSetAccessor.class);
  TransactionSystemClient txSystemClient=injector.getInstance(TransactionSystemClient.class);
  OperationContext opCtx=new OperationContext(DefaultId.ACCOUNT.getId(),app.getAppSpecLoc().getSpecification().getName());
  TransactionProxy proxy=new TransactionProxy();
  DataSetInstantiator dataSetInstantiator=new DataSetInstantiator(new DataFabricImpl(opex,locationFactory,dataSetAccessor,opCtx),proxy,getClass().getClassLoader());
  dataSetInstantiator.setDataSets(ImmutableList.copyOf(new AppWithMapReduce().configure().getDataSets().values()));
  TransactionAgent txAgent=new SynchronousTransactionAgent(opex,opCtx,dataSetInstantiator.getTransactionAware(),txSystemClient);
  proxy.setTransactionAgent(txAgent);
  TimeseriesTable table=(TimeseriesTable)dataSetInstantiator.getDataSet("String_Node_Str");
  txAgent.start();
  fillTestInputData(table);
  txAgent.finish();
  Thread.sleep(2);
  long start=System.currentTimeMillis();
  runProgram(app,AppWithMapReduce.AggregateTimeseriesByTag.class);
  long stop=System.currentTimeMillis();
  Map<String,Long> expected=Maps.newHashMap();
  expected.put("String_Node_Str",18L);
  expected.put("String_Node_Str",3L);
  expected.put("String_Node_Str",18L);
  table=(TimeseriesTable)dataSetInstantiator.getDataSet("String_Node_Str");
  txAgent.start();
  List<TimeseriesTable.Entry> agg=table.read(AggregateMetricsByTag.BY_TAGS,start,stop);
  Assert.assertEquals(expected.size(),agg.size());
  for (  TimeseriesTable.Entry entry : agg) {
    String tag=Bytes.toString(entry.getTags()[0]);
    Assert.assertEquals((long)expected.get(tag),Bytes.toLong(entry.getValue()));
  }
  txAgent.finish();
}

Fixed version (ground truth):
@Test public void testTimeSeriesRecordsCount() throws Exception {
  final ApplicationWithPrograms app=TestHelper.deployApplicationWithManager(AppWithMapReduce.class);
  injector.getInstance(InMemoryTransactionManager.class).init();
  OperationExecutor opex=injector.getInstance(OperationExecutor.class);
  LocationFactory locationFactory=injector.getInstance(LocationFactory.class);
  DataSetAccessor dataSetAccessor=injector.getInstance(DataSetAccessor.class);
  TransactionSystemClient txSystemClient=injector.getInstance(TransactionSystemClient.class);
  OperationContext opCtx=new OperationContext(DefaultId.ACCOUNT.getId(),app.getAppSpecLoc().getSpecification().getName());
  TransactionProxy proxy=new TransactionProxy();
  DataSetInstantiator dataSetInstantiator=new DataSetInstantiator(new DataFabricImpl(opex,locationFactory,dataSetAccessor,opCtx),proxy,getClass().getClassLoader());
  dataSetInstantiator.setDataSets(ImmutableList.copyOf(new AppWithMapReduce().configure().getDataSets().values()));
  TransactionAgent txAgent=new SynchronousTransactionAgent(opex,opCtx,dataSetInstantiator.getTransactionAware(),txSystemClient);
  proxy.setTransactionAgent(txAgent);
  TimeseriesTable table=(TimeseriesTable)dataSetInstantiator.getDataSet("String_Node_Str");
  txAgent.start();
  fillTestInputData(table);
  txAgent.finish();
  Thread.sleep(2);
  long start=System.currentTimeMillis();
  runProgram(app,AppWithMapReduce.AggregateTimeseriesByTag.class);
  long stop=System.currentTimeMillis();
  Map<String,Long> expected=Maps.newHashMap();
  expected.put("String_Node_Str",18L);
  expected.put("String_Node_Str",3L);
  expected.put("String_Node_Str",18L);
  table=(TimeseriesTable)dataSetInstantiator.getDataSet("String_Node_Str");
  txAgent.start();
  List<TimeseriesTable.Entry> agg=table.read(AggregateMetricsByTag.BY_TAGS,start,stop);
  Assert.assertEquals(expected.size(),agg.size());
  for (  TimeseriesTable.Entry entry : agg) {
    String tag=Bytes.toString(entry.getTags()[0]);
    Assert.assertEquals((long)expected.get(tag),Bytes.toLong(entry.getValue()));
  }
  txAgent.finish();
}