Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-16560 test: Improve get_service_file() #15116

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/tests/ftest/util/systemctl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import getpass
import os
import re
import tempfile

from ClusterShell.NodeSet import NodeSet
Expand Down Expand Up @@ -151,17 +152,18 @@ def get_service_file(logger, hosts, service, user, verbose=True, timeout=120):
str: the service file
"""
command = ' | '.join([
get_systemctl_command("status", service, user),
"grep 'Loaded:'",
"grep -oE '/.*service'",
"xargs sh -c '[ -e \"$0\" ] && echo \"$0\"'"
get_systemctl_command("show", service, user),
"grep 'FragmentPath='",
])
result = run_remote(logger, hosts, command, verbose, timeout)
if not result.passed:
raise SystemctlFailure("Error obtaining the service file path")
if not result.homogeneous:
raise SystemctlFailure("Error obtaining a homogeneous service file path")
return list(result.all_stdout.values())[0].strip()
try:
return re.findall(r'FragmentPath=(.+)', result.joined_stdout)[0]
except IndexError as error:
raise SystemctlFailure("Error parsing the service file path") from error


def create_override_config(logger, hosts, service, user, service_command, service_config, path,
Expand Down
Loading