Beispiel #1
0
    def test_worker_quarantine_unpausing_doesnt_reset_timeout(self):
        worker = yield self.createWorker(attached=False)
        yield worker.startService()
        self.assertTrue(worker.canStartBuild())
        self.assertIsNone(worker.quarantine_timer)

        # pump up the quarantine wait time
        for quarantine_wait in (10, 20, 40, 80):
            worker.putInQuarantine()
            self.assertFalse(worker.canStartBuild())
            self.assertIsNotNone(worker.quarantine_timer)
            self.master.reactor.advance(quarantine_wait)
            self.assertTrue(worker.canStartBuild())
            self.assertIsNone(worker.quarantine_timer)

        # put worker into quarantine (160s)
        worker.putInQuarantine()
        self.assertFalse(worker._paused)
        self.assertFalse(worker.canStartBuild())

        # pause and unpause the worker to exit quarantine
        worker.controlWorker(("worker", 1, "pause"), {"reason": "none"})
        self.assertFalse(worker.canStartBuild())
        worker.controlWorker(("worker", 1, "unpause"), {"reason": "none"})
        self.assertFalse(worker._paused)
        self.assertTrue(worker.canStartBuild())

        # next build fails. check timeout is 320s
        worker.putInQuarantine()
        self.master.reactor.advance(319)
        self.assertFalse(worker.canStartBuild())
        self.assertIsNotNone(worker.quarantine_timer)
        self.master.reactor.advance(1)
        self.assertIsNone(worker.quarantine_timer)
        self.assertTrue(worker.canStartBuild())
Beispiel #2
0
    def test_worker_quarantine_doesnt_affect_pause(self):
        worker = yield self.createWorker(attached=False)
        yield worker.startService()
        self.assertTrue(worker.canStartBuild())
        self.assertIsNone(worker.quarantine_timer)
        self.assertFalse(worker._paused)

        # put worker into quarantine.
        # Check canStartBuild() is False, and paused state is not changed
        worker.putInQuarantine()
        self.assertFalse(worker._paused)
        self.assertFalse(worker.canStartBuild())
        self.assertIsNotNone(worker.quarantine_timer)

        # human manually pauses the worker
        worker.controlWorker(("worker", 1, "pause"), {"reason": "none"})
        self.assertTrue(worker._paused)
        self.assertFalse(worker.canStartBuild())

        # simulate wait for quarantine to end
        # Check canStartBuild() is still False, and paused state is not changed
        self.master.reactor.advance(10)
        self.assertTrue(worker._paused)
        self.assertFalse(worker.canStartBuild())
        self.assertIsNone(worker.quarantine_timer)
Beispiel #3
0
    def test_worker_actions_pause(self):
        worker = yield self.createWorker(attached=False)
        yield worker.startService()
        worker.controlWorker(("worker", 1, "pause"), {'reason': "none"})
        self.assertEqual(worker._paused, True)

        worker.controlWorker(("worker", 1, "unpause"), {'reason': "none"})
        self.assertEqual(worker._paused, False)
Beispiel #4
0
    def test_worker_actions_pause(self):
        worker = yield self.createWorker(attached=False)
        yield worker.startService()
        worker.controlWorker(("worker", 1, "pause"), {'reason': "none"})
        self.assertEqual(worker._paused, True)

        worker.controlWorker(("worker", 1, "unpause"), {'reason': "none"})
        self.assertEqual(worker._paused, False)
Beispiel #5
0
    def test_worker_quarantine_unpausing_exits_quarantine(self):
        worker = yield self.createWorker(attached=False)
        yield worker.startService()
        self.assertTrue(worker.canStartBuild())
        self.assertIsNone(worker.quarantine_timer)

        # put worker into quarantine whilst unpaused.
        worker.putInQuarantine()
        self.assertFalse(worker._paused)
        self.assertFalse(worker.canStartBuild())

        # pause and unpause the worker
        worker.controlWorker(("worker", 1, "pause"), {"reason": "none"})
        self.assertFalse(worker.canStartBuild())
        worker.controlWorker(("worker", 1, "unpause"), {"reason": "none"})
        self.assertTrue(worker.canStartBuild())

        # put worker into quarantine whilst paused.
        worker.controlWorker(("worker", 1, "pause"), {"reason": "none"})
        worker.putInQuarantine()
        self.assertTrue(worker._paused)
        self.assertFalse(worker.canStartBuild())

        # unpause worker should start the build
        worker.controlWorker(("worker", 1, "unpause"), {"reason": "none"})
        self.assertFalse(worker._paused)
        self.assertTrue(worker.canStartBuild())
Beispiel #6
0
 def test_worker_actions_kill(self):
     worker = yield self.createWorker(attached=False)
     yield worker.startService()
     worker.controlWorker(("worker", 1, "kill"), {'reason': "none"})
     self.assertEqual(worker.conn, None)
Beispiel #7
0
 def test_worker_actions_stop(self):
     worker = yield self.createWorker(attached=False)
     yield worker.startService()
     worker.controlWorker(("worker", 1, "stop"), {'reason': "none"})
     self.assertEqual(worker._graceful, True)
Beispiel #8
0
 def test_worker_actions_kill(self):
     worker = yield self.createWorker(attached=False)
     yield worker.startService()
     worker.controlWorker(("worker", 1, "kill"), {'reason': "none"})
     self.assertEqual(worker.conn, None)
Beispiel #9
0
 def test_worker_actions_stop(self):
     worker = yield self.createWorker(attached=False)
     yield worker.startService()
     worker.controlWorker(("worker", 1, "stop"), {'reason': "none"})
     self.assertEqual(worker._graceful, True)