Beispiel #1
0
    def testAlertGeneratorCouchErrorsPollerBasic(self):
        try:
            poller = CouchErrorsPoller(self.config.AlertGenerator.couchErrorsPoller, self.generator)
        except Exception as ex:
            self.fail("Exception, reason: %s" % ex)

        # even a single values to observe shall be turned into particular iterables
        obs = self.config.AlertGenerator.couchErrorsPoller.observables
        self.config.AlertGenerator.couchErrorsPoller.observables = 400
        try:
            poller = CouchErrorsPoller(self.config.AlertGenerator.couchErrorsPoller, self.generator)
        except Exception as ex:
            self.fail("Exception, reason: %s" % ex)
        #self.assertTrue(isinstance(obs, (types.ListType, types.TupleType)))
        self.assertTrue(isinstance(self.config.AlertGenerator.couchErrorsPoller.observables,
                                   (types.ListType, types.TupleType)))

        # test return value on non-sense HTTP status code
        res = poller.sample("40000")
        self.assertFalse(res)
        # test definitely existing value
        res = poller.sample("200")
        # on a freshly started couch, this status code may not exist in the
        # stats table, so despite correct and meaningful HTTP status code, the
        # query may still return None, hence don't assume any particular response
        #self.assertTrue(isinstance(res, types.IntType))
        poller.check()
Beispiel #2
0
     except Exception, ex:
         self.fail("Exception, reason: %s" % ex)
     #self.assertTrue(isinstance(obs, (types.ListType, types.TupleType)))
     self.assertTrue(isinstance(self.config.AlertGenerator.couchErrorsPoller.observables,
                                (types.ListType, types.TupleType)))
     
     # test return value on non-sense HTTP status code
     res = poller.sample("40000")
     self.assertFalse(res)
     # test definitely existing value
     res = poller.sample("200")
     # on a freshly started couch, this status code may not exist in the
     # stats table, so despite correct and meaningful HTTP status code, the
     # query may still return None, hence don't assume any particular response
     #self.assertTrue(isinstance(res, types.IntType))
     poller.check()
     
     
 def testAlertGeneratorCouchErrorsPollerSoftThreshold(self):
     self.config.AlertGenerator.couchErrorsPoller.couchURL = os.getenv("COUCHURL", None)
     self.config.AlertGenerator.couchErrorsPoller.soft = 100
     self.config.AlertGenerator.couchErrorsPoller.critical = 200
     # shall expect corresponding number of generated alerts for each observable value
     self.config.AlertGenerator.couchErrorsPoller.observables = (5, 6, 7)
     self.config.AlertGenerator.couchErrorsPoller.pollInterval = 0.2
     ti = utils.TestInput() # see attributes comments at the class
     ti.pollerClass = CouchErrorsPoller
     ti.config = self.config.AlertGenerator.couchErrorsPoller
     ti.thresholdToTest = self.config.AlertGenerator.couchErrorsPoller.soft
     ti.level = self.config.AlertProcessor.soft.level
     ti.expected = len(self.config.AlertGenerator.couchErrorsPoller.observables)
Beispiel #3
0
        #self.assertTrue(isinstance(obs, (types.ListType, types.TupleType)))
        self.assertTrue(
            isinstance(
                self.config.AlertGenerator.couchErrorsPoller.observables,
                (types.ListType, types.TupleType)))

        # test return value on non-sense HTTP status code
        res = poller.sample("40000")
        self.assertFalse(res)
        # test definitely existing value
        res = poller.sample("200")
        # on a freshly started couch, this status code may not exist in the
        # stats table, so despite correct and meaningful HTTP status code, the
        # query may still return None, hence don't assume any particular response
        #self.assertTrue(isinstance(res, types.IntType))
        poller.check()

    def testAlertGeneratorCouchErrorsPollerSoftThreshold(self):
        self.config.AlertGenerator.couchErrorsPoller.couchURL = os.getenv(
            "COUCHURL", None)
        self.config.AlertGenerator.couchErrorsPoller.soft = 100
        self.config.AlertGenerator.couchErrorsPoller.critical = 200
        # shall expect corresponding number of generated alerts for each observable value
        self.config.AlertGenerator.couchErrorsPoller.observables = (5, 6, 7)
        self.config.AlertGenerator.couchErrorsPoller.pollInterval = 0.2
        ti = utils.TestInput()  # see attributes comments at the class
        ti.pollerClass = CouchErrorsPoller
        ti.config = self.config.AlertGenerator.couchErrorsPoller
        ti.thresholdToTest = self.config.AlertGenerator.couchErrorsPoller.soft
        ti.level = self.config.AlertProcessor.soft.level
        ti.expected = len(