Bail out if any services fail to get paused.
This commit is contained in:
parent
f6a4025760
commit
5a7865a14a
|
@ -21,10 +21,15 @@ def get_action_parser(actions_yaml_path, action_name):
|
|||
|
||||
|
||||
def pause(args):
|
||||
"""Pause all the swift services."""
|
||||
# TODO: What if some services stop and others don't?
|
||||
"""Pause all the swift services.
|
||||
|
||||
@raises Exception if any services fail to stop
|
||||
"""
|
||||
for service in SWIFT_SVCS:
|
||||
service_pause(service)
|
||||
stopped = service_pause(service)
|
||||
if not stopped:
|
||||
raise Exception("{} didn't stop cleanly.".format(service))
|
||||
|
||||
|
||||
# A dictionary of all the defined actions to callables (which take
|
||||
# parsed arguments).
|
||||
|
|
|
@ -18,7 +18,12 @@ class PauseTestCase(CharmTestCase):
|
|||
def test_pauses_services(self):
|
||||
"""Pause action pauses all of the Swift services."""
|
||||
pause_calls = []
|
||||
self.service_pause.side_effect = pause_calls.append
|
||||
|
||||
def fake_service_pause(svc):
|
||||
pause_calls.append(svc)
|
||||
return True
|
||||
|
||||
self.service_pause.side_effect = fake_service_pause
|
||||
actions.actions.pause([])
|
||||
self.assertEqual(pause_calls, ['swift-account-auditor',
|
||||
'swift-account-reaper',
|
||||
|
@ -34,6 +39,26 @@ class PauseTestCase(CharmTestCase):
|
|||
'swift-object-server',
|
||||
'swift-object-updater'])
|
||||
|
||||
def test_bails_out_early_on_error(self):
|
||||
"""Pause action fails early if there are errors stopping a service."""
|
||||
pause_calls = []
|
||||
|
||||
def maybe_kill(svc):
|
||||
if svc == "swift-container-auditor":
|
||||
return False
|
||||
else:
|
||||
pause_calls.append(svc)
|
||||
return True
|
||||
|
||||
self.service_pause.side_effect = maybe_kill
|
||||
self.assertRaisesRegexp(
|
||||
Exception, "swift-container-auditor didn't stop cleanly.",
|
||||
actions.actions.pause, [])
|
||||
self.assertEqual(pause_calls, ['swift-account-auditor',
|
||||
'swift-account-reaper',
|
||||
'swift-account-replicator',
|
||||
'swift-account-server'])
|
||||
|
||||
|
||||
class GetActionParserTestCase(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue