Beispiel #1
0
    def test_killTask_during_runner_initialize(self):
        proxy_driver = ProxyDriver()

        task = make_task(HELLO_WORLD_MTI)

        with temporary_dir() as td:
            te = FastThermosExecutor(runner_provider=make_provider(td),
                                     sandbox_provider=SlowSandboxProvider)
            te.launchTask(proxy_driver, task)
            te.sandbox_initialized.wait()
            te.killTask(proxy_driver,
                        mesos_pb.TaskID(value=task.task_id.value))
            assert te.runner_aborted.is_set()
            assert not te.sandbox_created.is_set()

            # we've simulated a "slow" initialization by blocking it until the killTask was sent - so now,
            # trigger the initialization to complete
            te._sandbox._init_start.set()

            # however, wait on the runner to definitely finish its initialization before continuing
            # (otherwise, this function races ahead too fast)
            te._sandbox._init_done.wait()
            te.sandbox_created.wait(1.0)
            assert te.sandbox_initialized.is_set()
            assert te.sandbox_created.is_set()

            proxy_driver._stop_event.wait(timeout=1.0)
            assert proxy_driver._stop_event.is_set()

            updates = proxy_driver.method_calls['sendStatusUpdate']
            assert len(updates) == 2
            assert updates[-1][0][0].state == mesos_pb.TASK_KILLED
Beispiel #2
0
    def test_killTask(self):
        proxy_driver = ProxyDriver()

        with temporary_dir() as checkpoint_root:
            _, executor = make_executor(proxy_driver, checkpoint_root,
                                        SLEEP60_MTI)
            # send two, expect at most one delivered
            executor.killTask(proxy_driver,
                              mesos_pb.TaskID(value='sleep60-001'))
            executor.killTask(proxy_driver,
                              mesos_pb.TaskID(value='sleep60-001'))
            executor.terminated.wait()

        updates = proxy_driver.method_calls['sendStatusUpdate']
        assert len(updates) == 3
        assert updates[-1][0][0].state == mesos_pb.TASK_KILLED
Beispiel #3
0
 def killTask(self, task):
     jid = self.taskIdToJobId.get(task.id)
     if jid:
         tid = mesos_pb2.TaskID()
         tid.value = "%s:%s:%s" % (jid, task.id, task.tried)
         self.driver.killTask(tid)
     else:
         logger.warning("can not kill %s because of job had gone", task)
Beispiel #4
0
 def killTask(self, job_id, task_id, tried):
     tid = mesos_pb2.TaskID()
     tid.value = "%s:%s:%s" % (job_id, task_id, tried)
     self.driver.killTask(tid)