Program: 6644
Project: 6644
Buggy source:
@Test public void testWorkflowRuns() throws Exception {
  String appName="String_Node_Str";
  String workflowName="String_Node_Str";
  HttpResponse response=deploy(WorkflowAppWithErrorRuns.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,appName,ProgramType.WORKFLOW,workflowName);
  File instance1File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File instance2File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File doneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  Map<String,String> propertyMap=ImmutableMap.of("String_Node_Str",instance1File.getAbsolutePath(),"String_Node_Str",doneFile.getAbsolutePath());
  startProgram(programId,propertyMap);
  propertyMap=ImmutableMap.of("String_Node_Str",instance2File.getAbsolutePath(),"String_Node_Str",doneFile.getAbsolutePath());
  startProgram(programId,propertyMap);
  while (!(instance1File.exists() && instance2File.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  List<RunRecord> historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() == 2);
  String runId=historyRuns.get(0).getPid();
  stopProgram(programId,200,runId);
  runId=historyRuns.get(1).getPid();
  stopProgram(programId,200,runId);
  verifyProgramRuns(programId,"String_Node_Str",1);
  File instanceFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  propertyMap=ImmutableMap.of("String_Node_Str",instanceFile.getAbsolutePath(),"String_Node_Str",doneFile.getAbsolutePath());
  startProgram(programId,propertyMap);
  while (!instanceFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() == 1);
  Assert.assertTrue(doneFile.createNewFile());
  verifyProgramRuns(programId,"String_Node_Str");
  propertyMap=ImmutableMap.of("String_Node_Str","String_Node_Str");
  startProgram(programId,propertyMap);
  verifyProgramRuns(programId,"String_Node_Str");
}

Fixed version (ground truth):
@Test public void testWorkflowRuns() throws Exception {
  String appName="String_Node_Str";
  String workflowName="String_Node_Str";
  HttpResponse response=deploy(WorkflowAppWithErrorRuns.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,appName,ProgramType.WORKFLOW,workflowName);
  File instance1File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File instance2File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File doneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  Map<String,String> propertyMap=ImmutableMap.of("String_Node_Str",instance1File.getAbsolutePath(),"String_Node_Str",doneFile.getAbsolutePath());
  startProgram(programId,propertyMap);
  propertyMap=ImmutableMap.of("String_Node_Str",instance2File.getAbsolutePath(),"String_Node_Str",doneFile.getAbsolutePath());
  startProgram(programId,propertyMap);
  while (!(instance1File.exists() && instance2File.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  List<RunRecord> historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() == 2);
  String runId=historyRuns.get(0).getPid();
  stopProgram(programId,runId,200);
  runId=historyRuns.get(1).getPid();
  stopProgram(programId,runId,200);
  verifyProgramRuns(programId,"String_Node_Str",1);
  File instanceFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  propertyMap=ImmutableMap.of("String_Node_Str",instanceFile.getAbsolutePath(),"String_Node_Str",doneFile.getAbsolutePath());
  startProgram(programId,propertyMap);
  while (!instanceFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() == 1);
  Assert.assertTrue(doneFile.createNewFile());
  verifyProgramRuns(programId,"String_Node_Str");
  propertyMap=ImmutableMap.of("String_Node_Str","String_Node_Str");
  startProgram(programId,propertyMap);
  verifyProgramRuns(programId,"String_Node_Str");
}