Пример #1
0
  // remove task-ending chunk, past task deadline, s.b. Timeout error.
  public void testRemoveChunkTaskEndTimeout() {
    final List finished = new ArrayList();
    StepTask t1 =
        task(
            100,
            200,
            100,
            new TaskCallback() {
              public void taskEvent(SchedulableTask task, Schedule.EventType event) {
                if (log.isDebug2()) {
                  log.debug2("testRemoveChunkTaskEndTimeout callback");
                }
                if (event == Schedule.EventType.FINISH) {
                  finished.add(task);
                }
              }
            });
    Schedule s = sched(ListUtil.list(t1));
    fact.setResult(s);
    assertTrue(tr.addToSchedule(t1));

    Schedule.Chunk chunk = (Schedule.Chunk) s.getEvents().get(0);
    assertTrue(tr.getCurrentSchedule().getEvents().contains(chunk));
    chunk.setTaskEnd();
    TimeBase.setSimulated(201);
    tr.removeChunk(chunk);
    assertFalse(tr.getCurrentSchedule().getEvents().contains(chunk));
    assertSame(t1, finished.get(0));
    assertNotNull(t1.e);
    assertTrue(t1.e.toString(), t1.e instanceof SchedService.Timeout);
    assertEmpty(tr.getAcceptedTasks());
  }
Пример #2
0
 public void testRunStepsWithOverrunDisallowed() {
   StepTask t1 = task(100, 300, 100, null, new MyMockStepper(15, -10));
   //    t1.setOverrunAllowed(true);
   StepTask t2 = task(150, 250, 100, null, new MyMockStepper(10, -10));
   Schedule s = sched(ListUtil.list(t1, t2));
   fact.setResults(s, s);
   assertTrue(tr.addToSchedule(t1));
   assertTrue(tr.addToSchedule(t2));
   TimeBase.setSimulated(101);
   Interrupter intr = null;
   try {
     intr = interruptMeIn(TIMEOUT_SHOULDNT, true);
     while (tr.findTaskToRun()) {
       tr.runSteps(new MutableBoolean(true), null);
     }
     intr.cancel();
   } catch (Exception e) {
     log.error("runSteps threw:", e);
   } finally {
     if (intr.did()) {
       fail("runSteps looped");
     }
   }
   assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(removedTasks));
   assertTrue(t1.e.toString(), t1.e instanceof SchedService.Overrun);
 }
Пример #3
0
  // This should generate an impossible state log, and leave the task in
  // acceptedTasks
  public void testRemoveChunkTaskEnd() {
    final List finished = new ArrayList();
    StepTask t1 =
        task(
            100,
            200,
            100,
            new TaskCallback() {
              public void taskEvent(SchedulableTask task, Schedule.EventType event) {
                if (log.isDebug2()) {
                  log.debug2("testRemoveChunkTaskEnd event " + event);
                }
                if (event == Schedule.EventType.FINISH) {
                  finished.add(task);
                }
              }
            });
    Schedule s = sched(ListUtil.list(t1));
    fact.setResult(s);
    assertTrue(tr.addToSchedule(t1));

    Schedule.Chunk chunk = (Schedule.Chunk) s.getEvents().get(0);
    assertTrue(tr.getCurrentSchedule().getEvents().contains(chunk));
    chunk.setTaskEnd();
    t1.setFinished(); // avoids impossible task state warning in removeTask()
    tr.removeChunk(chunk);
    assertFalse(tr.getCurrentSchedule().getEvents().contains(chunk));
    assertEmpty(tr.getAcceptedTasks());
    assertIsomorphic(ListUtil.list(t1), finished);
  }
Пример #4
0
 public void testIsTaskSchedulable() {
   fact.setResult(null);
   StepTask t1 = task(100, 200, 50);
   assertFalse(tr.isTaskSchedulable(t1));
   fact.setResult(sched(ListUtil.list(t1)));
   assertTrue(tr.isTaskSchedulable(t1));
 }
Пример #5
0
  public void testStepperThrows() {
    final List finished = new ArrayList();
    TaskCallback cb =
        new TaskCallback() {
          public void taskEvent(SchedulableTask task, Schedule.EventType event) {
            if (event == Schedule.EventType.FINISH) {
              finished.add(task);
            }
          }
        };

    MyMockStepper stepper = new MyMockStepper(10, -10);
    stepper.setWhenToThrow(5);
    StepTask t1 = task(100, 200, 100, cb, stepper);
    Schedule s = sched(ListUtil.list(t1));
    fact.setResult(s);
    assertTrue(tr.addToSchedule(t1));
    TimeBase.setSimulated(101);
    assertTrue(tr.findTaskToRun());
    Interrupter intr = null;
    try {
      intr = interruptMeIn(TIMEOUT_SHOULDNT, true);
      tr.runSteps(new MutableBoolean(true), null);
      intr.cancel();
    } catch (Exception e) {
      log.error("runSteps threw:", e);
    } finally {
      if (intr.did()) {
        fail("runSteps looped");
      }
    }
    assertSame(t1, finished.get(0));
    assertTrue(t1.e instanceof ExpectedRuntimeException);
    assertEquals(5, stepper.nSteps);
  }
Пример #6
0
 public void testRunStepsWithOverrunAllowed() {
   StepTask t1 = task(100, 500, 30, null, new MyMockStepper(15, -10));
   t1.setOverrunAllowed(true);
   StepTask t2 = task(150, 250, 100, null, new MyMockStepper(10, -10));
   newTr(
       new MyMockTaskRunner(
           new TaskRunner.SchedulerFactory() {
             public Scheduler createScheduler() {
               return new SortScheduler();
             }
           }));
   assertTrue(tr.addToSchedule(t1));
   assertTrue(tr.addToSchedule(t2));
   TimeBase.setSimulated(101);
   assertTrue(tr.findTaskToRun());
   Interrupter intr = null;
   try {
     intr = interruptMeIn(TIMEOUT_SHOULDNT, true);
     while (tr.findTaskToRun()) {
       tr.runSteps(new MutableBoolean(true), null);
     }
     intr.cancel();
   } catch (Exception e) {
     log.error("runSteps threw:", e);
   } finally {
     if (intr.did()) {
       fail("runSteps looped");
     }
   }
   assertNull(t1.e);
   assertTrue(t1.hasOverrun());
 }
Пример #7
0
  // one task to drop, two failed schedule tries
  public void testAddToScheduleFailNoCleanup() {
    ConfigurationUtil.addFromArgs(
        TaskRunner.PARAM_DROP_TASK_MAX, "10", TaskRunner.PARAM_MIN_CLEANUP_INTERVAL, "0");
    StepTask t1 = task(100, 200, 50);
    StepTask t2 = task(100, 200, 100);
    Schedule sched = sched(ListUtil.list(t1));
    fact.setResult(sched);
    assertTrue(tr.addToSchedule(t1));
    assertIsomorphic(ListUtil.list(t1), fact.scheduler.tasks);
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getAcceptedTasks()));
    assertForegroundStat(1, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(1, TaskRunner.STAT_WAITING);
    assertForegroundStat(0, TaskRunner.STAT_DROPPED);

    assertFalse(tr.addToSchedule(t2));
    assertEquals(
        ListUtil.list(ListUtil.list(t1), ListUtil.list(t1, t2), ListUtil.list(t1)),
        fact.createArgs);
    assertEquals(SetUtil.set(t1), SetUtil.theSet(fact.scheduler.tasks));
    assertEquals(sched, tr.getCurrentSchedule());
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getAcceptedTasks()));
    assertForegroundStat(1, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(1, TaskRunner.STAT_REFUSED);
    assertForegroundStat(1, TaskRunner.STAT_WAITING);
    assertForegroundStat(0, TaskRunner.STAT_DROPPED);
  }
Пример #8
0
 // ensure addToSchedule returns false if (Mock)Scheduler returns false
 public void testAddToScheduleFail() {
   fact.setResult(null);
   StepTask t1 = task(100, 200, 50);
   assertFalse(tr.addToSchedule(t1));
   assertEmpty(tr.getAcceptedTasks());
   assertForegroundStat(0, TaskRunner.STAT_ACCEPTED);
   assertForegroundStat(1, TaskRunner.STAT_REFUSED);
 }
Пример #9
0
 private void newTr(MyMockTaskRunner newTr) {
   if (tr != null) {
     tr.stopService();
   }
   tr = newTr;
   tr.initService(getMockLockssDaemon());
   tr.startService();
 }
Пример #10
0
 // only one try, because no tasks to drop
 public void testAddToScheduleFailNothingToDrop() {
   ConfigurationUtil.addFromArgs(TaskRunner.PARAM_DROP_TASK_MAX, "2");
   fact.setResult(null);
   StepTask t1 = task(100, 200, 50);
   assertFalse(tr.addToSchedule(t1));
   assertEmpty(tr.getAcceptedTasks());
   assertEquals(1, fact.createArgs.size());
   assertForegroundStat(1, TaskRunner.STAT_REFUSED);
   assertForegroundStat(0, TaskRunner.STAT_WAITING);
   assertForegroundStat(0, TaskRunner.STAT_DROPPED);
 }
Пример #11
0
 public void setUp() throws Exception {
   super.setUp();
   TimeBase.setSimulated();
   ConfigurationUtil.setFromArgs(SortScheduler.PARAM_OVERHEAD_LOAD, "0");
   removedChunks = new ArrayList();
   removedTasks = new ArrayList();
   fact = new SchedFact(null);
   tr = new MyMockTaskRunner(fact);
   tr.initService(getMockLockssDaemon());
   tr.startService();
 }
Пример #12
0
  public void testRemoveChunk() {
    StepTask t1 = task(100, 200, 100);
    Schedule s = sched(ListUtil.list(t1));
    fact.setResult(s);
    assertTrue(tr.addToSchedule(t1));
    assertIsomorphic(ListUtil.list(t1), tr.getAcceptedTasks());

    Schedule.Chunk chunk = (Schedule.Chunk) s.getEvents().get(0);
    assertTrue(tr.getCurrentSchedule().getEvents().contains(chunk));
    tr.removeChunk(chunk);
    assertFalse(tr.getCurrentSchedule().getEvents().contains(chunk));
  }
Пример #13
0
  public void testFindOverrunTaskToRun() {
    assertFalse(tr.findTaskToRun());
    StepTask t1 = task(100, 200, 100);
    Schedule s = sched(ListUtil.list(t1));
    fact.setResult(s);
    assertTrue(tr.addToSchedule(t1));
    assertFalse(tr.findTaskToRun());
    assertEquals(Deadline.at(100), tr.runningDeadline);

    StepTask t2 = task(0, 300, 50);
    tr.addOverrunner(t2);
    assertTrue(tr.findTaskToRun());
    assertEquals(t2, tr.runningTask);
    assertEquals(Deadline.at(100), tr.runningDeadline);
    assertNull(tr.runningChunk);
  }
Пример #14
0
  public void testFindChunkTaskToRun() {
    assertFalse(tr.findTaskToRun());
    StepTask t1 = task(100, 200, 100);
    StepTask t2 = task(100, 300, 50);

    Schedule s = sched(ListUtil.list(t1, t2));
    fact.setResults(s, s);
    assertTrue(tr.addToSchedule(t1));
    assertTrue(tr.addToSchedule(t2));
    assertFalse(tr.findTaskToRun());
    assertEquals(Deadline.at(100), tr.runningDeadline);

    TimeBase.setSimulated(101);
    assertTrue(tr.findTaskToRun());
    assertEquals(t1, tr.runningTask);
    assertEquals(t1.getLatestFinish(), tr.runningDeadline);
    assertEquals(s.getEvents().get(0), tr.runningChunk);
  }
Пример #15
0
 // ensure addToSchedule updates structures if (Mock)Scheduler returns true
 public void testAddToScheduleOk() {
   StepTask t1 = task(100, 200, 50);
   StepTask t2 = task(100, 200, 100);
   Schedule sched = sched(ListUtil.list(t1, t2));
   fact.setResult(sched);
   assertTrue(tr.addToSchedule(t1));
   assertIsomorphic(ListUtil.list(t1), fact.scheduler.tasks);
   assertForegroundStat(1, TaskRunner.STAT_ACCEPTED);
   assertForegroundStat(0, TaskRunner.STAT_REFUSED);
   fact.setResult(sched);
   assertTrue(tr.addToSchedule(t2));
   assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(fact.scheduler.tasks));
   assertEquals(sched, tr.getCurrentSchedule());
   assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(tr.getAcceptedTasks()));
   assertForegroundStat(2, TaskRunner.STAT_ACCEPTED);
   assertForegroundStat(2, TaskRunner.STAT_WAITING);
   assertForegroundStat(0, TaskRunner.STAT_REFUSED);
 }
Пример #16
0
  public void testFindTaskToRunRemovesExpiredChunks() {
    assertFalse(tr.findTaskToRun());
    StepTask t1 = task(100, 200, 100);
    StepTask t2 = task(100, 300, 50);
    StepTask texp1 = task(0, 0, 50);
    StepTask texp2 = task(0, 0, 50);

    Schedule s = sched(ListUtil.list(texp1, texp2, t1, t2));
    fact.setResults(s, s);
    assertTrue(tr.addToSchedule(t1));
    assertTrue(tr.addToSchedule(t2));
    assertFalse(tr.findTaskToRun());
    assertEquals(2, removedChunks.size());
    assertEquals(
        SetUtil.set(texp1, texp2),
        SetUtil.set(
            ((Schedule.Chunk) removedChunks.get(0)).getTask(),
            ((Schedule.Chunk) removedChunks.get(1)).getTask()));
  }
Пример #17
0
 public void testFindRunnableChunk() {
   assertFalse(tr.findTaskToRun());
   StepTask t1 = task(100, 200, 100);
   StepTask t2 = task(10, 300, 50);
   Schedule.Chunk c1 = new Schedule.Chunk(t1, Deadline.at(100), Deadline.at(200), 100);
   Schedule.Chunk c2 = new Schedule.Chunk(t2, Deadline.at(200), Deadline.at(300), 100);
   Schedule s = new Schedule(ListUtil.list(c1, c2));
   fact.setResults(s, s);
   assertTrue(tr.addToSchedule(t1));
   assertTrue(tr.addToSchedule(t2));
   assertFalse(tr.findTaskToRun());
   assertEquals(Deadline.at(100), tr.runningDeadline);
   TimeBase.setSimulated(11);
   assertTrue(tr.findTaskToRun());
   assertEquals(t2, tr.runningTask);
   assertEquals(c2, tr.runningChunk);
   assertEquals(Deadline.at(100), tr.runningDeadline);
   assertEquals(s.getEvents().get(1), tr.runningChunk);
 }
Пример #18
0
  public void testNotifyThread() {
    final List rec = new ArrayList();
    final SimpleBinarySemaphore sem = new SimpleBinarySemaphore();
    tr.setImmediateNotify(false);

    TaskCallback cb =
        new TaskCallback() {
          public void taskEvent(SchedulableTask task, Schedule.EventType event) {
            rec.add(new BERec(Deadline.in(0), (BackgroundTask) task, event));
            sem.give();
          }
        };
    BackgroundTask t1 = btask(100, 200, .1, cb);
    BackgroundTask t2 = btask(100, 300, .2, cb);

    tr.notify(t1, Schedule.EventType.START);
    tr.notify(t1, Schedule.EventType.FINISH);
    // 2nd finish event should not cause another callback
    tr.notify(t1, Schedule.EventType.FINISH);
    tr.notify(t2, Schedule.EventType.START);

    Interrupter intr = null;
    try {
      intr = interruptMeIn(TIMEOUT_SHOULDNT, true);
      while (rec.size() < 3) {
        sem.take();
      }
      assertEquals(
          ListUtil.list(
              new BERec(0, t1, Schedule.EventType.START),
              new BERec(0, t1, Schedule.EventType.FINISH),
              new BERec(0, t2, Schedule.EventType.START)),
          rec);
      intr.cancel();
    } finally {
      if (intr.did()) {
        fail("Notifier didn't run callbacks");
      }
    }
  }
Пример #19
0
  public void testFindTaskToRunRemovesExpiredOverrunners() {
    assertFalse(tr.findTaskToRun());
    StepTask t1 = task(100, 200, 100);
    StepTask t2 = task(100, 300, 50);
    StepTask texp1 = task(0, 0, 50);
    StepTask texp2 = task(0, 0, 49);

    Schedule s = sched(ListUtil.list(t1, t2));
    fact.setResults(s, s);
    assertTrue(tr.addToSchedule(t1));
    assertTrue(tr.addToSchedule(t2));
    tr.addOverrunner(texp1);
    tr.addOverrunner(texp2);

    // if this fails, it might be because the sorted list/set is treating
    // sort-order equivalence as object equality, which we don't want
    assertEquals(2, tr.getOverrunTasks().size());
    assertFalse(tr.findTaskToRun());
    assertEquals(0, removedChunks.size());
    assertEquals(2, removedTasks.size());
    assertEquals(
        SetUtil.set(texp1, texp2),
        SetUtil.set((StepTask) removedTasks.get(0), (StepTask) removedTasks.get(1)));
  }
Пример #20
0
  // one task to drop, succeeds after dropping it
  public void testAddToScheduleOkAfterDrops() {
    log.debug("testAddToScheduleOkAfterDrops()");
    ConfigurationUtil.addFromArgs(
        TaskRunner.PARAM_DROP_TASK_MAX, "10", TaskRunner.PARAM_MIN_CLEANUP_INTERVAL, "0");
    StepTask t1 = task(100, 200, 50);
    StepTask t2 = task(100, 200, 100);
    Schedule sched1 = sched(ListUtil.list(t1));
    Schedule sched2 = sched(ListUtil.list(t2));
    fact.setResults(ListUtil.list(sched1, null, null, sched2, sched2));
    TimeBase.step(101);
    assertTrue(tr.addToSchedule(t1));
    assertIsomorphic(ListUtil.list(t1), fact.scheduler.tasks);
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getAcceptedTasks()));
    assertForegroundStat(1, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(1, TaskRunner.STAT_WAITING);
    assertForegroundStat(0, TaskRunner.STAT_DROPPED);

    assertTrue(tr.addToSchedule(t2));
    assertEquals(
        ListUtil.list(
            ListUtil.list(t1),
            ListUtil.list(t1, t2),
            ListUtil.list(t1),
            Collections.EMPTY_SET,
            ListUtil.list(t1, t2)),
        fact.createArgs);
    assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(fact.scheduler.tasks));
    assertTrue(t1.isDropped());
    assertEquals(sched2, tr.getCurrentSchedule());
    assertEquals(SetUtil.set(t1, t2), SetUtil.theSet(tr.getAcceptedTasks()));
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getOverrunTasks()));
    assertForegroundStat(2, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(1, TaskRunner.STAT_WAITING);
    assertForegroundStat(1, TaskRunner.STAT_DROPPED);

    t2.cancel();
    assertForegroundStat(2, TaskRunner.STAT_ACCEPTED);
    assertForegroundStat(0, TaskRunner.STAT_REFUSED);
    assertForegroundStat(0, TaskRunner.STAT_WAITING);
    assertForegroundStat(1, TaskRunner.STAT_DROPPED);
    assertForegroundStat(1, TaskRunner.STAT_CANCELLED);
  }
Пример #21
0
 // test resched with overrun task doesn't lose task.
 public void testRunStepsWithOverrunAllowedPlusResched() {
   StepTask t1 = task(100, 500, 30, null, new MyMockStepper(15, -10));
   t1.setOverrunAllowed(true);
   StepTask t2 = task(150, 250, 100, null, new MyMockStepper(10, -10));
   newTr(
       new MyMockTaskRunner(
           new TaskRunner.SchedulerFactory() {
             public Scheduler createScheduler() {
               return new SortScheduler();
             }
           }));
   assertTrue(tr.addToSchedule(t1));
   assertEmpty(tr.getOverrunTasks());
   TimeBase.setSimulated(101);
   assertTrue(tr.findTaskToRun());
   t1.timeUsed = 1000;
   assertTrue(t1.hasOverrun());
   assertEmpty(tr.getOverrunTasks());
   assertTrue(tr.addToSchedule(t2));
   assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getOverrunTasks()));
 }
Пример #22
0
  // one task not ready to start yet, so not droppable
  public void testAddToScheduleFailNoDroppable() {
    log.debug("testAddToScheduleOkAfterDrops()");
    ConfigurationUtil.addFromArgs(
        TaskRunner.PARAM_DROP_TASK_MAX, "10", TaskRunner.PARAM_MIN_CLEANUP_INTERVAL, "0");
    StepTask t1 = task(100, 200, 50);
    StepTask t2 = task(100, 200, 100);
    Schedule sched1 = sched(ListUtil.list(t1));
    Schedule sched2 = sched(ListUtil.list(t2));
    fact.setResults(ListUtil.list(sched1, null, null, sched2, sched2));
    assertTrue(tr.addToSchedule(t1));
    assertIsomorphic(ListUtil.list(t1), fact.scheduler.tasks);
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getAcceptedTasks()));

    assertFalse(tr.addToSchedule(t2));
    assertEquals(
        ListUtil.list(ListUtil.list(t1), ListUtil.list(t1, t2), ListUtil.list(t1)),
        fact.createArgs);
    assertEquals(SetUtil.set(t1), SetUtil.theSet(fact.scheduler.tasks));
    assertFalse(t1.isDropped());
    assertEquals(sched1, tr.getCurrentSchedule());
    assertEquals(SetUtil.set(t1), SetUtil.theSet(tr.getAcceptedTasks()));
    assertEmpty(SetUtil.theSet(tr.getOverrunTasks()));
  }
Пример #23
0
 void assertBackgroundStat(int expected, int stat_ix) {
   assertEquals(expected, tr.getBackgroundStat(stat_ix));
 }
Пример #24
0
  public void testBackground() {
    final List rec = new ArrayList();
    TaskCallback cb =
        new TaskCallback() {
          public void taskEvent(SchedulableTask task, Schedule.EventType event) {
            rec.add(new BERec(Deadline.in(0), (BackgroundTask) task, event));
          }
        };
    assertFalse(tr.findTaskToRun());
    BackgroundTask t1 = btask(100, 200, .1, cb);
    BackgroundTask t2 = btask(100, 300, .2, cb);
    BackgroundTask t3 = btask(150, 200, .4, cb);

    Schedule s =
        sched(
            ListUtil.list(
                bEvent(t1, Schedule.EventType.START),
                bEvent(t2, Schedule.EventType.START),
                bEvent(t3, Schedule.EventType.START),
                bEvent(t1, Schedule.EventType.FINISH),
                bEvent(t3, Schedule.EventType.FINISH),
                bEvent(t2, Schedule.EventType.FINISH)));
    fact.setResults(ListUtil.list(s, s, s));

    assertTrue(tr.addToSchedule(t1));
    assertTrue(tr.addToSchedule(t2));
    assertTrue(tr.addToSchedule(t3));
    assertEquals(3, tr.getAcceptedTasks().size());
    assertIsomorphic(ListUtil.list(t1, t2, t3), tr.getAcceptedTasks());
    assertFalse(tr.findTaskToRun());
    assertEquals(0, rec.size());
    assertEquals(0, tr.getBackgroundLoadFactor(), .005);
    assertEquals(Deadline.at(100), tr.runningDeadline);

    TimeBase.setSimulated(101);
    assertFalse(tr.findTaskToRun());
    assertEquals(2, rec.size());
    assertEquals(.3, tr.getBackgroundLoadFactor(), .005);
    TimeBase.setSimulated(151);
    assertFalse(tr.findTaskToRun());
    assertEquals(3, rec.size());
    assertEquals(.7, tr.getBackgroundLoadFactor(), .005);
    assertEquals(3, tr.getAcceptedTasks().size());
    TimeBase.setSimulated(201);
    assertFalse(tr.findTaskToRun());
    assertEquals(5, rec.size());
    assertEquals(.2, tr.getBackgroundLoadFactor(), .005);
    assertEquals(1, tr.getAcceptedTasks().size());
    t2.taskIsFinished();
    TimeBase.setSimulated(202);
    assertFalse(tr.findTaskToRun());
    assertEquals(6, rec.size());
    assertEquals(0, tr.getBackgroundLoadFactor(), .005);
    assertEquals(0, tr.getAcceptedTasks().size());
    TimeBase.setSimulated(301);
    assertFalse(tr.findTaskToRun());
    assertEquals(6, rec.size());
    assertEquals(0, tr.getBackgroundLoadFactor(), .005);
    List exp =
        ListUtil.list(
            new BERec(101, t1, Schedule.EventType.START),
            new BERec(101, t2, Schedule.EventType.START),
            new BERec(151, t3, Schedule.EventType.START),
            new BERec(201, t1, Schedule.EventType.FINISH),
            new BERec(201, t3, Schedule.EventType.FINISH),
            new BERec(201, t2, Schedule.EventType.FINISH));
    assertEquals(exp, rec);
  }
Пример #25
0
 public void tearDown() throws Exception {
   TimeBase.setReal();
   tr.stopService();
   super.tearDown();
 }