本文整理汇总了Python中apache.aurora.admin.host_maintenance.HostMaintenance.perform_maintenance方法的典型用法代码示例。如果您正苦于以下问题:Python HostMaintenance.perform_maintenance方法的具体用法?Python HostMaintenance.perform_maintenance怎么用?Python HostMaintenance.perform_maintenance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apache.aurora.admin.host_maintenance.HostMaintenance
的用法示例。
在下文中一共展示了HostMaintenance.perform_maintenance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_perform_maintenance_partial_sla_failure
# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import perform_maintenance [as 别名]
def test_perform_maintenance_partial_sla_failure(self, mock_check_sla, mock_start_maintenance,
mock_drain_hosts, mock_operate_on_hosts, mock_complete_maintenance):
mock_callback = mock.Mock()
failed_host = 'us-west-001.example.com'
mock_check_sla.return_value = set([failed_host])
drained_hosts = set(TEST_HOSTNAMES) - set([failed_host])
maintenance = HostMaintenance(DEFAULT_CLUSTER, 'quiet')
with temporary_file() as fp:
with group_by_rack():
maintenance.perform_maintenance(
TEST_HOSTNAMES,
callback=mock_callback,
grouping_function='by_rack',
output_file=fp.name)
with open(fp.name, 'r') as fpr:
content = fpr.read()
assert failed_host in content
mock_start_maintenance.assert_called_once_with(TEST_HOSTNAMES)
assert mock_check_sla.call_count == 1
assert mock_drain_hosts.call_count == 1
assert mock_drain_hosts.call_args_list == [mock.call(Hosts(drained_hosts))]
assert mock_operate_on_hosts.call_count == 1
assert mock_operate_on_hosts.call_args_list == [
mock.call(Hosts(drained_hosts), mock_callback)]
assert mock_complete_maintenance.call_count == 2
assert mock_complete_maintenance.call_args_list == [
mock.call(Hosts(set([failed_host]))), mock.call(Hosts(drained_hosts))]
示例2: test_perform_maintenance
# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import perform_maintenance [as 别名]
def test_perform_maintenance(self, mock_check_sla, mock_start_maintenance, mock_drain_hosts):
mock_check_sla.return_value = set()
mock_start_maintenance.return_value = TEST_HOSTNAMES
maintenance = HostMaintenance(DEFAULT_CLUSTER, 'quiet')
maintenance.perform_maintenance(TEST_HOSTNAMES)
mock_start_maintenance.assert_called_once_with(TEST_HOSTNAMES)
assert mock_check_sla.call_count == 3
assert mock_drain_hosts.call_count == 3
assert mock_drain_hosts.call_args_list == [
mock.call(Hosts(set([hostname]))) for hostname in TEST_HOSTNAMES]
示例3: test_perform_maintenance
# 需要导入模块: from apache.aurora.admin.host_maintenance import HostMaintenance [as 别名]
# 或者: from apache.aurora.admin.host_maintenance.HostMaintenance import perform_maintenance [as 别名]
def test_perform_maintenance(self, mock_operate_on_hosts, mock_check_sla, mock_start_maintenance,
mock_drain_hosts):
mock_callback = mock.Mock()
mock_check_sla.return_value = set()
mock_start_maintenance.return_value = TEST_HOSTNAMES
drain_hosts_results = [set() for _ in TEST_HOSTNAMES]
drain_hosts_results[0] = set([TEST_HOSTNAMES[0]])
def drain_hosts_result(*args):
return drain_hosts_results.pop(0)
mock_drain_hosts.side_effect = drain_hosts_result
maintenance = HostMaintenance(DEFAULT_CLUSTER, 'quiet')
maintenance.perform_maintenance(TEST_HOSTNAMES, callback=mock_callback)
mock_start_maintenance.assert_called_once_with(TEST_HOSTNAMES)
assert mock_check_sla.call_count == 3
assert mock_drain_hosts.call_count == 3
assert mock_drain_hosts.call_args_list == [
mock.call(Hosts(set([hostname]))) for hostname in TEST_HOSTNAMES]
assert mock_operate_on_hosts.call_count == 3
assert mock_operate_on_hosts.call_args_list == [mock.call(set(), mock_callback)] + [
mock.call(set([hostname]), mock_callback) for hostname in TEST_HOSTNAMES[1:]]