Пример #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()
Пример #2
0
     except Exception, 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, 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
Пример #3
0
        # 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, 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