Skip to content

Commit

Permalink
DAOS-13886 test: Fix system name validation
Browse files Browse the repository at this point in the history
Fix regression on tests checking system name.

Test-tag: DAOSVersion,test_version DaosAgentConfigTest,test_daos_agent_config_basic DaosControlConfigTest,test_daos_control_config_basic
Required-githooks: true
Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@intel.com>
  • Loading branch information
kanard38 authored and knard-intel committed Jul 4, 2023
1 parent 008a9ba commit 5601fae
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/tests/ftest/control/daos_agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_daos_agent_config_basic(self):
:avocado: tags=all,daily_regression
:avocado: tags=vm
:avocado: tags=control,basic
:avocado: tags=agent_start,daos_agent_config_test,test_daos_agent_config_basic
:avocado: tags=DaosAgentConfigTest,test_daos_agent_config_basic
"""
# Setup the agents
self.add_agent_manager()
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ftest/control/daos_agent_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ agent_config_val: !mux
config_val:
- "name"
- "! @#$%^&*()_+{}|:<>?-=[];',./"
- "PASS"
- "FAIL"
name_alphanumeric:
config_val:
- "name"
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ftest/control/daos_control_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_daos_control_config_basic(self):
:avocado: tags=all,daily_regression
:avocado: tags=vm
:avocado: tags=control,basic
:avocado: tags=control_start,test_daos_control_config_basic
:avocado: tags=DaosControlConfigTest,test_daos_control_config_basic
"""
# Get the input to verify
c_val = self.params.get("config_val", "/run/control_config_val/*/")
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ftest/control/daos_control_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ control_config_val: !mux
config_val:
- "name"
- "! @#$%^&*()_+{}|:<>?-=[];',./"
- "PASS"
- "FAIL"
name_numeric:
config_val:
- "name"
Expand Down
69 changes: 52 additions & 17 deletions src/tests/ftest/control/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,60 @@ class DAOSVersion(TestWithServers):
def __init__(self, *args, **kwargs):
"""Initialize a DAOSVersion object."""
super().__init__(*args, **kwargs)

# Don't waste time starting servers and agents.
self.setup_start_servers = False
self.setup_start_agents = False

self.errors = []

def report_result(self):
"""Helper printing test result"""
self.log.info("###### Test Result ######")
report_errors(test=self, errors=self.errors)
self.log.info("#########################")

def append_error(self, title, details):
"""Helper adding an error to the list of errors
Args:
title (str): Error message title
details (list): List of string of the error details
"""
msg = title
if details:
msg += "\n\t" + "\n\t".join(details)
self.errors.append(msg)

def test_version(self):
"""Verify version number for dmg, daos, daos_server, and daos_agent against RPM.
:avocado: tags=all,full_regression
:avocado: tags=vm
:avocado: tags=control,daos_cmd
:avocado: tags=version_number,test_version
:avocado: tags=DAOSVersion,test_version
"""
errors = []

# Get RPM version.
rpm_command = "rpm -qa|grep daos-server"
output = run_pcmd(hosts=self.hostlist_servers, command=rpm_command)
self.log.info("RPM output = %s", output)
stdout = output[0]["stdout"][0]
self.log.info("RPM stdout = %s", stdout)
result = re.findall(r"daos-server-[tests-|tests_openmpi-]*([\d.]+)", stdout)
self.log.debug("RPM output = %s", output)
rc = output[0]["exit_status"]
stdout = output[0]["stdout"]
if rc != 0:
msg = "DAOS RPMs not properly installed: rc={}".format(rc)
self.append_error(msg, stdout)
self.report_result()
rpm_version = None
for rpm in stdout:
result = re.findall(r"daos-server-[tests-|tests_openmpi-]*([\d.]+)", rpm)
if result:
rpm_version = result[0]
break
if not result:
errors.append("RPM version is not in the output! {}".format(output))
else:
rpm_version = result[0]
self.log.info("RPM version = %s", rpm_version)
msg = "RPM version could not be defined"
self.append_error(msg, stdout)
self.report_result()
self.log.info("RPM version = %s", rpm_version)

# Get dmg version.
dmg_version = self.get_dmg_command().version()["response"]["version"]
Expand All @@ -58,10 +86,19 @@ def test_version(self):
self.log.info("daos version = %s", daos_version)

# Get daos_agent version.
daos_agent_version = None
daos_agent_cmd = "daos_agent --json version"
output = run_pcmd(hosts=self.hostlist_servers, command=daos_agent_cmd)
daos_agent_version = json.loads("".join(output[0]["stdout"]))["response"]["version"]
self.log.info("daos_agent version = %s", daos_agent_version)
self.log.debug("DAOS Agent output = %s", output)
rc = output[0]["exit_status"]
stdout = output[0]["stdout"]
if rc != 0:
msg = "DAOS Agent not properly installed: rc={}".format(rc)
self.append_error(msg, stdout)
else:
self.log.info("DAOS Agent stdout = %s", "".join(stdout))
daos_agent_version = json.loads("".join(stdout))["response"]["version"]
self.log.info("daos_agent version = %s", daos_agent_version)

# Get daos_server version
daos_server_cmd = DaosServerCommandRunner(path=self.bin)
Expand All @@ -82,8 +119,6 @@ def test_version(self):
if version != rpm_version:
msg = "Unexpected version! {} = {}, RPM = {}".format(
tool, version, rpm_version)
errors.append(msg)
self.errors.append(msg)

self.log.info("###### Test Result ######")
report_errors(test=self, errors=errors)
self.log.info("#########################")
self.report_result()

0 comments on commit 5601fae

Please sign in to comment.