Fix check_service_setting() logic

The check_service_setting() function was checking files starting
from defaults and was returning True if match was found there.
On podified environments the file with defaults usually remains
unchanged and all overrides are pushed to a file with overrides
that alphabetically goes after the file with defaults.
So in case a default value of a parameter is True and in overrides
it was False, than the False was ignored.
This patch changes the order of searching config values to this:
- first check in file with overrides, if needed parameter found
check it's value against a desired value and return True if match
or False/skipTest if not match.
- only if parameter was not found in overrides (matching or
not matching) than check the value from the file with defaults.

Change-Id: I9a736e01790d077398954b424669984606aec499
This commit is contained in:
Roman Safronov 2024-05-09 17:02:23 +03:00
parent 0222b13376
commit c107274ae1

View File

@ -394,17 +394,23 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
else:
service_prefix = ""
cmd_prefix = "crudini --get"
for config_file in config_files:
# If we have config file with defaults and second one with overrides,
# the latter has the config that wins
for config_file in reversed(config_files):
setting = "{} {} {}".format(config_file, section, param)
cmd = "{} {} {} || true".format(
service_prefix, cmd_prefix, setting)
LOG.debug("Command = '{}'".format(cmd))
result = host['client'].exec_command(cmd)
result = host['client'].exec_command(cmd).strip()
LOG.debug("Result = '{}'".format(result))
if value.lower() in result.lower():
return True
else:
continue
# Since we are checking files in reverse order,
# if we've found a value than it's an override and we
# should ignore values in other files
if result:
if value.lower() in result.lower():
return True
else:
break
if skip_if_fails:
raise cls.skipException(msg)