Merge "Add WSGI check for devstack"

This commit is contained in:
Zuul 2025-05-12 14:07:11 +00:00 committed by Gerrit Code Review
commit 188c36b751
3 changed files with 45 additions and 1 deletions

View File

@ -45,3 +45,5 @@ DHCP_OPTIONS_NEUTRON_TO_OVN = {
'lease-time': 'lease_time',
'domain-search': 'domain_search',
'26': 'mtu'}
LOCAL_CONF_FILE = '/opt/stack/devstack/local.conf'
WSGI_OPT = 'NEUTRON_DEPLOY_MOD_WSGI'

View File

@ -31,6 +31,46 @@ LOG = log.getLogger(__name__)
WB_CONF = CONF.whitebox_neutron_plugin_options
def is_regex_in_file(regex, filename, re_flags=0, fail_no_file=True):
"""Returns whether regex found in file content."""
try:
with open(filename) as file:
result = bool(re.search(
regex,
file.read(),
re_flags))
except FileNotFoundError:
if fail_no_file:
LOG.exception(
"File '%s' not found while searching regex '%s' in it",
filename, regex)
raise
result = False
LOG.debug("is '%s' regex found in file '%s' -> %s",
regex, filename, result)
return result
def _is_devstack_wsgi(local_conf=constants.LOCAL_CONF_FILE):
# NOTE(mblue): fails/false for podified, so file existence optional
return is_regex_in_file(
f'{constants.WSGI_OPT}=.*?true.*?',
local_conf,
re.I,
fail_no_file=False)
def conf_action(
file, section='DEFAULT', param='', value='', host=None, check=True):
"""get/set using crudini in local/remote host."""
assert param
_action = '--set' if value else '--get'
_value = f"'{value}'" if value else ""
cmd = f"crudini {_action} '{file}' '{section}' '{param}' {_value}"
output = shell.execute(cmd, host, check)
return output.stdout.strip()
def create_payload_file(ssh_client, size):
ssh_client.exec_command(
"head -c {0} /dev/zero > {0}".format(size))

View File

@ -62,6 +62,8 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
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()
@classmethod
def resource_setup(cls):
@ -93,7 +95,7 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
@classmethod
def get_neutron_api_service_name(cls):
"""Return the Neutron API service name based on test configuration"""
if cls.is_devstack:
if cls.is_devstack and not cls.is_devstack_wsgi:
# NOTE: in OSP18+, the Neutron API will use WSGI by default (not
# the eventlet server) and the name will be "neutron api"
return 'q svc'