def testAllUp(self): tasks = self._new_tasks() for x in simpleCorrelator(tasks, connected_ips=True, reactorYield=noOpYield): pass eventCount = len(self._events) self.assertEqual(eventCount, 0, 'All devices should be up, but got %d events' % eventCount)
def testAllUp(self): tasks = self._new_tasks() for x in simpleCorrelator(tasks, connected_ips=True, reactorYield=noOpYield): pass eventCount = len(self._events) self.assertEqual( eventCount, 0, 'All devices should be up, but got %d events' % eventCount)
def testRouter1DownConnectedIps(self): tasks = self._new_tasks() for devId in ('device_0', 'device_1', 'device_2', 'router_1'): task = tasks[devId] task.isUp = False task.delayedIsUp = False # exercise correlator for x in simpleCorrelator(tasks, connected_ips=True, reactorYield=noOpYield): pass # should have 4 down events eventCount = len(self._events) self.assertEqual(eventCount, 4, '4 devices should be down, but got %d events' % eventCount) # make sure we get the events we expect expectedEvents = {} expectedEvents['device_0'] = { 'rootcause.componentId': 'eth0', 'rootcause.message': "IP 'router_1_ip' on interface 'eth0' is connected to device 'router_1' and is also in the traceroute for monitored ip 'device_0_ip' on device 'device_0'", 'rootcause.componentIP': 'router_1_ip', 'rootcause.deviceId': 'router_1', 'suppressed': True, 'id': 'device_0', 'up': False, } expectedEvents['router_1'] = {'id': 'router_1', 'up': False} expectedEvents['device_1'] = { 'rootcause.componentId': 'eth1', 'rootcause.message': "IP 'router_1_ip_1' on interface 'eth1' is connected to device 'router_1' and is also in the traceroute for monitored ip 'device_1_ip' on device 'device_1'", 'rootcause.deviceId': 'router_1', 'up': False, 'rootcause.componentIP': 'router_1_ip_1', 'suppressedWithconnectedIp': 'True', 'suppressed': True, 'id': 'device_1'} expectedEvents['device_2'] = { 'rootcause.componentId': 'eth2', 'rootcause.message': "IP 'router_1_ip_2' on interface 'eth2' is connected to device 'router_1' and is also in the traceroute for monitored ip 'device_2_ip' on device 'device_2'", 'rootcause.deviceId': 'router_1', 'up': False, 'rootcause.componentIP': 'router_1_ip_2', 'suppressedWithconnectedIp': 'True', 'suppressed': True, 'id': 'device_2', } while len(self._events): actualEvent = self._events.pop() expectedEvent = expectedEvents.get(actualEvent['id'], None) self.assertIsNotNone(expectedEvent, 'Unexpected event generated: %r' % actualEvent) self.assertDictEqual(actualEvent, expectedEvent)
def testEdgeDown(self): tasks = self._new_tasks() tasks['device_6'].isUp = False tasks['device_6'].delayedIsUp = False # exercise correlator for x in simpleCorrelator(tasks, connected_ips=True, reactorYield=noOpYield): pass # should have 1 down event eventCount = len(self._events) self.assertEqual(eventCount, 1, 'One device should be down, but got %d events' % eventCount) # make sure we get the event we expect expectedEvent = {"id": "device_6", "up": False} self.assertDictEqual(expectedEvent, self._events[0])
def testEdgeDown(self): tasks = self._new_tasks() tasks['device_6'].isUp = False tasks['device_6'].delayedIsUp = False # exercise correlator for x in simpleCorrelator(tasks, connected_ips=True, reactorYield=noOpYield): pass # should have 1 down event eventCount = len(self._events) self.assertEqual( eventCount, 1, 'One device should be down, but got %d events' % eventCount) # make sure we get the event we expect expectedEvent = {"id": "device_6", "up": False} self.assertDictEqual(expectedEvent, self._events[0])
def testRouter1DownNoConnectedIps(self): tasks = self._new_tasks() for devId in ('device_0', 'device_1', 'device_2', 'router_1'): task = tasks[devId] task.isUp = False task.delayedIsUp = False # exercise correlator for x in simpleCorrelator(tasks, connected_ips=False, reactorYield=noOpYield): pass # should have 4 down events eventCount = len(self._events) self.assertEqual( eventCount, 4, '4 devices should be down, but got %d events' % eventCount) # make sure we get the events we expect expectedEvents = {} expectedEvents['device_0'] = { 'rootcause.componentId': 'eth0', 'rootcause.message': "IP 'router_1_ip' on interface 'eth0' is connected to device 'router_1' and is also in the traceroute for monitored ip 'device_0_ip' on device 'device_0'", 'rootcause.componentIP': 'router_1_ip', 'rootcause.deviceId': 'router_1', 'suppressed': True, 'id': 'device_0', 'up': False, } expectedEvents['device_1'] = {'id': 'device_1', 'up': False} expectedEvents['device_2'] = {'id': 'device_2', 'up': False} expectedEvents['router_1'] = {'id': 'router_1', 'up': False} while len(self._events): actualEvent = self._events.pop() expectedEvent = expectedEvents.get(actualEvent['id'], None) self.assertIsNotNone( expectedEvent, 'Unexpected event generated: %r' % actualEvent) self.assertDictEqual(actualEvent, expectedEvent)