Пример #1
0
def test_scheduler_event_handlers(mocker):
    sched = mocker.Mock()
    driver = mocker.Mock()
    proxy = SchedulerProxy(sched)

    proxy.executorLost(driver, mesos_pb2.ExecutorInfo(),
                       mesos_pb2.ExecutorID(), 1)
    proxy.frameworkMessage(driver, mesos_pb2.ExecutorID(),
                           mesos_pb2.SlaveID(), 'message')
    proxy.offerRescinded(driver, mesos_pb2.OfferID())
    proxy.registered(driver, mesos_pb2.FrameworkID(), mesos_pb2.MasterInfo())
    proxy.resourceOffers(driver, [mesos_pb2.Offer(), mesos_pb2.Offer()])
    proxy.slaveLost(driver, mesos_pb2.SlaveID())
    proxy.statusUpdate(driver, mesos_pb2.TaskStatus())
    proxy.reregistered(driver, mesos_pb2.MasterInfo())
    proxy.error(driver, 'message')
    proxy.disconnected(driver)

    sched.on_executor_lost.assert_called_once()
    sched.on_message.assert_called_once()
    sched.on_rescinded.assert_called_once()
    sched.on_registered.assert_called_once()
    sched.on_offers.assert_called_once()
    sched.on_slave_lost.assert_called_once()
    sched.on_update.assert_called_once()
    sched.on_reregistered.assert_called_once()
    sched.on_error.assert_called_once()
    sched.on_disconnected.assert_called_once()
Пример #2
0
    def _query_slave(self, task_id):
        assert task_id in self._mesos_slaves

        log.info('Querying MySQL slave %s for its log position (epoch=%s)' %
                 (str((task_id, self._mesos_slaves[task_id])), self._epoch))

        # Because the elector re-sends messages, it's necessary to use the epoch to differentiate
        # responses for each election.
        self._driver.sendFrameworkMessage(
            mesos_pb2.ExecutorID(value=task_id),
            mesos_pb2.SlaveID(value=self._mesos_slaves[task_id]),
            str(self._epoch)
        )  # Send the slave the epoch so it can be included in the response.
Пример #3
0
    def __init__(self, executor):
        Process.__init__(self, 'executor')
        self.executor = executor

        env = os.environ
        self.local = bool(env.get('MESOS_LOCAL'))
        slave_pid = env.get('MESOS_SLAVE_PID')
        assert slave_pid, 'expecting MESOS_SLAVE_PID in environment'
        self.slave = UPID(slave_pid)
        self.framework_id = mesos_pb2.FrameworkID()
        self.framework_id.value = env.get('MESOS_FRAMEWORK_ID')
        self.executor_id = mesos_pb2.ExecutorID()
        self.executor_id.value = env.get('MESOS_EXECUTOR_ID')
        self.workDirectory = env.get('MESOS_DIRECTORY')
 def setUp(self):
     self.framework_id = mesos_pb2.FrameworkID(value=self.FRAMEWORK_ID)
     self.framework_info = mesos_pb2.FrameworkInfo(
         user='******',
         name='fake_framework_name',
     )
     self.command_info = mesos_pb2.CommandInfo(value='fake-command')
     self.executor_id = mesos_pb2.ExecutorID(value='fake-executor-id')
     self.executor_info = mesos_pb2.ExecutorInfo(
         executor_id=self.executor_id,
         framework_id=self.framework_id,
         command=self.command_info,
     )
     self.slave_id = mesos_pb2.SlaveID(value='fake-slave-id')
     self.offer_id = mesos_pb2.OfferID(value='1')