本文整理汇总了Python中unittest_support.create_component_pool_for_one_host函数的典型用法代码示例。如果您正苦于以下问题:Python create_component_pool_for_one_host函数的具体用法?Python create_component_pool_for_one_host怎么用?Python create_component_pool_for_one_host使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_component_pool_for_one_host函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_stop_services_then_reboot_then_start_services
def test_should_stop_services_then_reboot_then_start_services(self,
dump_plan,
state_reboot,
state_metalogic):
components = create_component_pool_for_one_host(add_services=True)
state_reboot.return_value = components
state_metalogic.return_value = state_reboot.return_value
reboot(uris=["host://foobar42"])
dump_plan_calls = dump_plan.call_args_list
self.assertEqual(len(dump_plan_calls), 1, "More than one plan for reboot was serialized! (potential overwrite)")
dump_plan_call = dump_plan_calls[0]
dump_plan_call_name, dump_plan_args = dump_plan_call[0]
actual_reboot_plan = dump_plan_args
# Careful, there's no missing comma here (string concatenation)
expected_actions = [
Action("update", "host://foobar42", "state", "rebooted",
kwargs={"reboot_required": True, "upgrade_packages": False},
preconditions=[
TargetState("service://foobar42/bazservice", "state", "down"),
TargetState("service://foobar42/barservice", "state", "down")]),
Action("start", "service://foobar42/barservice", "state", "up",
preconditions=[
TargetState("host://foobar42", "state", "rebooted")]),
Action("start", "service://foobar42/bazservice", "state", "up",
preconditions=[
TargetState("host://foobar42", "state", "rebooted")]),
Action("stop", "service://foobar42/barservice", "state", "down"),
Action("stop", "service://foobar42/bazservice", "state", "down")
]
assert_actual_plan_matches_expected_actions(self, expected_actions, actual_reboot_plan)
示例2: test_should_render_update_needed_when_host_is_not_uptodate
def test_should_render_update_needed_when_host_is_not_uptodate(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPDATE_NEEDED)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in(' u host uptodate', info_matrix)
示例3: test_should_update_host_when_host_is_not_uptodate
def test_should_update_host_when_host_is_not_uptodate(self, components, action_plan, apply_instructions, dump_action_plan, action):
components.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPDATE_NEEDED,
next_artefacts_present=True)
compare_versions()
action.assert_called_with('update', 'host://foobar42', 'state', 'uptodate')
示例4: test_should_stop_all_services_without_preconditions
def test_should_stop_all_services_without_preconditions(self, state):
state.return_value = create_component_pool_for_one_host(add_services=True)
stop_plan = yadtshell._reboot.create_plan_to_stop_all_services_on(["host://foobar42"])
for stop_action in stop_plan.list_actions:
self.assertEqual(stop_action.cmd, "stop")
self.assertEqual(stop_action.preconditions, set([]))
示例5: test_should_not_update_anything_when_hosts_are_uptodate
def test_should_not_update_anything_when_hosts_are_uptodate(self, components, action_plan, apply_instructions, dump_action_plan):
components.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPTODATE)
compare_versions()
dump_action_plan.assert_called_with('update', action_plan.return_value)
action_plan.assert_called_with('start', set([]))
示例6: test_should_render_reboot_now
def test_should_render_reboot_now(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPDATE_NEEDED,
host_reboot_now=True)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in(' R reboot required', info_matrix)
示例7: test_should_render_uptodate_when_host_is_uptodate
def test_should_render_uptodate_when_host_is_uptodate(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPTODATE)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in(' | host uptodate', info_matrix)
self.assert_in('1/1 hosts uptodate', info_matrix)
示例8: test_should_stop_all_services
def test_should_stop_all_services(self, state):
state.return_value = create_component_pool_for_one_host(add_services=True)
stop_plan = yadtshell._reboot.create_plan_to_stop_all_services_on(["host://foobar42"])
self.assertEqual(stop_plan.dump(),
'stop [2 items, workers *undefined*, 0 errors tolerated]:\n'
' stop the service://foobar42/barservice, set state to "down"\n'
' stop the service://foobar42/bazservice, set state to "down"\n')
示例9: test_should_render_missing_artefact_problems
def test_should_render_missing_artefact_problems(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
missing_artefact=True)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in(
"config problem: missing artefact://foobar42/missing",
info_matrix)
示例10: test_should_render_cache_in_red_when_it_is_old
def test_should_render_cache_in_red_when_it_is_old(self,
component_pool,
cache_age):
cache_age.return_value = 900
component_pool.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPDATE_NEEDED)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in("queried ${BG_RED}${WHITE}${BOLD} 900 ${NORMAL} seconds ago",
info_matrix)
示例11: test_should_start_services_unconditionally_when_other_host_is_rebooted
def test_should_start_services_unconditionally_when_other_host_is_rebooted(self, state):
components = create_component_pool_for_one_host(add_services=True)
state.return_value = components
start_plan = yadtshell._reboot.create_plan_to_start_services_after_rebooting(["service://foobar42/barservice", "service://foobar42/bazservice"],
["host://foobar43"], components)
self.assertEqual(start_plan.dump(),
'start [2 items, workers *undefined*, 0 errors tolerated]:\n'
' start the service://foobar42/barservice, set state to "up"\n'
' start the service://foobar42/bazservice, set state to "up"\n')
示例12: test_should_render_stopped_services
def test_should_render_stopped_services(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPTODATE,
add_services=True,
service_state=yadtshell.settings.DOWN)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in(' O service barservice', info_matrix)
self.assert_in(' O service bazservice', info_matrix)
示例13: test_should_render_artefact_problems_when_state_is_not_up
def test_should_render_artefact_problems_when_state_is_not_up(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
host_state=yadtshell.settings.UPDATE_NEEDED,
artefact_state=yadtshell.settings.MISSING)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in('''
problems
${RED}${BOLD} missing${NORMAL} artefact://foobar42/yit/0:0.0.1
${RED}${BOLD} missing${NORMAL} artefact://foobar42/foo/0:0.0.0
''', info_matrix)
示例14: test_should_render_host_locked_by_me
def test_should_render_host_locked_by_me(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(
host_locked_by_me=True)
info_matrix = self._call_info_and_render_output_to_string()
self.assert_in('''
${BG_YELLOW}${BOLD}
foobar42 is locked by me
Reason: yes we can (lock the host)
${NORMAL}
''', info_matrix)
self.assert_in(' l host access', info_matrix)
示例15: test_should_render_readonly_services
def test_should_render_readonly_services(self,
component_pool):
component_pool.return_value = create_component_pool_for_one_host(add_readonly_services=True)
info_matrix = self._call_info_and_render_output_to_string()
rendered_ro_services = '''
foobar42
| readonly-service ro_up (needed by me you)
O readonly-service ro_down (needed by something a_dog)
'''
self.assert_in(rendered_ro_services,
info_matrix)