Program: 4793
Project: 4793
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.assertEquals(2,historyRuns.size());
  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.assertEquals(1,historyRuns.size());
  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);
  }
  verifyProgramRuns(programId,ProgramRunStatus.RUNNING,1);
  List<RunRecord> historyRuns=getProgramRuns(programId,ProgramRunStatus.ALL);
  String runId=historyRuns.get(0).getPid();
  stopProgram(programId,runId,200);
  runId=historyRuns.get(1).getPid();
  stopProgram(programId,runId,200);
  verifyProgramRuns(programId,ProgramRunStatus.KILLED,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);
  verifyProgramRuns(programId,ProgramRunStatus.RUNNING);
  while (!instanceFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  historyRuns=getProgramRuns(programId,ProgramRunStatus.RUNNING);
  Assert.assertEquals(1,historyRuns.size());
  Assert.assertTrue(doneFile.createNewFile());
  verifyProgramRuns(programId,ProgramRunStatus.COMPLETED);
  propertyMap=ImmutableMap.of("String_Node_Str","String_Node_Str");
  startProgram(programId,propertyMap);
  verifyProgramRuns(programId,ProgramRunStatus.FAILED);
}