Exemplo n.º 1
0
 def test_offline(self):
     self.worker.ping()
     offline = time.time() - 81  # 81 seconds old
     os.utime(self.worker.pings_log, (offline, offline))
     _check_workers()
     db.session.refresh(self.worker)
     self.assertFalse(self.worker.online)
Exemplo n.º 2
0
    def test_truncate(self):
        # rotation is disabled by default:

        # create a big file
        self.worker.ping()
        with open(self.worker.pings_log, 'a') as f:
            f.write('1' * 1024 * 1024)
        _check_workers()
        self.assertEqual(0, os.stat(self.worker.pings_log).st_size)
        # there should be two files now
        self.assertEqual(
            1, len(os.listdir(os.path.dirname(self.worker.pings_log))))

        # we should still be online
        db.session.refresh(self.worker)
        self.assertTrue(self.worker.online)
Exemplo n.º 3
0
    def test_rotate(self, rotate):
        # enable rotation
        rotate.return_value = True
        # create a big file
        self.worker.ping()
        with open(self.worker.pings_log, 'a') as f:
            f.write('1' * 1024 * 1024)
        _check_workers()
        self.assertEqual(0, os.stat(self.worker.pings_log).st_size)
        # there should be two files now
        self.assertEqual(
            2, len(os.listdir(os.path.dirname(self.worker.pings_log))))

        # we should still be online
        db.session.refresh(self.worker)
        self.assertTrue(self.worker.online)
Exemplo n.º 4
0
 def test_offline_no_pings(self):
     _check_workers()
     db.session.refresh(self.worker)
     self.assertFalse(self.worker.online)