Add RabbitMQDeferredRestartTest + fixes

This commit is contained in:
Liam Young
2021-03-23 15:57:21 +00:00
parent 1f47ef0bd7
commit 085d5a1513
2 changed files with 44 additions and 1 deletions

View File

@@ -428,3 +428,45 @@ class RmqTests(test_utils.OpenStackBaseTest):
check_units(all_units)
logging.info('OK')
class RabbitMQDeferredRestartTest(test_utils.BaseDeferredRestartTest):
"""Deferred restart tests."""
@classmethod
def setUpClass(cls):
"""Run setup for deferred restart tests."""
super().setUpClass(
restart_config_file='/etc/rabbitmq/rabbitmq.config',
test_service='rabbitmq-server',
restart_package='rabbitmq-server',
restart_package_service='rabbitmq-server',
application_name='rabbitmq-server')
def trigger_deferred_restart_via_charm(self):
"""Set charm config option which requires a service start.
Set the charm debug option and wait for that change to be renderred in
applications config file.
NOTE: The implementation assumes the charm has a `debug` option and
self.restart_config_file in an oslo config file where that
debug option is renderred. If that is not true the specaliasation
class should override this method.
"""
app_config = zaza.model.get_application_config(self.application_name)
logging.info("Triggering deferred restart via config change")
new_debug_value = str(int(app_config['connection-backlog'].get('value', 100) + 1))
logging.info("Setting connection-backlog: {}".format(new_debug_value))
zaza.model.set_application_config(
self.application_name,
{'connection-backlog': new_debug_value})
logging.info("Waiting for connection-backlog to be {} in {}".format(
new_debug_value,
self.restart_config_file))
zaza.model.block_until_file_matches_re(
self.application_name,
self.restart_config_file,
'{{backlog, {}}}'.format(new_debug_value))
logging.info("Waiting for units to be idle")
zaza.model.block_until_all_units_idle()

View File

@@ -770,7 +770,7 @@ class BaseDeferredRestartTest(OpenStackBaseTest):
# Check workload status no longer shows deferred restarts.
for unit in model.get_units(self.application_name):
assert unit.workload_status_message == 'Unit is ready'
assert 'Services queued' not in unit.workload_status_message
def check_show_deferred_restarts_action(self, test_service,
restart_reason):
@@ -796,6 +796,7 @@ class BaseDeferredRestartTest(OpenStackBaseTest):
"show-deferred-restarts action on {}").format(
test_service,
unit.entity_id))
assert action.data['status'] == 'completed'
for event in yaml.safe_load(action.data['results']['output']):
if test_service in event and restart_reason in event:
break