Esempio n. 1
0
 public void processRow(ResultSet rs) throws SQLException {
   assertEquals(m_svc.getNodeId(), rs.getInt("nodeId"));
   assertEquals(m_svc.getIpAddr(), rs.getString("ipAddr"));
   assertEquals(m_svc.getId(), rs.getInt("serviceId"));
   assertEquals(m_lostSvcEvent.getDbid(), Integer.valueOf(rs.getInt("svcLostEventId")));
   assertEquals(m_lostSvcTime, rs.getTimestamp("ifLostService"));
   assertEquals(getRegainedEventId(), rs.getObject("svcRegainedEventId"));
   assertEquals(m_regainedSvcTime, rs.getTimestamp("ifRegainedService"));
 }
Esempio n. 2
0
  @Test
  public void testNodeLostServiceWithReason() {
    m_pollerConfig.setNodeOutageProcessingEnabled(true);

    MockService svc = m_network.getService(1, "192.168.1.1", "ICMP");
    Event e = svc.createDownEvent();
    String reasonParm = "eventReason";
    String val = EventUtil.getNamedParmValue("parm[" + reasonParm + "]", e);
    assertEquals("Service Not Responding.", val);
  }
Esempio n. 3
0
  @Test
  public void testBug709() {

    m_pollerConfig.setNodeOutageProcessingEnabled(true);

    MockNode node = m_network.getNode(2);
    MockService icmpService = m_network.getService(2, "192.168.1.3", "ICMP");
    MockService httpService = m_network.getService(2, "192.168.1.3", "HTTP");

    // start the poller
    startDaemons();

    //
    // Bring Down the HTTP service and expect nodeLostService Event
    //

    resetAnticipated();
    anticipateDown(httpService);

    // bring down the HTTP service
    httpService.bringDown();

    verifyAnticipated(10000);

    //
    // Bring Down the ICMP (on the only interface on the node) now expect
    // nodeDown
    // only.
    //

    resetAnticipated();
    anticipateDown(node);

    // bring down the ICMP service
    icmpService.bringDown();

    // make sure the down events are received
    // verifyAnticipated(10000);
    sleep(5000);
    //
    // Bring up both the node and the httpService at the same time. Expect
    // both a nodeUp and a nodeRegainedService
    //

    resetAnticipated();
    // the order matters here
    anticipateUp(httpService);
    anticipateUp(node);

    // bring up all the services on the node
    node.bringUp();

    // make sure the down events are received
    verifyAnticipated(10000);
  }
Esempio n. 4
0
  @Test
  public void testSuspendPollingResumeService() {

    MockService svc = m_network.getService(1, "192.168.1.2", "SMTP");

    startDaemons();

    sleep(2000);
    assertTrue(0 < svc.getPollCount());

    m_eventMgr.sendEventToListeners(MockEventUtil.createSuspendPollingServiceEvent("Test", svc));
    svc.resetPollCount();

    sleep(5000);
    assertEquals(0, svc.getPollCount());

    m_eventMgr.sendEventToListeners(MockEventUtil.createResumePollingServiceEvent("Test", svc));

    sleep(2000);
    assertTrue(0 < svc.getPollCount());
  }
Esempio n. 5
0
  @Test
  public void testNodeLostServiceIncludesReason() throws Exception {
    MockService element = m_network.getService(1, "192.168.1.1", "SMTP");
    String expectedReason = "Oh No!! An Outage!!";
    startDaemons();

    resetAnticipated();
    anticipateDown(element);

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

    verifyAnticipated(8000);

    Collection<Event> receivedEvents = m_anticipator.getAnticipatedEventsRecieved();

    assertEquals(1, receivedEvents.size());

    Event event = receivedEvents.iterator().next();

    assertEquals(expectedReason, EventUtils.getParm(event, EventConstants.PARM_LOSTSERVICE_REASON));
  }
Esempio n. 6
0
  @Test
  public void testInterfaceWithNoCriticalService() {
    m_pollerConfig.setNodeOutageProcessingEnabled(true);

    MockInterface iface = m_network.getInterface(3, "192.168.1.4");
    MockService svc = iface.getService("SMTP");
    MockService otherService = iface.getService("HTTP");

    startDaemons();

    anticipateDown(iface);

    iface.bringDown();

    verifyAnticipated(8000);

    anticipateUp(iface);
    anticipateDown(otherService, true);

    svc.bringUp();

    verifyAnticipated(8000);
  }
Esempio n. 7
0
  @Test
  public void testNodeGainedServiceWhileNodeDownAndServiceDown() {

    startDaemons();

    MockNode node = m_network.getNode(4);
    MockService svc = m_network.getService(4, "192.168.1.6", "SNMP");

    anticipateDown(node);

    node.bringDown();

    verifyAnticipated(5000);

    resetAnticipated();

    MockService newSvc = m_network.addService(4, "192.168.1.6", "SMTP");

    m_db.writeService(newSvc);

    newSvc.bringDown();

    Event e = MockEventUtil.createNodeGainedServiceEvent("Test", newSvc);
    m_eventMgr.sendEventToListeners(e);

    sleep(5000);
    System.err.println(m_db.getOutages());

    verifyAnticipated(8000);

    anticipateUp(node);
    anticipateDown(svc, true);

    newSvc.bringUp();

    verifyAnticipated(5000);
  }
Esempio n. 8
0
  private void testSendNodeGainedServices(
      int nodeid, String nodeLabel, String ipAddr, String... svcNames) {
    assertNotNull(svcNames);
    assertTrue(svcNames.length > 0);

    MockNode node = m_network.addNode(nodeid, nodeLabel);
    m_db.writeNode(node);
    MockInterface iface = m_network.addInterface(nodeid, ipAddr);
    m_db.writeInterface(iface);

    List<MockService> services = new ArrayList<MockService>();
    for (String svcName : svcNames) {
      MockService svc = m_network.addService(nodeid, ipAddr, svcName);
      m_db.writeService(svc);
      m_pollerConfig.addService(svc);
      services.add(svc);
    }

    MockVisitor gainSvcSender =
        new MockVisitorAdapter() {
          public void visitService(MockService svc) {
            Event event = MockEventUtil.createNodeGainedServiceEvent("Test", svc);
            m_eventMgr.sendEventToListeners(event);
          }
        };
    node.visit(gainSvcSender);

    MockService svc1 = services.get(0);

    PollAnticipator anticipator = new PollAnticipator();
    svc1.addAnticipator(anticipator);

    anticipator.anticipateAllServices(svc1);

    StringBuffer didNotOccur = new StringBuffer();
    for (MockService service : anticipator.waitForAnticipated(10000)) {
      didNotOccur.append(service.toString());
    }
    StringBuffer unanticipatedStuff = new StringBuffer();
    for (MockService service : anticipator.unanticipatedPolls()) {
      unanticipatedStuff.append(service.toString());
    }

    assertEquals(unanticipatedStuff.toString(), "", didNotOccur.toString());

    anticipateDown(svc1);

    svc1.bringDown();

    verifyAnticipated(10000);
  }
Esempio n. 9
0
  @Test
  @Ignore
  public void testBug1564() {
    // NODE processing = true;
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    MockNode node = m_network.getNode(2);
    MockService icmpService = m_network.getService(2, "192.168.1.3", "ICMP");
    MockService smtpService = m_network.getService(2, "192.168.1.3", "SMTP");
    MockService snmpService = m_network.getService(2, "192.168.1.3", "SNMP");

    // start the poller
    startDaemons();

    //
    // Bring Down the HTTP service and expect nodeLostService Event
    //

    resetAnticipated();
    anticipateDown(snmpService);
    // One service works fine
    snmpService.bringDown();

    verifyAnticipated(10000);

    // Now we simulate the restart, the node
    // looses all three at the same time

    resetAnticipated();
    anticipateDown(node);

    icmpService.bringDown();
    smtpService.bringDown();
    snmpService.bringDown();

    verifyAnticipated(10000);
    anticipateDown(smtpService);
    verifyAnticipated(10000);
    anticipateDown(snmpService);
    verifyAnticipated(10000);

    // This is to simulate a restart,
    // where I turn off the node behaviour

    m_pollerConfig.setNodeOutageProcessingEnabled(false);

    anticipateUp(snmpService);
    snmpService.bringUp();

    verifyAnticipated(10000);

    anticipateUp(smtpService);
    smtpService.bringUp();

    verifyAnticipated(10000);

    // Another restart - let's see if this will work?

    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    // So everything is down, now
    // SNMP will regain and SMTP will regain
    // will the node come up?

    smtpService.bringDown();

    anticipateUp(smtpService);
    smtpService.bringUp();

    verifyAnticipated(10000, true);

    anticipateUp(snmpService);
    snmpService.bringUp();

    verifyAnticipated(10000);
  }