Пример #1
0
def test_on_task_updated(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    task_info = {
        'task_id': {
            'value': str(uuid.uuid4())
        },
        'framework_id': {
            'value': str(uuid.uuid4())
        },
        'agent_id': {
            'value': str(uuid.uuid4())
        },
        'executor_id': {
            'value': str(uuid.uuid4())
        },
        'state': 'TASK_RUNNING'
    }
    event = {
        'type': 'TASK_UPDATED',
        'task_updated': task_info
    }
    driver.on_event(event)
    operator.taskUpdated.assert_called_once_with(task_info)
    operator.taskAdded.assert_not_called()
Пример #2
0
def test_on_framework_removed(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    framework_info = {
        'capabilities': [{
            'type': 'RESERVATION_REFINEMENT'
        }],
        'checkpoint': 'true',
        'failover_timeout': 0,
        'id': {
            'value': str(uuid.uuid4())
        },
        'name': 'inverse-offer-example-framework',
        'role': '*',
        'user': '******'
    }
    event = {
        'type': 'FRAMEWORK_REMOVED',
        'framework_removed': {
            'framework_info': framework_info
        }
    }
    driver.on_event(event)
    operator.frameworkRemoved.assert_called_once_with(framework_info)
Пример #3
0
def test_on_task_updated(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    task_info = {
        'task_id': {
            'value': str(uuid.uuid4())
        },
        'framework_id': {
            'value': str(uuid.uuid4())
        },
        'agent_id': {
            'value': str(uuid.uuid4())
        },
        'executor_id': {
            'value': str(uuid.uuid4())
        },
        'state': 'TASK_RUNNING'
    }
    event = {
        'type': 'TASK_UPDATED',
        'task_updated': task_info
    }
    driver.on_event(event)
    operator.taskUpdated.assert_called_once_with(task_info)
    operator.taskAdded.assert_not_called()
Пример #4
0
def test_on_framework_removed(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    framework_info = {
        'capabilities': [
            {
                'type': 'RESERVATION_REFINEMENT'
            }
        ],
        'checkpoint': 'true',
        'failover_timeout': 0,
        'id': {
            'value': str(uuid.uuid4())
        },
        'name': 'inverse-offer-example-framework',
        'role': '*',
        'user': '******'
    }
    event = {
        'type': 'FRAMEWORK_REMOVED',
        'framework_removed': {
            'framework_info': framework_info
        }
    }
    driver.on_event(event)
    operator.frameworkRemoved.assert_called_once_with(framework_info)
Пример #5
0
def test_on_agent_removed(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    agent_id = str(uuid.uuid4())
    event = {
        'type': 'AGENT_REMOVED',
        'agent_removed': {
            'agent_id': {
                'value': agent_id
            }
        }
    }
    driver.on_event(event)
    operator.agentRemoved.assert_called_once_with(agent_id)
Пример #6
0
def test_on_agent_removed(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    agent_id = str(uuid.uuid4())
    event = {
        'type': 'AGENT_REMOVED',
        'agent_removed': {
            'agent_id': {
                'value': agent_id
            }
        }
    }
    driver.on_event(event)
    operator.agentRemoved.assert_called_once_with(agent_id)
Пример #7
0
def test_on_agent_added(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    agent_info = {
        'active': 'true',
        'agent_info': {
            'hostname': '172.31.2.24',
            'id': {
                'value': str(uuid.uuid4())
            },
            'port': 5051,
            'resources': [],
        },
        'allocated_resources': [],
        'capabilities': [
            {
                'type': 'MULTI_ROLE'
            },
            {
                'type': 'HIERARCHICAL_ROLE'
            },
            {
                'type': 'RESERVATION_REFINEMENT'
            }
        ],
        'offered_resources': [],
        'pid': 'slave(1)@172.31.2.24:5051',
        'registered_time': {
            'nanoseconds': 1500993262264135000
        },
        'reregistered_time': {
            'nanoseconds': 1500993263019321000
        },
        'total_resources': [],
        'version': '1.4.0'
    }
    event = {
        'type': 'AGENT_ADDED',
        'agent_added': {
            'agent': agent_info
        }
    }
    driver.on_event(event)
    operator.agentAdded.assert_called_once_with(agent_info)
Пример #8
0
def test_on_agent_added(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    agent_info = {
        'active': 'true',
        'agent_info': {
            'hostname': '172.31.2.24',
            'id': {
                'value': str(uuid.uuid4())
            },
            'port': 5051,
            'resources': [],
        },
        'allocated_resources': [],
        'capabilities': [
            {
                'type': 'MULTI_ROLE'
            },
            {
                'type': 'HIERARCHICAL_ROLE'
            },
            {
                'type': 'RESERVATION_REFINEMENT'
            }
        ],
        'offered_resources': [],
        'pid': 'slave(1)@172.31.2.24:5051',
        'registered_time': {
            'nanoseconds': 1500993262264135000
        },
        'reregistered_time': {
            'nanoseconds': 1500993263019321000
        },
        'total_resources': [],
        'version': '1.4.0'
    }
    event = {
        'type': 'AGENT_ADDED',
        'agent_added': {
            'agent': agent_info
        }
    }
    driver.on_event(event)
    operator.agentAdded.assert_called_once_with(agent_info)
Пример #9
0
def test_on_framework_updated(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    framework_info = {
        'active': 'true',
        'allocated_resources': [],
        'connected': 'true',
        'framework_info': {
            'capabilities': [
                {
                    'type': 'RESERVATION_REFINEMENT'
                }
            ],
            'checkpoint': 'true',
            'failover_timeout': 0,
            'id': {
                'value': str(uuid.uuid4())
            },
            'name': 'inverse-offer-example-framework',
            'role': '*',
            'user': '******'
        },
        'inverse_offers': [],
        'recovered': 'false',
        'registered_time': {
            'nanoseconds': 1501191957829317120
        },
        'reregistered_time': {
            'nanoseconds': 1501191957829317120
        }
    }
    event = {
        'type': 'FRAMEWORK_UPDATED',
        'framework_updated': {
            'framework': framework_info
        }
    }
    driver.on_event(event)
    operator.frameworkUpdated.assert_called_once_with(framework_info)
    operator.frameworkAdded.assert_not_called()
Пример #10
0
def test_on_framework_updated(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    framework_info = {
        'active': 'true',
        'allocated_resources': [],
        'connected': 'true',
        'framework_info': {
            'capabilities': [
                {
                    'type': 'RESERVATION_REFINEMENT'
                }
            ],
            'checkpoint': 'true',
            'failover_timeout': 0,
            'id': {
                'value': str(uuid.uuid4())
            },
            'name': 'inverse-offer-example-framework',
            'role': '*',
            'user': '******'
        },
        'inverse_offers': [],
        'recovered': 'false',
        'registered_time': {
            'nanoseconds': 1501191957829317120
        },
        'reregistered_time': {
            'nanoseconds': 1501191957829317120
        }
    }
    event = {
        'type': 'FRAMEWORK_UPDATED',
        'framework_updated': {
            'framework': framework_info
        }
    }
    driver.on_event(event)
    operator.frameworkUpdated.assert_called_once_with(framework_info)
    operator.frameworkAdded.assert_not_called()
Пример #11
0
def test_on_task_added(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    task_info = {
        'name': 'dummy-task',
        'task_id': {'value': str(uuid.uuid4())},
        'agent_id': {'value': str(uuid.uuid4())},
        'command': {'value': 'sleep', 'arguments': ['100'], }
    }
    event = {
        'type': 'TASK_ADDED',
        'task_added': {
            'task': task_info
        }
    }
    driver.on_event(event)
    operator.taskAdded.assert_called_once_with(task_info)
    operator.taskUpdated.assert_not_called()
Пример #12
0
def test_on_task_added(mocker):
    operator = mocker.Mock()
    master = mocker.Mock()
    driver = MesosOperatorMasterDriver(master, operator)
    driver._started = True
    task_info = {
        'name': 'dummy-task',
        'task_id': {'value': str(uuid.uuid4())},
        'agent_id': {'value': str(uuid.uuid4())},
        'command': {'value': 'sleep', 'arguments': ['100'], }
    }
    event = {
        'type': 'TASK_ADDED',
        'task_added': {
            'task': task_info
        }
    }
    driver.on_event(event)
    operator.taskAdded.assert_called_once_with(task_info)
    operator.taskUpdated.assert_not_called()