Program: 4790
Project: 4790
Buggy source:
@Category(XSlowTests.class) @Test public void testWorkflowCondition() throws Exception {
  String conditionalWorkflowApp="String_Node_Str";
  String conditionalWorkflow="String_Node_Str";
  HttpResponse response=deploy(ConditionalWorkflowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,conditionalWorkflowApp,ProgramType.WORKFLOW,conditionalWorkflow);
  Map<String,String> runtimeArguments=Maps.newHashMap();
  File ifForkOneActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File ifForkOneActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",ifForkOneActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",ifForkOneActionDoneFile.getAbsolutePath());
  File ifForkAnotherActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File ifForkAnotherActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",ifForkAnotherActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",ifForkAnotherActionDoneFile.getAbsolutePath());
  File elseForkOneActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File elseForkOneActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",elseForkOneActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",elseForkOneActionDoneFile.getAbsolutePath());
  File elseForkAnotherActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File elseForkAnotherActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",elseForkAnotherActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",elseForkAnotherActionDoneFile.getAbsolutePath());
  File elseForkThirdActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File elseForkThirdActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",elseForkThirdActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",elseForkThirdActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",createConditionInput("String_Node_Str",2,12));
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  setAndTestRuntimeArgs(programId,runtimeArguments);
  startProgram(programId);
  while (!(elseForkOneActionFile.exists() && elseForkAnotherActionFile.exists() && elseForkThirdActionFile.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  String runId=getRunIdOfRunningProgram(programId);
  verifyRunningProgramCount(programId,runId,3);
  Assert.assertTrue(elseForkOneActionDoneFile.createNewFile());
  Assert.assertTrue(elseForkAnotherActionDoneFile.createNewFile());
  Assert.assertTrue(elseForkThirdActionDoneFile.createNewFile());
  verifyProgramRuns(programId,"String_Node_Str");
  List<RunRecord> workflowHistoryRuns=getProgramRuns(programId,"String_Node_Str");
  Id.Program recordVerifierProgramId=Id.Program.from(TEST_NAMESPACE2,conditionalWorkflowApp,ProgramType.MAPREDUCE,"String_Node_Str");
  List<RunRecord> recordVerifierRuns=getProgramRuns(recordVerifierProgramId,"String_Node_Str");
  Id.Program wordCountProgramId=Id.Program.from(TEST_NAMESPACE2,conditionalWorkflowApp,ProgramType.MAPREDUCE,"String_Node_Str");
  List<RunRecord> wordCountRuns=getProgramRuns(wordCountProgramId,"String_Node_Str");
  Assert.assertEquals(1,workflowHistoryRuns.size());
  Assert.assertEquals(1,recordVerifierRuns.size());
  Assert.assertEquals(0,wordCountRuns.size());
  runtimeArguments.put("String_Node_Str",createConditionInput("String_Node_Str",10,2));
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  setAndTestRuntimeArgs(programId,runtimeArguments);
  startProgram(programId);
  while (!(ifForkOneActionFile.exists() && ifForkAnotherActionFile.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  runId=getRunIdOfRunningProgram(programId);
  verifyRunningProgramCount(programId,runId,2);
  Assert.assertTrue(ifForkOneActionDoneFile.createNewFile());
  Assert.assertTrue(ifForkAnotherActionDoneFile.createNewFile());
  verifyProgramRuns(programId,"String_Node_Str",1);
  workflowHistoryRuns=getProgramRuns(programId,"String_Node_Str");
  recordVerifierRuns=getProgramRuns(recordVerifierProgramId,"String_Node_Str");
  wordCountRuns=getProgramRuns(wordCountProgramId,"String_Node_Str");
  Assert.assertEquals(2,workflowHistoryRuns.size());
  Assert.assertEquals(2,recordVerifierRuns.size());
  Assert.assertEquals(1,wordCountRuns.size());
}

Fixed version (ground truth):
@Category(XSlowTests.class) @Test public void testWorkflowCondition() throws Exception {
  String conditionalWorkflowApp="String_Node_Str";
  String conditionalWorkflow="String_Node_Str";
  HttpResponse response=deploy(ConditionalWorkflowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,conditionalWorkflowApp,ProgramType.WORKFLOW,conditionalWorkflow);
  Map<String,String> runtimeArguments=Maps.newHashMap();
  File ifForkOneActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File ifForkOneActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",ifForkOneActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",ifForkOneActionDoneFile.getAbsolutePath());
  File ifForkAnotherActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File ifForkAnotherActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",ifForkAnotherActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",ifForkAnotherActionDoneFile.getAbsolutePath());
  File elseForkOneActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File elseForkOneActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",elseForkOneActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",elseForkOneActionDoneFile.getAbsolutePath());
  File elseForkAnotherActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File elseForkAnotherActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",elseForkAnotherActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",elseForkAnotherActionDoneFile.getAbsolutePath());
  File elseForkThirdActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File elseForkThirdActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  runtimeArguments.put("String_Node_Str",elseForkThirdActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",elseForkThirdActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",createConditionInput("String_Node_Str",2,12));
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  setAndTestRuntimeArgs(programId,runtimeArguments);
  startProgram(programId);
  while (!(elseForkOneActionFile.exists() && elseForkAnotherActionFile.exists() && elseForkThirdActionFile.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  String runId=getRunIdOfRunningProgram(programId);
  verifyRunningProgramCount(programId,runId,3);
  Assert.assertTrue(elseForkOneActionDoneFile.createNewFile());
  Assert.assertTrue(elseForkAnotherActionDoneFile.createNewFile());
  Assert.assertTrue(elseForkThirdActionDoneFile.createNewFile());
  verifyProgramRuns(programId,ProgramRunStatus.COMPLETED);
  List<RunRecord> workflowHistoryRuns=getProgramRuns(programId,ProgramRunStatus.COMPLETED);
  Id.Program recordVerifierProgramId=Id.Program.from(TEST_NAMESPACE2,conditionalWorkflowApp,ProgramType.MAPREDUCE,"String_Node_Str");
  List<RunRecord> recordVerifierRuns=getProgramRuns(recordVerifierProgramId,ProgramRunStatus.COMPLETED);
  Id.Program wordCountProgramId=Id.Program.from(TEST_NAMESPACE2,conditionalWorkflowApp,ProgramType.MAPREDUCE,"String_Node_Str");
  List<RunRecord> wordCountRuns=getProgramRuns(wordCountProgramId,ProgramRunStatus.COMPLETED);
  Assert.assertEquals(1,workflowHistoryRuns.size());
  Assert.assertEquals(1,recordVerifierRuns.size());
  Assert.assertEquals(0,wordCountRuns.size());
  runtimeArguments.put("String_Node_Str",createConditionInput("String_Node_Str",10,2));
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  setAndTestRuntimeArgs(programId,runtimeArguments);
  startProgram(programId);
  while (!(ifForkOneActionFile.exists() && ifForkAnotherActionFile.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  runId=getRunIdOfRunningProgram(programId);
  verifyRunningProgramCount(programId,runId,2);
  Assert.assertTrue(ifForkOneActionDoneFile.createNewFile());
  Assert.assertTrue(ifForkAnotherActionDoneFile.createNewFile());
  verifyProgramRuns(programId,ProgramRunStatus.COMPLETED,1);
  workflowHistoryRuns=getProgramRuns(programId,ProgramRunStatus.COMPLETED);
  recordVerifierRuns=getProgramRuns(recordVerifierProgramId,ProgramRunStatus.COMPLETED);
  wordCountRuns=getProgramRuns(wordCountProgramId,ProgramRunStatus.COMPLETED);
  Assert.assertEquals(2,workflowHistoryRuns.size());
  Assert.assertEquals(2,recordVerifierRuns.size());
  Assert.assertEquals(1,wordCountRuns.size());
}