Beispiel #1
0
    def test_lost(self):
        beats = []
        lost = []

        def onbeat():
            beats.append('.')

        def onbeatlost():
            lost.append('.')

        hb = Heartbeat('ipc:///tmp/stetho.ipc', interval=0.1)
        hb.start()
        time.sleep(.2)

        stetho = Stethoscope('ipc:///tmp/stetho.ipc', onbeat=onbeat,
                    onbeatlost=onbeatlost,
                    delay=0.1)
        stetho.start()

        time.sleep(2.)
        hb.stop()         # the hber stops

        # the stethoer continues for a while
        time.sleep(2.)

        stetho.stop()

        self.assertTrue(len(beats) > 0)
        self.assertTrue(len(lost) > 3)
Beispiel #2
0
    def test_working(self):
        beats = []
        lost = []

        def onbeat():
            beats.append('.')

        def onbeatlost():
            lost.append('.')

        hb = Heartbeat('ipc:///tmp/stetho.ipc', interval=0.1)
        hb.start()
        time.sleep(.2)

        stetho = Stethoscope('ipc:///tmp/stetho.ipc', onbeat=onbeat,
                    onbeatlost=onbeatlost,
                    delay=0.1)
        stetho.start()

        time.sleep(5.)

        stetho.stop()
        hb.stop()
        self.assertTrue(len(beats) > 10)
        self.assertEqual(len(lost),  0)
    def test_working(self):
        beats = []
        lost = []

        def onbeat():
            beats.append('.')

        def onbeatlost():
            lost.append('.')

        hb = Heartbeat('ipc:///tmp/stetho.ipc', interval=0.1)
        hb.start()
        time.sleep(.2)

        stetho = Stethoscope('ipc:///tmp/stetho.ipc',
                             onbeat=onbeat,
                             onbeatlost=onbeatlost,
                             delay=1.,
                             retries=5.)
        stetho.start()

        time.sleep(5.)

        stetho.stop()
        hb.stop()
        self.assertEqual(len(lost), 0, len(lost))
        self.assertTrue(len(beats) > 10, len(beats))
    def test_lost(self):
        beats = []
        lost = []

        def _onbeat():
            beats.append('.')

        def _onbeatlost():
            lost.append('.')

        hb = Heartbeat('ipc:///tmp/stetho.ipc', interval=0.1)
        hb.start()
        time.sleep(.2)

        stetho = Stethoscope('ipc:///tmp/stetho.ipc',
                             onbeat=_onbeat,
                             onbeatlost=_onbeatlost,
                             delay=0.1)
        stetho.start()

        time.sleep(2.)
        hb.stop()  # the hber stops

        # the stethoer continues for a while
        time.sleep(2.)

        stetho.stop()

        self.assertTrue(len(beats) > 0)
        self.assertTrue(len(lost) > 3)
Beispiel #5
0
    def test_working(self):
        beats = []
        lost = []

        def onbeat():
            beats.append(".")

        def onbeatlost():
            lost.append(".")

        hb = Heartbeat("ipc:///tmp/stetho.ipc", interval=0.1)
        hb.start()
        time.sleep(0.2)

        stetho = Stethoscope("ipc:///tmp/stetho.ipc", onbeat=onbeat, onbeatlost=onbeatlost, delay=1.0, retries=5.0)
        stetho.start()

        time.sleep(5.0)

        stetho.stop()
        hb.stop()
        self.assertEqual(len(lost), 0, len(lost))
        self.assertTrue(len(beats) > 10, len(beats))