Example #1
0
    def test_basic_as_job(self):
        proxy_driver = ProxyDriver()

        with temporary_dir() as tempdir:
            te = ThermosExecutor(runner_provider=make_provider(tempdir),
                                 sandbox_provider=DefaultTestSandboxProvider)
            te.launchTask(proxy_driver,
                          make_task(MESOS_JOB(task=HELLO_WORLD), instanceId=0))
            te.runner_started.wait()
            while te._status_manager is None:
                time.sleep(0.1)
            te.terminated.wait()
            tm = TaskMonitor(TaskPath(root=tempdir),
                             task_id=HELLO_WORLD_TASK_ID)
            runner_state = tm.get_state()

        assert 'hello_world_hello_world-001' in runner_state.processes, (
            'Could not find processes, got: %s' %
            ' '.join(runner_state.processes))
        updates = proxy_driver.method_calls['sendStatusUpdate']
        assert len(updates) == 3
        status_updates = [arg_tuple[0][0] for arg_tuple in updates]
        assert status_updates[0].state == mesos_pb.TASK_STARTING
        assert status_updates[1].state == mesos_pb.TASK_RUNNING
        assert status_updates[2].state == mesos_pb.TASK_FINISHED
Example #2
0
    def test_launchTask_deserialization_fail(self):
        proxy_driver = ProxyDriver()

        task_info = mesos_pb.TaskInfo()
        task_info.name = task_info.task_id.value = 'broken'
        task_info.data = serialize(
            AssignedTask(task=TaskConfig(executorConfig=ExecutorConfig(
                name=AURORA_EXECUTOR_NAME, data='garbage'))))

        te = ThermosExecutor(runner_provider=make_provider(safe_mkdtemp()),
                             sandbox_provider=DefaultTestSandboxProvider)
        te.launchTask(proxy_driver, task_info)

        updates = proxy_driver.method_calls['sendStatusUpdate']
        assert len(updates) == 1
        assert updates[0][0][0].state == mesos_pb.TASK_FAILED
  def test_launchTask_deserialization_fail(self):
    proxy_driver = ProxyDriver()

    task_info = mesos_pb.TaskInfo()
    task_info.name = task_info.task_id.value = 'broken'
    task_info.data = serialize(AssignedTask(task=TaskConfig(executorConfig=ExecutorConfig(
        name=AURORA_EXECUTOR_NAME,
        data='garbage'))))

    te = ThermosExecutor(
        runner_provider=make_provider(safe_mkdtemp()),
        sandbox_provider=DefaultTestSandboxProvider)
    te.launchTask(proxy_driver, task_info)

    updates = proxy_driver.method_calls['sendStatusUpdate']
    assert len(updates) == 1
    assert updates[0][0][0].state == mesos_pb.TASK_FAILED
  def test_basic(self):
    proxy_driver = ProxyDriver()

    with temporary_dir() as tempdir:
      te = ThermosExecutor(
          runner_provider=make_provider(tempdir),
          sandbox_provider=DefaultTestSandboxProvider)
      te.launchTask(proxy_driver, make_task(HELLO_WORLD_MTI))
      te.terminated.wait()
      tm = TaskMonitor(TaskPath(root=tempdir), task_id=HELLO_WORLD_TASK_ID)
      runner_state = tm.get_state()

    assert 'hello_world_hello_world-001' in runner_state.processes, (
      'Could not find processes, got: %s' % ' '.join(runner_state.processes))

    updates = proxy_driver.method_calls['sendStatusUpdate']
    assert len(updates) == 3
    status_updates = [arg_tuple[0][0] for arg_tuple in updates]
    assert status_updates[0].state == mesos_pb.TASK_STARTING
    assert status_updates[1].state == mesos_pb.TASK_RUNNING
    assert status_updates[2].state == mesos_pb.TASK_FINISHED