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 <guoqiao@gmail.com>
This commit is contained in:
Joe Guo
2019-09-04 13:51:59 +12:00
parent a03ecb4488
commit fd83175f54

View File

@@ -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.