From fd83175f546ba85643a68ebb9d5e1abf4c60140b Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Wed, 4 Sep 2019 13:51:59 +1200 Subject: [PATCH] charm_tests/glance: migrate Amulet tests to Zaza This patch is the peer change for: https://review.opendev.org/#/c/679599/ charm-glance currently has following Amulet tests: https://github.com/openstack/charm-glance/blob/master/tests/basic_deployment.py The 1xx, 2xx and 5xx ones are mostly covered in zaza keystone tests, or could be skipped in zaza. Add the only missing 900 one, to test glance restart on config change. Test option `debug` instead of `use-syslog` to avoid conversion between `-` and `_`, which is out the scope of this test. Signed-off-by: Joe Guo --- zaza/openstack/charm_tests/glance/tests.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/zaza/openstack/charm_tests/glance/tests.py b/zaza/openstack/charm_tests/glance/tests.py index 001f17f..4f25d81 100644 --- a/zaza/openstack/charm_tests/glance/tests.py +++ b/zaza/openstack/charm_tests/glance/tests.py @@ -67,6 +67,44 @@ class GlanceTest(test_utils.OpenStackBaseTest): {'image_format': {'disk_formats': ['qcow2']}}, ['glance-api']) + 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' + + # Services which are expected to restart upon config change + services = {'glance-api': conf_file} + current_release = openstack_utils.get_os_release() + bionic_stein = openstack_utils.get_os_release('bionic_stein') + if current_release < bionic_stein: + services.update({'glance-registry': conf_file}) + + # Make config change, check for service restarts + logging.info('changing config: {}'.format(set_alternate)) + self.restart_on_changed( + conf_file, + set_default, + set_alternate, + default_entry, + alternate_entry, + services) + def test_901_pause_resume(self): """Run pause and resume tests.