Program: 6843
Project: 6843
Buggy source:
@Category(XSlowTests.class) @Test public void testMultipleWorkflowInstances() throws Exception {
  String appWithConcurrentWorkflow="String_Node_Str";
  String appWithConcurrentWorkflowSchedule1="String_Node_Str";
  String appWithConcurrentWorkflowSchedule2="String_Node_Str";
  String concurrentWorkflowName="String_Node_Str";
  File schedule1File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File schedule2File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File simpleActionDoneFile=new File(tmpFolder.newFolder() + "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,concurrentWorkflowName);
  Map<String,String> propMap=ImmutableMap.of("String_Node_Str",schedule1File.getAbsolutePath(),"String_Node_Str",schedule2File.getAbsolutePath(),"String_Node_Str",simpleActionDoneFile.getAbsolutePath());
  PreferencesStore store=getInjector().getInstance(PreferencesStore.class);
  store.setProperties(defaultNamespace,appWithConcurrentWorkflow,ProgramType.WORKFLOW.getCategoryName(),concurrentWorkflowName,propMap);
  Assert.assertEquals(200,resumeSchedule(defaultNamespace,appWithConcurrentWorkflow,appWithConcurrentWorkflowSchedule1));
  Assert.assertEquals(200,resumeSchedule(defaultNamespace,appWithConcurrentWorkflow,appWithConcurrentWorkflowSchedule2));
  while (!(schedule1File.exists() && schedule2File.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  List<RunRecord> historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() >= 2);
  List<ScheduleSpecification> schedules=getSchedules(defaultNamespace,appWithConcurrentWorkflow,concurrentWorkflowName);
  for (  ScheduleSpecification spec : schedules) {
    Assert.assertEquals(200,suspendSchedule(defaultNamespace,appWithConcurrentWorkflow,spec.getSchedule().getName()));
  }
  response=getWorkflowCurrentStatus(programId,historyRuns.get(0).getPid());
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  String json=EntityUtils.toString(response.getEntity());
  List<WorkflowActionNode> nodes=GSON.fromJson(json,LIST_WORKFLOWACTIONNODE_TYPE);
  Assert.assertEquals(1,nodes.size());
  Assert.assertEquals("String_Node_Str",nodes.get(0).getProgram().getProgramName());
  response=getWorkflowCurrentStatus(programId,historyRuns.get(1).getPid());
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  json=EntityUtils.toString(response.getEntity());
  nodes=GSON.fromJson(json,LIST_WORKFLOWACTIONNODE_TYPE);
  Assert.assertEquals(1,nodes.size());
  Assert.assertEquals("String_Node_Str",nodes.get(0).getProgram().getProgramName());
  Assert.assertTrue(simpleActionDoneFile.createNewFile());
  deleteApp(programId.getApplication(),200,60,TimeUnit.SECONDS);
}

Fixed version (ground truth):
@Category(XSlowTests.class) @Test public void testMultipleWorkflowInstances() throws Exception {
  String appWithConcurrentWorkflow="String_Node_Str";
  String appWithConcurrentWorkflowSchedule1="String_Node_Str";
  String appWithConcurrentWorkflowSchedule2="String_Node_Str";
  String concurrentWorkflowName="String_Node_Str";
  File schedule1File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File schedule2File=new File(tmpFolder.newFolder() + "String_Node_Str");
  File simpleActionDoneFile=new File(tmpFolder.newFolder() + "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,concurrentWorkflowName);
  Map<String,String> propMap=ImmutableMap.of("String_Node_Str",schedule1File.getAbsolutePath(),"String_Node_Str",schedule2File.getAbsolutePath(),"String_Node_Str",simpleActionDoneFile.getAbsolutePath());
  PreferencesStore store=getInjector().getInstance(PreferencesStore.class);
  store.setProperties(defaultNamespace,appWithConcurrentWorkflow,ProgramType.WORKFLOW.getCategoryName(),concurrentWorkflowName,propMap);
  Assert.assertEquals(200,resumeSchedule(defaultNamespace,appWithConcurrentWorkflow,appWithConcurrentWorkflowSchedule1));
  Assert.assertEquals(200,resumeSchedule(defaultNamespace,appWithConcurrentWorkflow,appWithConcurrentWorkflowSchedule2));
  while (!(schedule1File.exists() && schedule2File.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  List<RunRecord> historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() >= 2);
  List<ScheduleSpecification> schedules=getSchedules(defaultNamespace,appWithConcurrentWorkflow,concurrentWorkflowName);
  for (  ScheduleSpecification spec : schedules) {
    Assert.assertEquals(200,suspendSchedule(defaultNamespace,appWithConcurrentWorkflow,spec.getSchedule().getName()));
  }
  response=getWorkflowCurrentStatus(programId,historyRuns.get(0).getPid());
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  String json=EntityUtils.toString(response.getEntity());
  List<WorkflowActionNode> nodes=GSON.fromJson(json,LIST_WORKFLOWACTIONNODE_TYPE);
  Assert.assertEquals(1,nodes.size());
  Assert.assertEquals("String_Node_Str",nodes.get(0).getProgram().getProgramName());
  response=getWorkflowCurrentStatusOld(programId,historyRuns.get(0).getPid());
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  json=EntityUtils.toString(response.getEntity());
  nodes=GSON.fromJson(json,LIST_WORKFLOWACTIONNODE_TYPE);
  Assert.assertEquals(1,nodes.size());
  Assert.assertEquals("String_Node_Str",nodes.get(0).getProgram().getProgramName());
  response=getWorkflowCurrentStatus(programId,historyRuns.get(1).getPid());
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  json=EntityUtils.toString(response.getEntity());
  nodes=GSON.fromJson(json,LIST_WORKFLOWACTIONNODE_TYPE);
  Assert.assertEquals(1,nodes.size());
  Assert.assertEquals("String_Node_Str",nodes.get(0).getProgram().getProgramName());
  response=getWorkflowCurrentStatusOld(programId,historyRuns.get(1).getPid());
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  json=EntityUtils.toString(response.getEntity());
  nodes=GSON.fromJson(json,LIST_WORKFLOWACTIONNODE_TYPE);
  Assert.assertEquals(1,nodes.size());
  Assert.assertEquals("String_Node_Str",nodes.get(0).getProgram().getProgramName());
  Assert.assertTrue(simpleActionDoneFile.createNewFile());
  deleteApp(programId.getApplication(),200,60,TimeUnit.SECONDS);
}