Program: 6545
Project: 6545
Buggy source:
@Test public void testStreamSizeSchedule() throws Exception {
  AppFabricTestHelper.deployApplication(AppWithStreamSizeSchedule.class);
  Assert.assertEquals(Scheduler.ScheduleState.SUSPENDED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1));
  Assert.assertEquals(Scheduler.ScheduleState.SUSPENDED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1);
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  Assert.assertEquals(Scheduler.ScheduleState.SCHEDULED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1));
  Assert.assertEquals(Scheduler.ScheduleState.SCHEDULED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  int runs=store.getRuns(PROGRAM_ID,ProgramRunStatus.ALL,0,Long.MAX_VALUE,100).size();
  Assert.assertEquals(0,runs);
  StreamMetricsPublisher metricsPublisher=createMetricsPublisher(STREAM_ID);
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,1,5);
  waitUntilFinished(runtimeService,PROGRAM_ID,5);
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,3,5);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  Assert.assertEquals(Scheduler.ScheduleState.SUSPENDED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,4,5);
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  Assert.assertEquals(Scheduler.ScheduleState.SCHEDULED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,6,5);
  streamSizeScheduler.updateSchedule(PROGRAM_ID,PROGRAM_TYPE,UPDATE_SCHEDULE_2);
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,8,5);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  streamSizeScheduler.deleteSchedules(PROGRAM_ID,PROGRAM_TYPE);
  waitUntilFinished(runtimeService,PROGRAM_ID,10);
}

Fixed version (ground truth):
@Test public void testStreamSizeSchedule() throws Exception {
  AppFabricTestHelper.deployApplication(AppWithStreamSizeSchedule.class);
  Assert.assertEquals(Scheduler.ScheduleState.SUSPENDED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1));
  Assert.assertEquals(Scheduler.ScheduleState.SUSPENDED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1);
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  Assert.assertEquals(Scheduler.ScheduleState.SCHEDULED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1));
  Assert.assertEquals(Scheduler.ScheduleState.SCHEDULED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  int runs=store.getRuns(PROGRAM_ID,ProgramRunStatus.ALL,0,Long.MAX_VALUE,100).size();
  Assert.assertEquals(0,runs);
  StreamMetricsPublisher metricsPublisher=createMetricsPublisher(STREAM_ID);
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,1,15);
  waitUntilFinished(runtimeService,PROGRAM_ID,15);
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,3,15);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  Assert.assertEquals(Scheduler.ScheduleState.SUSPENDED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,4,15);
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  streamSizeScheduler.resumeSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  Assert.assertEquals(Scheduler.ScheduleState.SCHEDULED,streamSizeScheduler.scheduleState(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2));
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,6,15);
  streamSizeScheduler.updateSchedule(PROGRAM_ID,PROGRAM_TYPE,UPDATE_SCHEDULE_2);
  metricsPublisher.increment(1024 * 1024);
  waitForRuns(store,PROGRAM_ID,8,15);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_1);
  streamSizeScheduler.suspendSchedule(PROGRAM_ID,PROGRAM_TYPE,SCHEDULE_NAME_2);
  streamSizeScheduler.deleteSchedules(PROGRAM_ID,PROGRAM_TYPE);
  waitUntilFinished(runtimeService,PROGRAM_ID,10);
}