Program: 4795
Project: 4795
Buggy source:
@Category(XSlowTests.class) @Test public void testWorkflowScopedArguments() throws Exception {
  String workflowRunIdProperty="String_Node_Str";
  HttpResponse response=deploy(WorkflowAppWithScopedParameters.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  ProgramId programId=Ids.namespace(TEST_NAMESPACE2).app(WorkflowAppWithScopedParameters.APP_NAME).workflow(WorkflowAppWithScopedParameters.ONE_WORKFLOW);
  Map<String,String> runtimeArguments=Maps.newHashMap();
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  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());
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  setAndTestRuntimeArgs(programId.toId(),runtimeArguments);
  startProgram(programId.toId());
  waitState(programId.toId(),ProgramStatus.RUNNING.name());
  verifyProgramRuns(programId.toId(),"String_Node_Str");
  List<RunRecord> workflowHistoryRuns=getProgramRuns(programId.toId(),"String_Node_Str");
  String workflowRunId=workflowHistoryRuns.get(0).getPid();
  Id.Program mr1ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.MAPREDUCE,WorkflowAppWithScopedParameters.ONE_MR);
  waitState(mr1ProgramId,ProgramStatus.RUNNING.name());
  List<RunRecord> oneMRHistoryRuns=getProgramRuns(mr1ProgramId,"String_Node_Str");
  String expectedMessage=String.format("String_Node_Str" + "String_Node_Str",new Id.Run(mr1ProgramId,oneMRHistoryRuns.get(0).getPid()),workflowRunId);
  stopProgram(mr1ProgramId,oneMRHistoryRuns.get(0).getPid(),400,expectedMessage);
  verifyProgramRuns(programId.toId(),"String_Node_Str");
  workflowHistoryRuns=getProgramRuns(programId.toId(),"String_Node_Str");
  oneMRHistoryRuns=getProgramRuns(mr1ProgramId,"String_Node_Str");
  Id.Program mr2ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.MAPREDUCE,WorkflowAppWithScopedParameters.ANOTHER_MR);
  List<RunRecord> anotherMRHistoryRuns=getProgramRuns(mr2ProgramId,"String_Node_Str");
  Id.Program spark1ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.SPARK,WorkflowAppWithScopedParameters.ONE_SPARK);
  List<RunRecord> oneSparkHistoryRuns=getProgramRuns(spark1ProgramId,"String_Node_Str");
  Id.Program spark2ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.SPARK,WorkflowAppWithScopedParameters.ANOTHER_SPARK);
  List<RunRecord> anotherSparkHistoryRuns=getProgramRuns(spark2ProgramId,"String_Node_Str");
  Assert.assertEquals(1,workflowHistoryRuns.size());
  Assert.assertEquals(1,oneMRHistoryRuns.size());
  Assert.assertEquals(1,anotherMRHistoryRuns.size());
  Assert.assertEquals(1,oneSparkHistoryRuns.size());
  Assert.assertEquals(1,anotherSparkHistoryRuns.size());
  Map<String,String> workflowRunRecordProperties=workflowHistoryRuns.get(0).getProperties();
  Map<String,String> oneMRRunRecordProperties=oneMRHistoryRuns.get(0).getProperties();
  Map<String,String> anotherMRRunRecordProperties=anotherMRHistoryRuns.get(0).getProperties();
  Map<String,String> oneSparkRunRecordProperties=oneSparkHistoryRuns.get(0).getProperties();
  Map<String,String> anotherSparkRunRecordProperties=anotherSparkHistoryRuns.get(0).getProperties();
  Assert.assertNotNull(oneMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),oneMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertNotNull(anotherMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),anotherMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertNotNull(oneSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),oneSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertNotNull(anotherSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),anotherSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ONE_MR),oneMRHistoryRuns.get(0).getPid());
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ONE_SPARK),oneSparkHistoryRuns.get(0).getPid());
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ANOTHER_MR),anotherMRHistoryRuns.get(0).getPid());
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ANOTHER_SPARK),anotherSparkHistoryRuns.get(0).getPid());
  Map<String,WorkflowNodeStateDetail> nodeStates=getWorkflowNodeStates(programId,workflowHistoryRuns.get(0).getPid());
  Assert.assertNotNull(nodeStates);
  Assert.assertEquals(5,nodeStates.size());
  WorkflowNodeStateDetail mrNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ONE_MR);
  Assert.assertNotNull(mrNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ONE_MR,mrNodeState.getNodeId());
  Assert.assertEquals(oneMRHistoryRuns.get(0).getPid(),mrNodeState.getRunId());
  mrNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ANOTHER_MR);
  Assert.assertNotNull(mrNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ANOTHER_MR,mrNodeState.getNodeId());
  Assert.assertEquals(anotherMRHistoryRuns.get(0).getPid(),mrNodeState.getRunId());
  WorkflowNodeStateDetail sparkNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ONE_SPARK);
  Assert.assertNotNull(sparkNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ONE_SPARK,sparkNodeState.getNodeId());
  Assert.assertEquals(oneSparkHistoryRuns.get(0).getPid(),sparkNodeState.getRunId());
  sparkNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ANOTHER_SPARK);
  Assert.assertNotNull(sparkNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ANOTHER_SPARK,sparkNodeState.getNodeId());
  Assert.assertEquals(anotherSparkHistoryRuns.get(0).getPid(),sparkNodeState.getRunId());
  WorkflowNodeStateDetail oneActionNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ONE_ACTION);
  Assert.assertNotNull(oneActionNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ONE_ACTION,oneActionNodeState.getNodeId());
}

Fixed version (ground truth):
@Category(XSlowTests.class) @Test public void testWorkflowScopedArguments() throws Exception {
  String workflowRunIdProperty="String_Node_Str";
  HttpResponse response=deploy(WorkflowAppWithScopedParameters.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  ProgramId programId=Ids.namespace(TEST_NAMESPACE2).app(WorkflowAppWithScopedParameters.APP_NAME).workflow(WorkflowAppWithScopedParameters.ONE_WORKFLOW);
  Map<String,String> runtimeArguments=Maps.newHashMap();
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  runtimeArguments.put("String_Node_Str",createInput("String_Node_Str"));
  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());
  runtimeArguments.put("String_Node_Str",new File(tmpFolder.newFolder(),"String_Node_Str").getAbsolutePath());
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  runtimeArguments.put("String_Node_Str","String_Node_Str");
  setAndTestRuntimeArgs(programId.toId(),runtimeArguments);
  startProgram(programId,200);
  verifyProgramRuns(programId,ProgramRunStatus.RUNNING);
  List<RunRecord> workflowHistoryRuns=getProgramRuns(programId,ProgramRunStatus.ALL);
  String workflowRunId=workflowHistoryRuns.get(0).getPid();
  ProgramId mr1ProgramId=Ids.namespace(TEST_NAMESPACE2).app(WorkflowAppWithScopedParameters.APP_NAME).mr(WorkflowAppWithScopedParameters.ONE_MR);
  verifyProgramRuns(mr1ProgramId,ProgramRunStatus.RUNNING);
  List<RunRecord> oneMRHistoryRuns=getProgramRuns(mr1ProgramId,ProgramRunStatus.ALL);
  String expectedMessage=String.format("String_Node_Str" + "String_Node_Str",mr1ProgramId.run(oneMRHistoryRuns.get(0).getPid()),workflowRunId);
  stopProgram(mr1ProgramId.toId(),oneMRHistoryRuns.get(0).getPid(),400,expectedMessage);
  verifyProgramRuns(programId.toId(),ProgramRunStatus.COMPLETED);
  workflowHistoryRuns=getProgramRuns(programId.toId(),ProgramRunStatus.COMPLETED);
  oneMRHistoryRuns=getProgramRuns(mr1ProgramId,ProgramRunStatus.COMPLETED);
  Id.Program mr2ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.MAPREDUCE,WorkflowAppWithScopedParameters.ANOTHER_MR);
  List<RunRecord> anotherMRHistoryRuns=getProgramRuns(mr2ProgramId,ProgramRunStatus.COMPLETED);
  Id.Program spark1ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.SPARK,WorkflowAppWithScopedParameters.ONE_SPARK);
  List<RunRecord> oneSparkHistoryRuns=getProgramRuns(spark1ProgramId,ProgramRunStatus.COMPLETED);
  Id.Program spark2ProgramId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithScopedParameters.APP_NAME,ProgramType.SPARK,WorkflowAppWithScopedParameters.ANOTHER_SPARK);
  List<RunRecord> anotherSparkHistoryRuns=getProgramRuns(spark2ProgramId,ProgramRunStatus.COMPLETED);
  Assert.assertEquals(1,workflowHistoryRuns.size());
  Assert.assertEquals(1,oneMRHistoryRuns.size());
  Assert.assertEquals(1,anotherMRHistoryRuns.size());
  Assert.assertEquals(1,oneSparkHistoryRuns.size());
  Assert.assertEquals(1,anotherSparkHistoryRuns.size());
  Map<String,String> workflowRunRecordProperties=workflowHistoryRuns.get(0).getProperties();
  Map<String,String> oneMRRunRecordProperties=oneMRHistoryRuns.get(0).getProperties();
  Map<String,String> anotherMRRunRecordProperties=anotherMRHistoryRuns.get(0).getProperties();
  Map<String,String> oneSparkRunRecordProperties=oneSparkHistoryRuns.get(0).getProperties();
  Map<String,String> anotherSparkRunRecordProperties=anotherSparkHistoryRuns.get(0).getProperties();
  Assert.assertNotNull(oneMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),oneMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertNotNull(anotherMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),anotherMRRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertNotNull(oneSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),oneSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertNotNull(anotherSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowHistoryRuns.get(0).getPid(),anotherSparkRunRecordProperties.get(workflowRunIdProperty));
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ONE_MR),oneMRHistoryRuns.get(0).getPid());
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ONE_SPARK),oneSparkHistoryRuns.get(0).getPid());
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ANOTHER_MR),anotherMRHistoryRuns.get(0).getPid());
  Assert.assertEquals(workflowRunRecordProperties.get(WorkflowAppWithScopedParameters.ANOTHER_SPARK),anotherSparkHistoryRuns.get(0).getPid());
  Map<String,WorkflowNodeStateDetail> nodeStates=getWorkflowNodeStates(programId,workflowHistoryRuns.get(0).getPid());
  Assert.assertNotNull(nodeStates);
  Assert.assertEquals(5,nodeStates.size());
  WorkflowNodeStateDetail mrNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ONE_MR);
  Assert.assertNotNull(mrNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ONE_MR,mrNodeState.getNodeId());
  Assert.assertEquals(oneMRHistoryRuns.get(0).getPid(),mrNodeState.getRunId());
  mrNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ANOTHER_MR);
  Assert.assertNotNull(mrNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ANOTHER_MR,mrNodeState.getNodeId());
  Assert.assertEquals(anotherMRHistoryRuns.get(0).getPid(),mrNodeState.getRunId());
  WorkflowNodeStateDetail sparkNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ONE_SPARK);
  Assert.assertNotNull(sparkNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ONE_SPARK,sparkNodeState.getNodeId());
  Assert.assertEquals(oneSparkHistoryRuns.get(0).getPid(),sparkNodeState.getRunId());
  sparkNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ANOTHER_SPARK);
  Assert.assertNotNull(sparkNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ANOTHER_SPARK,sparkNodeState.getNodeId());
  Assert.assertEquals(anotherSparkHistoryRuns.get(0).getPid(),sparkNodeState.getRunId());
  WorkflowNodeStateDetail oneActionNodeState=nodeStates.get(WorkflowAppWithScopedParameters.ONE_ACTION);
  Assert.assertNotNull(oneActionNodeState);
  Assert.assertEquals(WorkflowAppWithScopedParameters.ONE_ACTION,oneActionNodeState.getNodeId());
}