Skip to content

Commit

Permalink
update agent_failure to run journalctl as user
Browse files Browse the repository at this point in the history
Skip-test: true
Skip-build: true

Signed-off-by: Dalton Bohning <dalton.bohning@intel.com>
  • Loading branch information
daltonbohning committed Sep 9, 2024
1 parent 3e2a907 commit fb41bc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/tests/ftest/deployment/agent_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_agent_failure(self):
# 5. Verify journalctl shows the log that the agent is stopped.
results = get_journalctl(
hosts=self.hostlist_clients, since=since, until=until,
journalctl_type="daos_agent")
journalctl_type="daos_agent", run_user=self.test_env.agent_user)
self.log.info("journalctl results = %s", results)
if "shutting down" not in results[0]["data"]:
msg = "Agent shut down message not found in journalctl! Output = {}".format(
Expand Down Expand Up @@ -240,7 +240,7 @@ def test_agent_failure_isolation(self):
# stopped.
results = get_journalctl(
hosts=[agent_host_kill], since=since, until=until,
journalctl_type="daos_agent")
journalctl_type="daos_agent", run_user=self.test_env.agent_user)
self.log.info("journalctl results (kill) = %s", results)
if "shutting down" not in results[0]["data"]:
msg = ("Agent shut down message not found in journalctl on killed client! "
Expand All @@ -251,7 +251,7 @@ def test_agent_failure_isolation(self):
# in the previous step doesn't show that the agent is stopped.
results = get_journalctl(
hosts=[agent_host_keep], since=since, until=until,
journalctl_type="daos_agent")
journalctl_type="daos_agent", run_user=self.test_env.agent_user)
self.log.info("journalctl results (keep) = %s", results)
if "shutting down" in results[0]["data"]:
msg = ("Agent shut down message found in journalctl on keep client! "
Expand Down
6 changes: 4 additions & 2 deletions src/tests/ftest/util/general_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,22 +1062,24 @@ def get_journalctl_command(since, until=None, system=False, units=None, identifi
return command_as_user(" ".join(command), run_user)


def get_journalctl(hosts, since, until, journalctl_type):
def get_journalctl(hosts, since, until, journalctl_type, run_user="root"):
"""Run the journalctl on the hosts.
Args:
hosts (list): List of hosts to run journalctl.
since (str): Start time to search the log.
until (str): End time to search the log.
journalctl_type (str): String to search in the log. -t param for journalctl.
run_user (str, optional): user to run as. Defaults to root
Returns:
list: a list of dictionaries containing the following key/value pairs:
"hosts": NodeSet containing the hosts with this data
"data": data requested for the group of hosts
"""
command = get_journalctl_command(since, until, True, identifiers=journalctl_type)
system = run_user != getuser()
command = get_journalctl_command(since, until, system, identifiers=journalctl_type, run_user=run_user)

Check failure on line 1082 in src/tests/ftest/util/general_utils.py

View workflow job for this annotation

GitHub Actions / Flake8 check

E501 line too long (106 > 100 characters)

Check warning on line 1082 in src/tests/ftest/util/general_utils.py

View workflow job for this annotation

GitHub Actions / Pylint check

line-too-long, Line too long (106/100)
err = "Error gathering system log events"
return get_host_data(hosts=hosts, command=command, text="journalctl", error=err)

Expand Down

0 comments on commit fb41bc3

Please sign in to comment.