Program: 6642
Project: 6642
Buggy source:
@Category(XSlowTests.class) @Test public void testProgramStartStopStatus() throws Exception {
  HttpResponse response=deploy(WordCountApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE1);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Flow wordcountFlow1=Id.Flow.from(TEST_NAMESPACE1,WORDCOUNT_APP_NAME,WORDCOUNT_FLOW_NAME);
  Id.Flow wordcountFlow2=Id.Flow.from(TEST_NAMESPACE2,WORDCOUNT_APP_NAME,WORDCOUNT_FLOW_NAME);
  Assert.assertEquals(STOPPED,getProgramStatus(wordcountFlow1));
  startProgram(wordcountFlow2,404);
  Assert.assertEquals(STOPPED,getProgramStatus(wordcountFlow1));
  startProgram(wordcountFlow1);
  waitState(wordcountFlow1,ProgramRunStatus.RUNNING.toString());
  stopProgram(wordcountFlow1);
  waitState(wordcountFlow1,STOPPED);
  response=deploy(DummyAppWithTrackingTable.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program dummyMR1=Id.Program.from(TEST_NAMESPACE1,DUMMY_APP_ID,ProgramType.MAPREDUCE,DUMMY_MR_NAME);
  Id.Program dummyMR2=Id.Program.from(TEST_NAMESPACE2,DUMMY_APP_ID,ProgramType.MAPREDUCE,DUMMY_MR_NAME);
  Assert.assertEquals(STOPPED,getProgramStatus(dummyMR2));
  startProgram(dummyMR1,404);
  Assert.assertEquals(STOPPED,getProgramStatus(dummyMR2));
  startProgram(dummyMR2);
  waitState(dummyMR2,ProgramRunStatus.RUNNING.toString());
  stopProgram(dummyMR2);
  waitState(dummyMR2,STOPPED);
  startProgram(dummyMR2);
  startProgram(dummyMR2);
  verifyProgramRuns(dummyMR2,"String_Node_Str",1);
  List<RunRecord> historyRuns=getProgramRuns(dummyMR2,"String_Node_Str");
  Assert.assertTrue(2 == historyRuns.size());
  String runId=historyRuns.get(0).getPid();
  stopProgram(dummyMR2,200,runId);
  runId=historyRuns.get(1).getPid();
  stopProgram(dummyMR2,200,runId);
  waitState(dummyMR2,STOPPED);
  response=deploy(SleepingWorkflowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program sleepWorkflow1=Id.Program.from(TEST_NAMESPACE1,SLEEP_WORKFLOW_APP_ID,ProgramType.WORKFLOW,SLEEP_WORKFLOW_NAME);
  Id.Program sleepWorkflow2=Id.Program.from(TEST_NAMESPACE2,SLEEP_WORKFLOW_APP_ID,ProgramType.WORKFLOW,SLEEP_WORKFLOW_NAME);
  Assert.assertEquals(STOPPED,getProgramStatus(sleepWorkflow2));
  startProgram(sleepWorkflow1,404);
  Assert.assertEquals(STOPPED,getProgramStatus(sleepWorkflow2));
  startProgram(sleepWorkflow2);
  waitState(sleepWorkflow2,ProgramRunStatus.RUNNING.toString());
  waitState(sleepWorkflow2,STOPPED);
  response=doDelete(getVersionedAPIPath("String_Node_Str",Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE1));
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=doDelete(getVersionedAPIPath("String_Node_Str",Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2));
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
}

Fixed version (ground truth):
@Category(XSlowTests.class) @Test public void testProgramStartStopStatus() throws Exception {
  HttpResponse response=deploy(WordCountApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE1);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Flow wordcountFlow1=Id.Flow.from(TEST_NAMESPACE1,WORDCOUNT_APP_NAME,WORDCOUNT_FLOW_NAME);
  Id.Flow wordcountFlow2=Id.Flow.from(TEST_NAMESPACE2,WORDCOUNT_APP_NAME,WORDCOUNT_FLOW_NAME);
  Assert.assertEquals(STOPPED,getProgramStatus(wordcountFlow1));
  startProgram(wordcountFlow2,404);
  Assert.assertEquals(STOPPED,getProgramStatus(wordcountFlow1));
  startProgram(wordcountFlow1);
  waitState(wordcountFlow1,ProgramRunStatus.RUNNING.toString());
  stopProgram(wordcountFlow1);
  waitState(wordcountFlow1,STOPPED);
  response=deploy(DummyAppWithTrackingTable.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program dummyMR1=Id.Program.from(TEST_NAMESPACE1,DUMMY_APP_ID,ProgramType.MAPREDUCE,DUMMY_MR_NAME);
  Id.Program dummyMR2=Id.Program.from(TEST_NAMESPACE2,DUMMY_APP_ID,ProgramType.MAPREDUCE,DUMMY_MR_NAME);
  Assert.assertEquals(STOPPED,getProgramStatus(dummyMR2));
  startProgram(dummyMR1,404);
  Assert.assertEquals(STOPPED,getProgramStatus(dummyMR2));
  startProgram(dummyMR2);
  waitState(dummyMR2,ProgramRunStatus.RUNNING.toString());
  stopProgram(dummyMR2);
  waitState(dummyMR2,STOPPED);
  startProgram(dummyMR2);
  startProgram(dummyMR2);
  verifyProgramRuns(dummyMR2,"String_Node_Str",1);
  List<RunRecord> historyRuns=getProgramRuns(dummyMR2,"String_Node_Str");
  Assert.assertTrue(2 == historyRuns.size());
  String runId=historyRuns.get(0).getPid();
  stopProgram(dummyMR2,runId,200);
  runId=historyRuns.get(1).getPid();
  stopProgram(dummyMR2,runId,200);
  waitState(dummyMR2,STOPPED);
  response=deploy(SleepingWorkflowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program sleepWorkflow1=Id.Program.from(TEST_NAMESPACE1,SLEEP_WORKFLOW_APP_ID,ProgramType.WORKFLOW,SLEEP_WORKFLOW_NAME);
  Id.Program sleepWorkflow2=Id.Program.from(TEST_NAMESPACE2,SLEEP_WORKFLOW_APP_ID,ProgramType.WORKFLOW,SLEEP_WORKFLOW_NAME);
  Assert.assertEquals(STOPPED,getProgramStatus(sleepWorkflow2));
  startProgram(sleepWorkflow1,404);
  Assert.assertEquals(STOPPED,getProgramStatus(sleepWorkflow2));
  startProgram(sleepWorkflow2);
  waitState(sleepWorkflow2,ProgramRunStatus.RUNNING.toString());
  waitState(sleepWorkflow2,STOPPED);
  response=doDelete(getVersionedAPIPath("String_Node_Str",Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE1));
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  response=doDelete(getVersionedAPIPath("String_Node_Str",Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2));
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
}