Beispiel #1
0
 public void testPollDuration() throws Exception {
   MyAuState aus = new MyAuState(mau, historyRepo);
   assertEquals(0, aus.getPollDuration());
   aus.setPollDuration(1000);
   assertEquals(1000, aus.getPollDuration());
   aus.setPollDuration(2000);
   assertEquals(1500, aus.getPollDuration());
 }
Beispiel #2
0
  public void testPollTimeAndResult() throws Exception {
    MyAuState aus = new MyAuState(mau, historyRepo);
    assertEquals(-1, aus.getLastTopLevelPollTime());
    assertEquals(-1, aus.getLastPollStart());
    assertEquals(-1, aus.getLastPollResult());
    assertEquals(null, aus.getLastPollResultMsg());
    assertEquals(-1, aus.getLastPoPPoll());
    assertEquals(-1, aus.getLastPoPPollResult());
    assertEquals(null, aus.getLastPoPPollResultMsg());
    assertEquals(-1, aus.getLastLocalHashScan());
    assertEquals(-1, aus.getLastTimePollCompleted());
    assertEquals(0, aus.getPollDuration());
    assertNull(historyRepo.theAuState);

    TimeBase.setSimulated(t1);
    aus.pollStarted();
    // running poll
    assertEquals(t1, aus.getLastPollStart());
    // These haven't been updated yet
    assertEquals(-1, aus.getLastTopLevelPollTime());
    assertEquals(-1, aus.getLastPollResult());
    assertEquals(0, aus.getPollDuration());
    assertEquals(-1, aus.getLastTimePollCompleted());
    assertNotNull(historyRepo.theAuState);

    TimeBase.setSimulated(t2);
    aus.pollFinished(V3Poller.POLLER_STATUS_ERROR, PollVariant.PoR);
    assertEquals(-1, aus.getLastTopLevelPollTime());
    assertEquals(t1, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_ERROR, aus.getLastPollResult());
    assertEquals("Error", aus.getLastPollResultMsg());
    assertEquals(t2, aus.getPollDuration());
    assertEquals(-1, aus.getLastPoPPoll());
    assertEquals(-1, aus.getLastPoPPollResult());
    assertEquals(null, aus.getLastPoPPollResultMsg());
    assertEquals(-1, aus.getLastLocalHashScan());
    assertEquals(-1, aus.getLastTimePollCompleted());

    TimeBase.setSimulated(t3);
    aus.pollFinished(V3Poller.POLLER_STATUS_COMPLETE, PollVariant.PoR);
    assertEquals(t3, aus.getLastTopLevelPollTime());
    assertEquals(t1, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPollResult());
    assertEquals("Complete", aus.getLastPollResultMsg());
    assertEquals((t3 + t2) / 2, aus.getPollDuration());
    assertEquals(-1, aus.getLastPoPPoll());
    assertEquals(-1, aus.getLastPoPPollResult());
    assertEquals(null, aus.getLastPoPPollResultMsg());
    assertEquals(-1, aus.getLastLocalHashScan());
    assertEquals(t3, aus.getLastTimePollCompleted());

    TimeBase.setSimulated(t4);
    aus.pollFinished(V3Poller.POLLER_STATUS_NO_QUORUM, PollVariant.PoP);
    assertEquals(t3, aus.getLastTopLevelPollTime());
    assertEquals(t1, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPollResult());
    assertEquals("Complete", aus.getLastPollResultMsg());
    assertEquals((t3 + t2) / 2, aus.getPollDuration());
    assertEquals(-1, aus.getLastPoPPoll());
    assertEquals(V3Poller.POLLER_STATUS_NO_QUORUM, aus.getLastPoPPollResult());
    assertEquals(-1, aus.getLastLocalHashScan());
    assertEquals("No Quorum", aus.getLastPoPPollResultMsg());
    assertEquals(t3, aus.getLastTimePollCompleted());

    TimeBase.setSimulated(t5);
    aus.pollFinished(V3Poller.POLLER_STATUS_COMPLETE, PollVariant.PoP);
    assertEquals(t3, aus.getLastTopLevelPollTime());
    assertEquals(t1, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPollResult());
    assertEquals("Complete", aus.getLastPollResultMsg());
    assertEquals((t3 + t2) / 2, aus.getPollDuration());
    assertEquals(t5, aus.getLastPoPPoll());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPoPPollResult());
    assertEquals("Complete", aus.getLastPoPPollResultMsg());
    assertEquals(-1, aus.getLastLocalHashScan());
    assertEquals(t5, aus.getLastTimePollCompleted());
    aus.pollFinished(V3Poller.POLLER_STATUS_NO_QUORUM, PollVariant.PoP);

    TimeBase.setSimulated(t6);
    aus.pollFinished(V3Poller.POLLER_STATUS_COMPLETE, PollVariant.Local);
    assertEquals(t3, aus.getLastTopLevelPollTime());
    assertEquals(t1, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPollResult());
    assertEquals("Complete", aus.getLastPollResultMsg());
    assertEquals((t3 + t2) / 2, aus.getPollDuration());
    assertEquals(t5, aus.getLastPoPPoll());
    assertEquals(V3Poller.POLLER_STATUS_NO_QUORUM, aus.getLastPoPPollResult());
    assertEquals("No Quorum", aus.getLastPoPPollResultMsg());
    assertEquals(t6, aus.getLastLocalHashScan());
    assertEquals(t5, aus.getLastTimePollCompleted());

    aus = aus.simulateStoreLoad();
    assertEquals(t3, aus.getLastTopLevelPollTime());
    assertEquals(t1, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPollResult());

    TimeBase.setSimulated(t7);
    aus.pollStarted();
    assertEquals(t3, aus.getLastTopLevelPollTime());
    assertEquals(t7, aus.getLastPollStart());
    assertEquals(V3Poller.POLLER_STATUS_COMPLETE, aus.getLastPollResult());
  }