Fix service list.
This commit is contained in:
parent
b383a1d1e7
commit
62e449c2b2
@ -6,7 +6,7 @@ import os
|
|||||||
from charmhelpers.core.host import service_pause, service_resume
|
from charmhelpers.core.host import service_pause, service_resume
|
||||||
from charmhelpers.core.hookenv import action_fail, status_set
|
from charmhelpers.core.hookenv import action_fail, status_set
|
||||||
|
|
||||||
from hooks.glance_utils import SERVICES
|
from hooks.glance_utils import services
|
||||||
|
|
||||||
|
|
||||||
def pause(args):
|
def pause(args):
|
||||||
@ -14,7 +14,7 @@ def pause(args):
|
|||||||
|
|
||||||
@raises Exception if any services fail to stop
|
@raises Exception if any services fail to stop
|
||||||
"""
|
"""
|
||||||
for service in SERVICES:
|
for service in services():
|
||||||
stopped = service_pause(service)
|
stopped = service_pause(service)
|
||||||
if not stopped:
|
if not stopped:
|
||||||
raise Exception("{} didn't stop cleanly.".format(service))
|
raise Exception("{} didn't stop cleanly.".format(service))
|
||||||
@ -27,7 +27,7 @@ def resume(args):
|
|||||||
|
|
||||||
@raises Exception if any services fail to start
|
@raises Exception if any services fail to start
|
||||||
"""
|
"""
|
||||||
for service in SERVICES:
|
for service in services():
|
||||||
started = service_resume(service)
|
started = service_resume(service)
|
||||||
if not started:
|
if not started:
|
||||||
raise Exception("{} didn't start cleanly.".format(service))
|
raise Exception("{} didn't start cleanly.".format(service))
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
from hooks import glance_contexts
|
from hooks import glance_contexts
|
||||||
|
|
||||||
@ -294,11 +295,8 @@ def restart_map():
|
|||||||
|
|
||||||
|
|
||||||
def services():
|
def services():
|
||||||
''' Returns a list of services associate with this charm '''
|
''' Returns a list of (unique) services associate with this charm '''
|
||||||
_services = []
|
return list(set(chain(*restart_map().values())))
|
||||||
for v in restart_map().values():
|
|
||||||
_services = _services + v
|
|
||||||
return list(set(_services))
|
|
||||||
|
|
||||||
|
|
||||||
def setup_ipv6():
|
def setup_ipv6():
|
||||||
|
@ -28,8 +28,6 @@ class GlanceBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
relations, service status, endpoint service catalog, create and
|
relations, service status, endpoint service catalog, create and
|
||||||
delete new image."""
|
delete new image."""
|
||||||
|
|
||||||
SERVICES = ('glance-api', 'glance-registry')
|
|
||||||
|
|
||||||
def __init__(self, series=None, openstack=None, source=None, git=False,
|
def __init__(self, series=None, openstack=None, source=None, git=False,
|
||||||
stable=False):
|
stable=False):
|
||||||
"""Deploy the entire test environment."""
|
"""Deploy the entire test environment."""
|
||||||
@ -44,7 +42,9 @@ class GlanceBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
|
|
||||||
def _assert_services(self, should_run):
|
def _assert_services(self, should_run):
|
||||||
u.get_unit_process_ids(
|
u.get_unit_process_ids(
|
||||||
{self.glance_sentry: self.services}, expect_success=should_run)
|
{self.glance_sentry: (
|
||||||
|
'apache2', 'haproxy', 'glance-api', 'glance-registry')},
|
||||||
|
expect_success=should_run)
|
||||||
|
|
||||||
def get_service_overrides(self, unit):
|
def get_service_overrides(self, unit):
|
||||||
"""
|
"""
|
||||||
@ -54,7 +54,7 @@ class GlanceBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
init_contents = unit.directory_contents("/etc/init/")
|
init_contents = unit.directory_contents("/etc/init/")
|
||||||
return {
|
return {
|
||||||
service: "{}.override".format(service) in init_contents["files"]
|
service: "{}.override".format(service) in init_contents["files"]
|
||||||
for service in self.SERVICES}
|
for service in ('glance-api', 'glance-registry')}
|
||||||
|
|
||||||
def _add_services(self):
|
def _add_services(self):
|
||||||
"""Add services
|
"""Add services
|
||||||
@ -542,12 +542,15 @@ class GlanceBasicDeployment(OpenStackAmuletDeployment):
|
|||||||
# Config file affected by juju set config change
|
# Config file affected by juju set config change
|
||||||
conf_file = '/etc/glance/glance-api.conf'
|
conf_file = '/etc/glance/glance-api.conf'
|
||||||
|
|
||||||
|
# Services which are expected to restart upon config change
|
||||||
|
services = ['glance-api', 'glance-registry']
|
||||||
|
|
||||||
# Make config change, check for service restarts
|
# Make config change, check for service restarts
|
||||||
u.log.debug('Making config change on {}...'.format(juju_service))
|
u.log.debug('Making config change on {}...'.format(juju_service))
|
||||||
self.d.configure(juju_service, set_alternate)
|
self.d.configure(juju_service, set_alternate)
|
||||||
|
|
||||||
sleep_time = 30
|
sleep_time = 30
|
||||||
for s in self.SERVICES:
|
for s in services:
|
||||||
u.log.debug("Checking that service restarted: {}".format(s))
|
u.log.debug("Checking that service restarted: {}".format(s))
|
||||||
if not u.service_restarted(sentry, s,
|
if not u.service_restarted(sentry, s,
|
||||||
conf_file, sleep_time=sleep_time):
|
conf_file, sleep_time=sleep_time):
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -25,7 +25,9 @@ class PauseTestCase(CharmTestCase):
|
|||||||
self.service_pause.side_effect = fake_service_pause
|
self.service_pause.side_effect = fake_service_pause
|
||||||
|
|
||||||
actions.actions.pause([])
|
actions.actions.pause([])
|
||||||
self.assertEqual(pause_calls, ['glance-api', 'glance-registry'])
|
self.assertItemsEqual(
|
||||||
|
pause_calls,
|
||||||
|
['glance-api', 'glance-registry', 'haproxy', 'apache2'])
|
||||||
|
|
||||||
def test_bails_out_early_on_error(self):
|
def test_bails_out_early_on_error(self):
|
||||||
"""Pause action fails early if there are errors stopping a service."""
|
"""Pause action fails early if there are errors stopping a service."""
|
||||||
@ -42,7 +44,7 @@ class PauseTestCase(CharmTestCase):
|
|||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegexp(
|
||||||
Exception, "glance-registry didn't stop cleanly.",
|
Exception, "glance-registry didn't stop cleanly.",
|
||||||
actions.actions.pause, [])
|
actions.actions.pause, [])
|
||||||
self.assertEqual(pause_calls, ['glance-api'])
|
self.assertEqual(pause_calls, ['haproxy', 'glance-api'])
|
||||||
|
|
||||||
def test_status_mode(self):
|
def test_status_mode(self):
|
||||||
"""Pause action sets the status to maintenance."""
|
"""Pause action sets the status to maintenance."""
|
||||||
@ -81,7 +83,9 @@ class ResumeTestCase(CharmTestCase):
|
|||||||
|
|
||||||
self.service_resume.side_effect = fake_service_resume
|
self.service_resume.side_effect = fake_service_resume
|
||||||
actions.actions.resume([])
|
actions.actions.resume([])
|
||||||
self.assertEqual(resume_calls, ['glance-api', 'glance-registry'])
|
self.assertItemsEqual(
|
||||||
|
resume_calls,
|
||||||
|
['glance-api', 'glance-registry', 'haproxy', 'apache2'])
|
||||||
|
|
||||||
def test_bails_out_early_on_error(self):
|
def test_bails_out_early_on_error(self):
|
||||||
"""Resume action fails early if there are errors starting a service."""
|
"""Resume action fails early if there are errors starting a service."""
|
||||||
@ -98,7 +102,7 @@ class ResumeTestCase(CharmTestCase):
|
|||||||
self.assertRaisesRegexp(
|
self.assertRaisesRegexp(
|
||||||
Exception, "glance-registry didn't start cleanly.",
|
Exception, "glance-registry didn't start cleanly.",
|
||||||
actions.actions.resume, [])
|
actions.actions.resume, [])
|
||||||
self.assertEqual(resume_calls, ['glance-api'])
|
self.assertEqual(resume_calls, ['haproxy', 'glance-api'])
|
||||||
|
|
||||||
def test_status_mode(self):
|
def test_status_mode(self):
|
||||||
"""Resume action sets the status to maintenance."""
|
"""Resume action sets the status to maintenance."""
|
||||||
|
@ -3,7 +3,7 @@ import os
|
|||||||
|
|
||||||
os.environ['JUJU_UNIT_NAME'] = 'glance'
|
os.environ['JUJU_UNIT_NAME'] = 'glance'
|
||||||
|
|
||||||
with patch('hooks.glance_utils.register_configs') as register_configs:
|
with patch('hooks.glance_utils.register_configs'):
|
||||||
from actions import openstack_upgrade
|
from actions import openstack_upgrade
|
||||||
|
|
||||||
from test_utils import (
|
from test_utils import (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user