Esempio n. 1
0
def test_mesos_executor_driver_init():
  context = Context()
  context.start()

  # spawn slave
  slave = MockSlave()
  context.spawn(slave)

  os.environ['MESOS_SLAVE_PID'] = str(slave.pid)

  executor = Executor()
  driver = MesosExecutorDriver(executor, context=context)
  assert driver.start() == mesos.DRIVER_RUNNING
  assert driver.stop() == mesos.DRIVER_STOPPED
  assert driver.join() == mesos.DRIVER_STOPPED

  context.stop()
Esempio n. 2
0
def test_mesos_executor_driver_init():
    context = Context()
    context.start()

    # spawn slave
    slave = MockSlave()
    context.spawn(slave)

    os.environ['MESOS_SLAVE_PID'] = str(slave.pid)

    executor = Executor()
    driver = MesosExecutorDriver(executor, context=context)
    assert driver.start() == mesos.DRIVER_RUNNING
    assert driver.stop() == mesos.DRIVER_STOPPED
    assert driver.join() == mesos.DRIVER_STOPPED

    context.stop()
Esempio n. 3
0
def test_mesos_executor_register():
  context = Context()
  context.start()

  # spawn slave
  slave = MockSlave()
  context.spawn(slave)

  os.environ['MESOS_SLAVE_PID'] = str(slave.pid)

  executor = mock.MagicMock()
  executor.registered = mock.MagicMock()

  driver = MesosExecutorDriver(executor, context=context)
  assert driver.start() == mesos.DRIVER_RUNNING

  command_info = mesos.CommandInfo(value='wat')
  framework_id = mesos.FrameworkID(value='fake_framework_id')
  executor_id = mesos.ExecutorID(value='fake_executor_id')
  executor_info = mesos.ExecutorInfo(
    executor_id=executor_id,
    framework_id=framework_id,
    command=command_info
  )
  framework_info = mesos.FrameworkInfo(user='******', name='fake_framework_name')

  slave.send_registered(
    driver.executor_process.pid,
    executor_info,
    framework_id,
    framework_info
  )

  driver.executor_process.connected.wait(timeout=1)
  assert driver.executor_process.connected.is_set()

  time.sleep(0.5)  # We should wait a small amount of time
  executor.registered.assert_called_with(driver, executor_info, framework_info, slave.slave_info)

  assert driver.stop() == mesos.DRIVER_STOPPED

  context.stop()
Esempio n. 4
0
def test_mesos_executor_register():
    context = Context()
    context.start()

    # spawn slave
    slave = MockSlave()
    context.spawn(slave)

    os.environ['MESOS_SLAVE_PID'] = str(slave.pid)

    executor = mock.MagicMock()
    executor.registered = mock.MagicMock()

    driver = MesosExecutorDriver(executor, context=context)
    assert driver.start() == mesos.DRIVER_RUNNING

    command_info = mesos.CommandInfo(value='wat')
    framework_id = mesos.FrameworkID(value='fake_framework_id')
    executor_id = mesos.ExecutorID(value='fake_executor_id')
    executor_info = mesos.ExecutorInfo(executor_id=executor_id,
                                       framework_id=framework_id,
                                       command=command_info)
    framework_info = mesos.FrameworkInfo(user='******',
                                         name='fake_framework_name')

    slave.send_registered(driver.executor_process.pid, executor_info,
                          framework_id, framework_info)

    driver.executor_process.connected.wait(timeout=1)
    assert driver.executor_process.connected.is_set()
    executor.registered.assert_called_with(driver, executor_info,
                                           framework_info, slave.slave_info)

    assert driver.stop() == mesos.DRIVER_STOPPED

    context.stop()