Fix Ganesha _restart_share_instance for non-ha

Manila Ganesha is not always deployed in an ha configuration in
functional tests. This means there is no automated restart of the
manila services but the _restart_share_instance method shuts down
manila services via systemctl and expects them to be automatically
started. This change detects if the hacluster charm is present, if
it is it defaults it used the old behaviour otherwise systemctl
is used to restart the services.
This commit is contained in:
Liam Young
2022-09-08 05:49:15 +00:00
parent 695f91a4c6
commit 778d36e1fa

View File

@@ -26,6 +26,7 @@ from zaza.openstack.charm_tests.manila_ganesha.setup import (
import zaza.openstack.utilities.generic as generic_utils
import zaza.openstack.charm_tests.manila.tests as manila_tests
import zaza.model
import zaza.utilities.juju as zaza_utils_juju
class ManilaGaneshaTests(manila_tests.ManilaBaseTest):
@@ -50,13 +51,27 @@ class ManilaGaneshaTests(manila_tests.ManilaBaseTest):
app for app in zaza.model.sync_deployed()
if 'ganesha' in app and 'mysql' not in app]
for ganesha in ganeshas:
ganesha_unit = zaza.model.get_units(ganesha)[0]
hacluster_unit = zaza_utils_juju.get_subordinate_units(
[ganesha_unit.entity_id],
charm_name='hacluster')
logging.info('Ganesha in hacluster mode: {}'.format(
bool(hacluster_unit)))
for unit in zaza.model.get_units(ganesha):
# While we really only need to run this on the machine hosting
# nfs-ganesha and manila-share, running it everywhere isn't
# harmful. Pacemaker handles restarting the services
zaza.model.run_on_unit(
unit.entity_id,
"systemctl stop manila-share nfs-ganesha")
if hacluster_unit:
# While we really only need to run this on the machine
# hosting # nfs-ganesha and manila-share, running it
# everywhere isn't harmful. Pacemaker handles restarting
# the services
zaza.model.run_on_unit(
unit.entity_id,
"systemctl stop manila-share nfs-ganesha")
else:
zaza.model.run_on_unit(
unit.entity_id,
"systemctl restart manila-share nfs-ganesha")
return True
def _run_nrpe_check_command(self, commands):