コード例 #1
0
ファイル: test_metric.py プロジェクト: hawkowl/eagleeye
class EagleEyeMetric(unittest.TestCase):

    def setUp(self):

        self.ee = Metric(myhost='EagleEye', timeprecision=2, host='127.0.0.1', port=5555)
        twisted.internet.base.DelayedCall.debug = True

    def test_recordRegularFunction(self):

        @self.ee.record('OneSecondTest')
        def OneSecondTest():

            time.sleep(1)

        OneSecondTest()

    def test_recordRegularFunctionWithThreshold(self):

        @self.ee.record('OneSecondTest_Critical', ee_criticalthreshold='500')
        def OneSecondTest_Threshold():

            time.sleep(1)

        OneSecondTest_Threshold()

    def test_recordDeferred(self):

        @self.ee.record('DNSLookup')
        def printResult(address):

            return self.assertEqual(address, '127.0.0.1')

        def returnfakeDNS():

            return '127.0.0.1'

        def fakeDNS(address):

            return maybeDeferred(returnfakeDNS)

        d = fakeDNS('127.0.0.1')
        d.addCallback(printResult)

        return d

    def tearDown(self):

        return self.ee.shutdown()
コード例 #2
0
ファイル: test_metric.py プロジェクト: hawkowl/eagleeye
    def setUp(self):

        self.ee = Metric(myhost='EagleEye', timeprecision=2, host='127.0.0.1', port=5555)
        twisted.internet.base.DelayedCall.debug = True