Use the new svc restart checker where possible

restart_on_changed_debug_oslo_config_file was added to avoid code
duplication.
This commit is contained in:
Dmitrii Shcherbakov
2020-04-21 16:50:02 +03:00
parent d8daabea22
commit 72b420b56a
5 changed files with 12 additions and 88 deletions

View File

@@ -114,20 +114,12 @@ class AodhTest(test_utils.OpenStackBaseTest):
Change debug mode and assert that change propagates to the correct
file and that services are restarted as a result
"""
# Expected default and alternate values
set_default = {'debug': 'False'}
set_alternate = {'debug': 'True'}
# Config file affected by juju set config change
conf_file = '/etc/aodh/aodh.conf'
# Make config change, check for service restarts
self.restart_on_changed(
self.restart_on_changed_debug_oslo_config_file(
conf_file,
set_default,
set_alternate,
{'DEFAULT': {'debug': ['False']}},
{'DEFAULT': {'debug': ['True']}},
self.services)
self.query_aodh_api()

View File

@@ -168,21 +168,13 @@ class CinderTests(test_utils.OpenStackBaseTest):
Change debug mode and assert that change propagates to the correct
file and that services are restarted as a result
"""
# Expected default and alternate values
set_default = {'debug': 'False'}
set_alternate = {'debug': 'True'}
# Config file affected by juju set config change
conf_file = '/etc/cinder/cinder.conf'
# Make config change, check for service restarts
logging.debug('Setting debug mode...')
self.restart_on_changed(
self.restart_on_changed_debug_oslo_config_file(
conf_file,
set_default,
set_alternate,
{'DEFAULT': {'debug': ['False']}},
{'DEFAULT': {'debug': ['True']}},
self.services)
def test_901_pause_resume(self):

View File

@@ -98,22 +98,15 @@ class DesignateTests(BaseDesignateTest):
Change debug mode and assert that change propagates to the correct
file and that services are restarted as a result
"""
# Expected default and alternate values
set_default = {'debug': 'False'}
set_alternate = {'debug': 'True'}
# Services which are expected to restart upon config change,
# and corresponding config files affected by the change
conf_file = '/etc/designate/designate.conf'
# Make config change, check for service restarts
self.restart_on_changed(
self.restart_on_changed_debug_oslo_config_file(
conf_file,
set_default,
set_alternate,
{'DEFAULT': {'debug': ['False']}},
{'DEFAULT': {'debug': ['True']}},
self.designate_svcs)
self.designate_svcs,
)
def test_910_pause_and_resume(self):
"""Run pause and resume tests.

View File

@@ -69,22 +69,6 @@ class GlanceTest(test_utils.OpenStackBaseTest):
def test_900_restart_on_config_change(self):
"""Checking restart happens on config change."""
# Expected default and alternate values
current_value = openstack_utils.get_application_config_option(
'glance', 'debug')
# this is bool, not str
assert type(current_value) == bool
new_value = not current_value
# convert bool to str
current_value = str(current_value)
new_value = str(new_value)
set_default = {'debug': current_value}
set_alternate = {'debug': new_value}
default_entry = {'DEFAULT': {'debug': [current_value]}}
alternate_entry = {'DEFAULT': {'debug': [new_value]}}
# Config file affected by juju set config change
conf_file = '/etc/glance/glance-api.conf'
@@ -96,14 +80,10 @@ class GlanceTest(test_utils.OpenStackBaseTest):
services.update({'glance-registry': conf_file})
# Make config change, check for service restarts
logging.info('changing config: {}'.format(set_alternate))
self.restart_on_changed(
logging.info('changing debug config')
self.restart_on_changed_debug_oslo_config_file(
conf_file,
set_default,
set_alternate,
default_entry,
alternate_entry,
services)
self.services)
def test_901_pause_resume(self):
"""Run pause and resume tests.

View File

@@ -80,29 +80,13 @@ class NovaCompute(test_utils.OpenStackBaseTest):
Change debug mode and assert that change propagates to the correct
file and that services are restarted as a result
"""
# Expected default and alternate values
current_value = zaza.model.get_application_config(
'nova-compute')['debug']['value']
new_value = str(not bool(current_value)).title()
current_value = str(current_value).title()
set_default = {'debug': current_value}
set_alternate = {'debug': new_value}
default_entry = {'DEFAULT': {'debug': [current_value]}}
alternate_entry = {'DEFAULT': {'debug': [new_value]}}
# Config file affected by juju set config change
conf_file = '/etc/nova/nova.conf'
# Make config change, check for service restarts
logging.info(
'Setting verbose on nova-compute {}'.format(set_alternate))
self.restart_on_changed(
logging.info('Changing the debug config on nova-compute')
self.restart_on_changed_debug_oslo_config_file(
conf_file,
set_default,
set_alternate,
default_entry,
alternate_entry,
['nova-compute'])
def test_920_change_aa_profile(self):
@@ -339,30 +323,13 @@ class NovaCloudController(test_utils.OpenStackBaseTest):
Change debug mode and assert that change propagates to the correct
file and that services are restarted as a result
"""
# Expected default and alternate values
current_value = zaza.model.get_application_config(
'nova-cloud-controller')['debug']['value']
new_value = str(not bool(current_value)).title()
current_value = str(current_value).title()
set_default = {'debug': current_value}
set_alternate = {'debug': new_value}
default_entry = {'DEFAULT': {'debug': [current_value]}}
alternate_entry = {'DEFAULT': {'debug': [new_value]}}
# Config file affected by juju set config change
conf_file = '/etc/nova/nova.conf'
# Make config change, check for service restarts
logging.info(
'Setting verbose on nova-cloud-controller {}'.format(
set_alternate))
self.restart_on_changed(
logging.info('Changing debug config on nova-cloud-controller')
self.restart_on_changed_debug_oslo_config_file(
conf_file,
set_default,
set_alternate,
default_entry,
alternate_entry,
self.services)
def test_901_pause_resume(self):