Exemplo n.º 1
0
  // Test harness that tests any type of node, interface or element.
  private void testElementDeleted(MockElement element) {
    Event deleteEvent = element.createDeleteEvent();
    m_pollerConfig.setNodeOutageProcessingEnabled(false);

    PollAnticipator poll = new PollAnticipator();
    element.addAnticipator(poll);

    poll.anticipateAllServices(element);

    startDaemons();

    // wait til after the first poll of the services
    poll.waitForAnticipated(1000L);

    // now delete the node and send a nodeDeleted event
    m_network.removeElement(element);
    m_eventMgr.sendEventToListeners(deleteEvent);

    // reset the poll count and wait to see if any polls on the removed
    // element happened
    m_network.resetInvalidPollCount();

    // now ensure that no invalid polls have occurred
    sleep(3000);

    assertEquals(
        "Received a poll for an element that doesn't exist", 0, m_network.getInvalidPollCount());
  }
Exemplo n.º 2
0
 private void anticipateDown(MockElement element, boolean force) {
   if (force || !element.getPollStatus().equals(PollStatus.down())) {
     Event event = element.createDownEvent();
     m_anticipator.anticipateEvent(event);
     m_outageAnticipator.anticipateOutageOpened(element, event);
   }
 }
Exemplo n.º 3
0
 private void anticipateServicesDown(MockElement node) {
   MockVisitor eventCreator =
       new MockVisitorAdapter() {
         public void visitService(MockService svc) {
           anticipateDown(svc);
         }
       };
   node.visit(eventCreator);
 }
Exemplo n.º 4
0
  public void testOutagesClosedOnDelete(MockElement element) {

    startDaemons();

    Event deleteEvent = element.createDeleteEvent();

    // bring down so we create an outage in the outages table
    anticipateDown(element);
    element.bringDown();
    verifyAnticipated(5000, false);

    m_outageAnticipator.anticipateOutageClosed(element, deleteEvent);

    // now delete the service
    m_eventMgr.sendEventToListeners(deleteEvent);
    m_network.removeElement(element);

    verifyAnticipated(5000);
  }
Exemplo n.º 5
0
 private void bringDownCritSvcs(MockElement element) {
   MockVisitor markCritSvcDown =
       new MockVisitorAdapter() {
         public void visitService(MockService svc) {
           if ("ICMP".equals(svc.getSvcName())) {
             svc.bringDown();
           }
         }
       };
   element.visit(markCritSvcDown);
 }
Exemplo n.º 6
0
 private void createOutages(MockElement element, final Event event) {
   MockVisitor outageCreater =
       new MockVisitorAdapter() {
         public void visitService(MockService svc) {
           if (svc.getMgmtStatus().equals(SvcMgmtStatus.ACTIVE)) {
             m_db.createOutage(svc, event);
           }
         }
       };
   element.visit(outageCreater);
 }
Exemplo n.º 7
0
  private void testElementDownUp(MockElement element) {
    startDaemons();

    resetAnticipated();
    anticipateDown(element);

    MockUtil.println("Bringing down element: " + element);
    element.bringDown();
    MockUtil.println("Finished bringing down element: " + element);

    verifyAnticipated(5000);

    sleep(2000);

    resetAnticipated();
    anticipateUp(element);

    MockUtil.println("Bringing up element: " + element);
    element.bringUp();
    MockUtil.println("Finished bringing up element: " + element);

    verifyAnticipated(8000);
  }