本文整理汇总了Python中pymesos.MesosSchedulerDriver._master方法的典型用法代码示例。如果您正苦于以下问题:Python MesosSchedulerDriver._master方法的具体用法?Python MesosSchedulerDriver._master怎么用?Python MesosSchedulerDriver._master使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymesos.MesosSchedulerDriver
的用法示例。
在下文中一共展示了MesosSchedulerDriver._master方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gen_request
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _master [as 别名]
def test_gen_request(mocker):
mock_addr = 'mock_addr:1234'
sched = mocker.Mock()
framework = {
'failover_timeout': 0
}
master = mocker.Mock()
driver = MesosSchedulerDriver(sched, framework, master)
driver._master = mock_addr
req = driver.gen_request()
parser = HttpParser(0)
assert len(req) == parser.execute(req, len(req))
assert parser.is_headers_complete()
assert parser.get_method() == 'POST'
assert parser.get_url() == '/api/v1/scheduler'
assert parser.is_partial_body()
body = parser.recv_body()
result = json.loads(body.decode('utf-8'))
assert result['type'] == 'SUBSCRIBE'
assert result['subscribe'] == {
'framework_info': framework
}
headers = {k.upper(): v for k, v in parser.get_headers().items()}
assert headers == {
'HOST': mock_addr,
'CONTENT-TYPE': 'application/json',
'ACCEPT': 'application/json',
'CONNECTION': 'close',
'CONTENT-LENGTH': str(len(body))
}
assert parser.is_message_complete()
示例2: test_on_subscribed
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _master [as 别名]
def test_on_subscribed(mocker):
sched = mocker.Mock()
framework = {}
master = mocker.Mock()
driver = MesosSchedulerDriver(sched, framework, master)
driver.version = '1.0.0'
driver._started = True
driver._master = 'mock_addr:12345'
framework_id = {
'value': str(uuid.uuid4())
}
event = {
'type': 'SUBSCRIBED',
'subscribed': {
'framework_id': framework_id
}
}
driver.on_event(event)
sched.registered.assert_called_once_with(driver, framework_id, {
'hostname': 'mock_addr',
'port': 12345,
'version': '1.0.0'
})