diff --git a/whitebox_neutron_tempest_plugin/common/utils.py b/whitebox_neutron_tempest_plugin/common/utils.py index 637fcac..3090f0c 100644 --- a/whitebox_neutron_tempest_plugin/common/utils.py +++ b/whitebox_neutron_tempest_plugin/common/utils.py @@ -51,13 +51,20 @@ def is_regex_in_file(regex, filename, re_flags=0, fail_no_file=True): return result -def _is_devstack_wsgi(): - # TODO(rxiao): remove this check when/if API check exists - if shell.execute( +def is_local_service(service_name): + """Returns if local service exists""" + return bool( + shell.execute( "systemctl list-unit-files --type service | " - "grep devstack@neutron-api", check=False).stdout.strip(): - return True - return False + f"grep '{service_name}'", + check=False + ).stdout.strip()) + + +def is_devstack_wsgi(): + """Returns if wsgi according to neutron api service name when used""" + # TODO(rxiao): remove this check when/if API check exists + return is_local_service('devstack@neutron-api') def conf_action( diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/base.py b/whitebox_neutron_tempest_plugin/tests/scenario/base.py index 747660a..89f2475 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/base.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/base.py @@ -56,14 +56,9 @@ ConfigOption = collections.namedtuple( class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): credentials = ['primary', 'admin'] - # NOTE(mblue): change devstack check if CI must not use /opt/stack, - # currently used commonly for devstack jobs needed by plugin. if 'is_devstack' not in locals(): - is_devstack = bool(shell.execute( - 'test -d /opt/stack && echo stack', - check=False).stdout.strip()) - if 'is_devstack_wsgi' not in locals(): - is_devstack_wsgi = local_utils._is_devstack_wsgi() + is_devstack = local_utils.is_local_service("devstack@") + is_devstack_wsgi = is_devstack and local_utils.is_devstack_wsgi() @classmethod def resource_setup(cls):