def test___performServiceAction_logs_error_if_action_fails(self):
service = make_fake_service(SERVICE_STATE.ON)
service_monitor = self.make_service_monitor()
mock_execSystemDServiceAction = self.patch(
service_monitor, "_execSystemDServiceAction")
error_output = factory.make_name("error")
mock_execSystemDServiceAction.return_value = (1, "", error_output)
action = factory.make_name("action")
with FakeLogger(
"maas.service_monitor", level=logging.ERROR) as maaslog:
with ExpectedException(ServiceActionError):
yield service_monitor._performServiceAction(service, action)
self.assertDocTestMatches(
"Service '%s' failed to %s: %s" % (
service.name, action, error_output),
maaslog.output)
评论列表
文章目录