本文整理匯總了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'
})