Program: 6199
Project: 6199
Buggy source:
private String executeWorkflow(ApplicationManager applicationManager,Map<String,String> additionalParams) throws Exception {
  WorkflowManager wfManager=applicationManager.getWorkflowManager(WorkflowAppWithLocalDatasets.WORKFLOW_NAME);
  Map<String,String> runtimeArgs=new HashMap<>();
  File waitFile=new File(TMP_FOLDER.newFolder(),"String_Node_Str");
  File doneFile=new File(TMP_FOLDER.newFolder(),"String_Node_Str");
  runtimeArgs.put("String_Node_Str","String_Node_Str");
  runtimeArgs.put("String_Node_Str","String_Node_Str");
  runtimeArgs.put("String_Node_Str",waitFile.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",doneFile.getAbsolutePath());
  runtimeArgs.putAll(additionalParams);
  wfManager.start(runtimeArgs);
  while (!waitFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  List<RunRecord> history=wfManager.getHistory(ProgramRunStatus.RUNNING);
  Assert.assertEquals(1,history.size());
  String runId=history.get(0).getPid();
  DataSetManager<KeyValueTable> localDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.WORDCOUNT_DATASET + "String_Node_Str" + runId);
  Assert.assertEquals("String_Node_Str",Bytes.toString(localDataset.get().read("String_Node_Str")));
  DataSetManager<FileSet> fileSetDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.CSV_FILESET_DATASET + "String_Node_Str" + runId);
  Assert.assertNotNull(fileSetDataset.get());
  localDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.WORDCOUNT_DATASET);
  Assert.assertNull(localDataset.get());
  fileSetDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.CSV_FILESET_DATASET);
  Assert.assertNull(fileSetDataset.get());
  doneFile.createNewFile();
  wfManager.waitForFinish(1,TimeUnit.MINUTES);
  Map<String,String> workflowMetricsContext=new HashMap<>();
  workflowMetricsContext.put(Constants.Metrics.Tag.NAMESPACE,testSpace.getId());
  workflowMetricsContext.put(Constants.Metrics.Tag.APP,applicationManager.getInfo().getName());
  workflowMetricsContext.put(Constants.Metrics.Tag.WORKFLOW,WorkflowAppWithLocalDatasets.WORKFLOW_NAME);
  workflowMetricsContext.put(Constants.Metrics.Tag.RUN_ID,runId);
  Map<String,String> writerContext=new HashMap<>(workflowMetricsContext);
  writerContext.put(Constants.Metrics.Tag.NODE,WorkflowAppWithLocalDatasets.LocalDatasetWriter.class.getSimpleName());
  Assert.assertEquals(2,getMetricsManager().getTotalMetric(writerContext,"String_Node_Str"));
  Map<String,String> sparkMetricsContext=new HashMap<>(workflowMetricsContext);
  sparkMetricsContext.put(Constants.Metrics.Tag.NODE,"String_Node_Str");
  Assert.assertEquals(2,getMetricsManager().getTotalMetric(sparkMetricsContext,"String_Node_Str"));
  Map<String,String> mrMetricsContext=new HashMap<>(workflowMetricsContext);
  mrMetricsContext.put(Constants.Metrics.Tag.NODE,"String_Node_Str");
  Assert.assertEquals(7,getMetricsManager().getTotalMetric(mrMetricsContext,"String_Node_Str"));
  Map<String,String> readerContext=new HashMap<>(workflowMetricsContext);
  readerContext.put(Constants.Metrics.Tag.NODE,"String_Node_Str");
  Assert.assertEquals(6,getMetricsManager().getTotalMetric(readerContext,"String_Node_Str"));
  return runId;
}

Fixed version (ground truth):
private String executeWorkflow(ApplicationManager applicationManager,Map<String,String> additionalParams) throws Exception {
  WorkflowManager wfManager=applicationManager.getWorkflowManager(WorkflowAppWithLocalDatasets.WORKFLOW_NAME);
  Map<String,String> runtimeArgs=new HashMap<>();
  File waitFile=new File(TMP_FOLDER.newFolder(),"String_Node_Str");
  File doneFile=new File(TMP_FOLDER.newFolder(),"String_Node_Str");
  runtimeArgs.put("String_Node_Str","String_Node_Str");
  runtimeArgs.put("String_Node_Str","String_Node_Str");
  runtimeArgs.put("String_Node_Str",waitFile.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",doneFile.getAbsolutePath());
  runtimeArgs.putAll(additionalParams);
  wfManager.start(runtimeArgs);
  while (!waitFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  List<RunRecord> history=wfManager.getHistory(ProgramRunStatus.RUNNING);
  Assert.assertEquals(1,history.size());
  String runId=history.get(0).getPid();
  DataSetManager<KeyValueTable> localDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.WORDCOUNT_DATASET + "String_Node_Str" + runId);
  Assert.assertEquals("String_Node_Str",Bytes.toString(localDataset.get().read("String_Node_Str")));
  DataSetManager<FileSet> fileSetDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.CSV_FILESET_DATASET + "String_Node_Str" + runId);
  Assert.assertNotNull(fileSetDataset.get());
  localDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.WORDCOUNT_DATASET);
  Assert.assertNull(localDataset.get());
  fileSetDataset=getDataset(testSpace,WorkflowAppWithLocalDatasets.CSV_FILESET_DATASET);
  Assert.assertNull(fileSetDataset.get());
  doneFile.createNewFile();
  wfManager.waitForFinish(1,TimeUnit.MINUTES);
  Map<String,WorkflowNodeStateDetail> nodeStateDetailMap=wfManager.getWorkflowNodeStates(runId);
  Map<String,String> workflowMetricsContext=new HashMap<>();
  workflowMetricsContext.put(Constants.Metrics.Tag.NAMESPACE,testSpace.getId());
  workflowMetricsContext.put(Constants.Metrics.Tag.APP,applicationManager.getInfo().getName());
  workflowMetricsContext.put(Constants.Metrics.Tag.WORKFLOW,WorkflowAppWithLocalDatasets.WORKFLOW_NAME);
  workflowMetricsContext.put(Constants.Metrics.Tag.RUN_ID,runId);
  Map<String,String> writerContext=new HashMap<>(workflowMetricsContext);
  writerContext.put(Constants.Metrics.Tag.NODE,WorkflowAppWithLocalDatasets.LocalDatasetWriter.class.getSimpleName());
  Assert.assertEquals(2,getMetricsManager().getTotalMetric(writerContext,"String_Node_Str"));
  Map<String,String> wfSparkMetricsContext=new HashMap<>(workflowMetricsContext);
  wfSparkMetricsContext.put(Constants.Metrics.Tag.NODE,"String_Node_Str");
  Assert.assertEquals(2,getMetricsManager().getTotalMetric(wfSparkMetricsContext,"String_Node_Str"));
  Map<String,String> sparkMetricsContext=new HashMap<>();
  sparkMetricsContext.put(Constants.Metrics.Tag.NAMESPACE,testSpace.getId());
  sparkMetricsContext.put(Constants.Metrics.Tag.APP,applicationManager.getInfo().getName());
  sparkMetricsContext.put(Constants.Metrics.Tag.SPARK,"String_Node_Str");
  sparkMetricsContext.put(Constants.Metrics.Tag.RUN_ID,nodeStateDetailMap.get("String_Node_Str").getRunId());
  Assert.assertEquals(2,getMetricsManager().getTotalMetric(sparkMetricsContext,"String_Node_Str"));
  Map<String,String> appMetricsContext=new HashMap<>();
  appMetricsContext.put(Constants.Metrics.Tag.NAMESPACE,testSpace.getId());
  appMetricsContext.put(Constants.Metrics.Tag.APP,applicationManager.getInfo().getName());
  Assert.assertEquals(4,getMetricsManager().getTotalMetric(appMetricsContext,"String_Node_Str"));
  Map<String,String> wfMRMetricsContext=new HashMap<>(workflowMetricsContext);
  wfMRMetricsContext.put(Constants.Metrics.Tag.NODE,"String_Node_Str");
  Assert.assertEquals(7,getMetricsManager().getTotalMetric(wfMRMetricsContext,"String_Node_Str"));
  Map<String,String> mrMetricsContext=new HashMap<>();
  mrMetricsContext.put(Constants.Metrics.Tag.NAMESPACE,testSpace.getId());
  mrMetricsContext.put(Constants.Metrics.Tag.APP,applicationManager.getInfo().getName());
  mrMetricsContext.put(Constants.Metrics.Tag.MAPREDUCE,"String_Node_Str");
  mrMetricsContext.put(Constants.Metrics.Tag.RUN_ID,nodeStateDetailMap.get("String_Node_Str").getRunId());
  Assert.assertEquals(7,getMetricsManager().getTotalMetric(mrMetricsContext,"String_Node_Str"));
  Map<String,String> readerContext=new HashMap<>(workflowMetricsContext);
  readerContext.put(Constants.Metrics.Tag.NODE,"String_Node_Str");
  Assert.assertEquals(6,getMetricsManager().getTotalMetric(readerContext,"String_Node_Str"));
  return runId;
}