Program: 4789
Project: 4789
Buggy source:
@Category(XSlowTests.class) @Test public void testMultipleWorkflowInstances() throws Exception {
  String appWithConcurrentWorkflow=ConcurrentWorkflowApp.class.getSimpleName();
  File tempDir=tmpFolder.newFolder(appWithConcurrentWorkflow);
  File run1File=new File(tempDir,"String_Node_Str");
  File run2File=new File(tempDir,"String_Node_Str");
  File run1DoneFile=new File(tempDir,"String_Node_Str");
  File run2DoneFile=new File(tempDir,"String_Node_Str");
  String defaultNamespace=Id.Namespace.DEFAULT.getId();
  HttpResponse response=deploy(ConcurrentWorkflowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,defaultNamespace);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(Id.Namespace.DEFAULT,appWithConcurrentWorkflow,ProgramType.WORKFLOW,ConcurrentWorkflowApp.ConcurrentWorkflow.class.getSimpleName());
  startProgram(programId,ImmutableMap.of(ConcurrentWorkflowApp.FILE_TO_CREATE_ARG,run1File.getAbsolutePath(),ConcurrentWorkflowApp.DONE_FILE_ARG,run1DoneFile.getAbsolutePath()),200);
  startProgram(programId,ImmutableMap.of(ConcurrentWorkflowApp.FILE_TO_CREATE_ARG,run2File.getAbsolutePath(),ConcurrentWorkflowApp.DONE_FILE_ARG,run2DoneFile.getAbsolutePath()),200);
  while (!(run1File.exists() && run2File.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  verifyMultipleConcurrentRuns(programId);
  Assert.assertTrue(run1DoneFile.createNewFile());
  Assert.assertTrue(run2DoneFile.createNewFile());
  verifyProgramRuns(programId,"String_Node_Str",1);
  deleteApp(programId.getApplication(),200,60,TimeUnit.SECONDS);
}

Fixed version (ground truth):
@Category(XSlowTests.class) @Test public void testMultipleWorkflowInstances() throws Exception {
  String appWithConcurrentWorkflow=ConcurrentWorkflowApp.class.getSimpleName();
  File tempDir=tmpFolder.newFolder(appWithConcurrentWorkflow);
  File run1File=new File(tempDir,"String_Node_Str");
  File run2File=new File(tempDir,"String_Node_Str");
  File run1DoneFile=new File(tempDir,"String_Node_Str");
  File run2DoneFile=new File(tempDir,"String_Node_Str");
  String defaultNamespace=Id.Namespace.DEFAULT.getId();
  HttpResponse response=deploy(ConcurrentWorkflowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,defaultNamespace);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(Id.Namespace.DEFAULT,appWithConcurrentWorkflow,ProgramType.WORKFLOW,ConcurrentWorkflowApp.ConcurrentWorkflow.class.getSimpleName());
  startProgram(programId,ImmutableMap.of(ConcurrentWorkflowApp.FILE_TO_CREATE_ARG,run1File.getAbsolutePath(),ConcurrentWorkflowApp.DONE_FILE_ARG,run1DoneFile.getAbsolutePath()),200);
  startProgram(programId,ImmutableMap.of(ConcurrentWorkflowApp.FILE_TO_CREATE_ARG,run2File.getAbsolutePath(),ConcurrentWorkflowApp.DONE_FILE_ARG,run2DoneFile.getAbsolutePath()),200);
  while (!(run1File.exists() && run2File.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  verifyMultipleConcurrentRuns(programId);
  Assert.assertTrue(run1DoneFile.createNewFile());
  Assert.assertTrue(run2DoneFile.createNewFile());
  verifyProgramRuns(programId,ProgramRunStatus.COMPLETED,1);
  deleteApp(programId.getApplication(),200,60,TimeUnit.SECONDS);
}