def test_acknowledge_status_update(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    agent_id = dict(value=str(uuid.uuid4()))
    task_id = dict(value=str(uuid.uuid4()))
    uid = encode_data(uuid.uuid4().bytes)
    status = {'agent_id': agent_id, 'task_id': task_id, 'uuid': uid}
    driver.acknowledgeStatusUpdate(status)
    driver._send.assert_not_called()
    driver._stream_id = 'a-stream-id'
    driver.acknowledgeStatusUpdate(status)
    driver._send.assert_called_once_with({
        'type': 'ACKNOWLEDGE',
        'framework_id': {
            'value': ID
        },
        'acknowledge': {
            'agent_id': agent_id,
            'task_id': task_id,
            'uuid': uid
        }
    })
Example #2
0
    def statusUpdate(self, driver: MesosSchedulerDriver, update: Dict):
        if self.frozen:
            return

        # update tasks
        task_id = update['task_id']['value']
        self.log('Task {} is in state {}'.format(
            task_id,
            update['state'],
        ), )

        task_params = self.task_store.update_task(
            task_id,
            mesos_task_state=update['state'],
        )

        if task_params.mesos_task_state not in LIVE_TASK_STATES:
            with self.constraint_state_lock:
                update_constraint_state(
                    task_params.offer,
                    self.constraints,
                    self.constraint_state,
                    step=-1,
                )

        driver.acknowledgeStatusUpdate(update)
        self.kill_tasks_if_necessary(driver)
Example #3
0
def test_acknowledge_status_update(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    agent_id = dict(value=str(uuid.uuid4()))
    task_id = dict(value=str(uuid.uuid4()))
    uid = encode_data(uuid.uuid4().bytes)
    status = {
        'agent_id': agent_id,
        'task_id': task_id,
        'uuid': uid
    }
    driver.acknowledgeStatusUpdate(status)
    driver._send.assert_called_once_with({
        'type': 'ACKNOWLEDGE',
        'framework_id': {
            'value': ID
        },
        'acknowledge': {
            'agent_id': agent_id,
            'task_id': task_id,
            'uuid': uid
        }
    })