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-16220 test: Include username in default common test directory #14937

Draft
wants to merge 63 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
995b03b
DAOS-16220 test: Include username in default common test directory
phender Aug 15, 2024
3fc3b4f
Merge branch 'master' into pahender/DAOS-16220
phender Aug 15, 2024
f0b01e9
Fix pylint.
phender Aug 16, 2024
7907b85
Merge branch 'master' into pahender/DAOS-16220
phender Aug 28, 2024
5b031ec
Fix shellcheck and apply feedback.
phender Aug 28, 2024
bb345cb
Fix main.sh
phender Aug 28, 2024
bb3ef4c
Fix main.sh again
phender Aug 28, 2024
c521baa
Test custom_a mode
phender Aug 29, 2024
09fbcfb
Fix systemctl --user usage.
phender Aug 29, 2024
681b8cc
Enable user systemctl on all test nodes.
phender Aug 29, 2024
8d54966
Merge branch 'master' into pahender/DAOS-16220
phender Aug 30, 2024
2ac57c5
Fixing running agent as user.
phender Aug 30, 2024
bfeb3b3
Cleanup verify socket dir.
phender Aug 30, 2024
810c456
Cleanup verify socket dir.
phender Aug 30, 2024
1908088
Remove missing config temp error.
phender Aug 30, 2024
3bb43b6
Merge branch 'pahender/DAOS-16220' of https://github.com/daos-stack/d…
phender Aug 30, 2024
4565846
Merge branch 'master' into pahender/DAOS-16220
phender Aug 30, 2024
f89984a
Fix running systemctl as user.
phender Aug 30, 2024
1df9183
Adding systemctl status for failed start debug.
phender Aug 31, 2024
71db462
Run systemctl status first on error.
phender Sep 3, 2024
fc6f498
Fix systemctl user setup.
phender Sep 3, 2024
e1bd482
Adding jenkins user to the systemd-journal group.
phender Sep 3, 2024
5dacb90
Merge branch 'master' into pahender/DAOS-16220
phender Sep 3, 2024
9a53052
Adding debug for failed systemctl start command.
phender Sep 3, 2024
2b78e78
Adding config file debug.
phender Sep 3, 2024
23723ca
Fix debug.
phender Sep 3, 2024
9568e99
Improvements
phender Sep 4, 2024
6977312
Debug
phender Sep 4, 2024
55cee23
Fix debug
phender Sep 4, 2024
d04b1bc
Fix mod of user daos_agent service file
phender Sep 4, 2024
9a0566c
Attempting to allow user access to journalctl output
phender Sep 4, 2024
48c08e4
Re-adding jenkins user to systemd-journal group.
phender Sep 4, 2024
ddde157
Merge branch 'master' into pahender/DAOS-16220
phender Sep 4, 2024
2fee48a
Adding restarting systemd-journald
phender Sep 4, 2024
d225fd3
Attempting w/o adding jenkins to systemd-journal
phender Sep 4, 2024
c96f498
Confirm normal CI operation.
phender Sep 4, 2024
0f11d81
Test fixes.
phender Sep 5, 2024
24040c5
Apply feedback.
phender Sep 5, 2024
cdf12b4
Merge branch 'master' into pahender/DAOS-16220
phender Sep 17, 2024
f780e92
Fix creatre_directory() owner/user swap.
phender Sep 17, 2024
5727b4c
Merge branch 'master' into pahender/DAOS-16220
phender Sep 18, 2024
15a4599
Additional updates for running the agent as the user.
phender Sep 18, 2024
46b0765
Fix typo.
phender Sep 19, 2024
e404fc0
Merge branch 'master' into pahender/DAOS-16220
phender Sep 20, 2024
34568ba
Remove the control metadata path with sudo.
phender Sep 20, 2024
c3e4126
Merge branch 'master' into pahender/DAOS-16220
phender Sep 24, 2024
d6331dd
Fix empty server list.
phender Sep 24, 2024
8ddd6ad
Merge branch 'master' into pahender/DAOS-16220
phender Sep 25, 2024
43f0d28
Remove the control metadata path contents as part of the server cleanup.
phender Sep 25, 2024
84d6b7c
Support running cart_ctl with user run daos_agent.
phender Sep 25, 2024
c3fad19
Code cleanup.
phender Sep 25, 2024
282d39c
Merge branch 'master' into pahender/DAOS-16220
phender Oct 3, 2024
48fcdb1
Add user to stop_processes.
phender Oct 3, 2024
50d5422
Merge branch 'master' into pahender/DAOS-16220
phender Oct 4, 2024
0a2cf6b
Apply feedback.
phender Oct 4, 2024
5109544
Fix handling daos_user home dirs.
phender Oct 7, 2024
3776f23
Merge branch 'master' into pahender/DAOS-16220
phender Oct 8, 2024
75d8677
Fix typo.
phender Oct 8, 2024
b28ae35
Merge branch 'master' into pahender/DAOS-16220
phender Oct 14, 2024
12d0c0e
Merge branch 'master' into pahender/DAOS-16220
phender Oct 17, 2024
2141693
Merge branch 'master' into pahender/DAOS-16220
phender Oct 22, 2024
2507648
Setting DAOS_AGENT_DRPC_DIR for remote commands
phender Oct 22, 2024
a4ff69c
Fix pylint issue.
phender Oct 22, 2024
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
66 changes: 56 additions & 10 deletions src/tests/ftest/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ def _run(self, args):
else:
set_test_environment(
logger, test_env, args.test_servers, args.test_clients, args.provider,
args.insecure_mode, self.details)
args.insecure_mode, self.details, args.agent_user, args.test_log_dir,
args.systemd_path, args.systemd_lib_path)
except TestEnvironmentException as error:
message = f"Error setting up test environment: {str(error)}"
return self.get_exit_status(1, message, "Setup", sys.exc_info())
Expand Down Expand Up @@ -318,12 +319,13 @@ def _run(self, args):
return self.get_exit_status(0, "Listing tests complete")

# Setup the fuse configuration
try:
setup_fuse_config(logger, args.test_servers | args.test_clients)
except LaunchException:
# Warn but don't fail
message = "Issue detected setting up the fuse configuration"
setup_result.warn_test(logger, "Setup", message, sys.exc_info())
if args.fuse_setup:
try:
setup_fuse_config(logger, args.test_servers | args.test_clients)
except LaunchException:
# Warn but don't fail
message = "Issue detected setting up the fuse configuration"
setup_result.warn_test(logger, "Setup", message, sys.exc_info())

# Get the core file pattern information
core_files = {}
Expand All @@ -347,8 +349,8 @@ def _run(self, args):
group.update_test_yaml(
logger, args.scm_size, args.scm_mount, args.extra_yaml,
args.timeout_multiplier, args.override, args.verbose, args.include_localhost)
except (RunException, YamlException) as e:
message = "Error modifying the test yaml files: {}".format(e)
except (RunException, YamlException) as error:
message = f"Error modifying the test yaml files: {error}"
status |= self.get_exit_status(1, message, "Setup", sys.exc_info())
except StorageException:
message = "Error detecting storage information for test yaml files"
Expand Down Expand Up @@ -529,6 +531,12 @@ def main():
"-a", "--archive",
action="store_true",
help="archive host log files in the avocado job-results directory")
parser.add_argument(
"-au", "--agent_user",
action="store",
default=None,
type=str,
help="user account to use when running the daos_agent")
parser.add_argument(
"-c", "--clear_mounts",
action="append",
Expand All @@ -551,6 +559,10 @@ def main():
"--failfast",
action="store_true",
help="stop the test suite after the first failure")
parser.add_argument(
"-fs", "--fuse_setup",
action="store_true",
help="enable setting up fuse configuration files")
parser.add_argument(
"-i", "--include_localhost",
action="store_true",
Expand All @@ -573,7 +585,7 @@ def main():
help="modify the test yaml files but do not run the tests")
parser.add_argument(
"-mo", "--mode",
choices=['normal', 'manual', 'ci'],
choices=['normal', 'manual', 'ci', 'custom_a'],
default='normal',
help="provide the mode of test to be run under. Default is normal, "
"in which the final return code of launch.py is still zero if "
Expand Down Expand Up @@ -638,6 +650,18 @@ def main():
"-si", "--slurm_install",
action="store_true",
help="enable installing slurm RPMs if required by the tests")
parser.add_argument(
"-sl", "--systemd_lib_path",
action="store",
default=None,
type=str,
help="the daos_server and daos_agent systemd LD_LIBRARY_PATH to define in the config")
parser.add_argument(
"-sp", "--systemd_path",
action="store",
default=None,
type=str,
help="the daos_server and daos_agent systemd PATH to define in the config")
parser.add_argument(
"--scm_mount",
action="store",
Expand Down Expand Up @@ -670,6 +694,12 @@ def main():
default=NodeSet(),
help="comma-separated list of hosts to use as replacement values for "
"client placeholders in each test's yaml file")
parser.add_argument(
"-tld", "--test_log_dir",
action="store",
default=None,
type=str,
help="test log directory base path")
parser.add_argument(
"-th", "--logs_threshold",
action="store",
Expand Down Expand Up @@ -733,10 +763,26 @@ def main():
args.slurm_install = True
args.slurm_setup = True
args.user_create = True
args.fuse_setup = True
args.clear_mounts.append("/mnt/daos")
args.clear_mounts.append("/mnt/daos0")
args.clear_mounts.append("/mnt/daos1")

elif args.mode == "custom_a":
if args.agent_user is None:
# Run the agent with the current user by default
args.agent_user = getpass.getuser()
if os.environ.get("DAOS_TEST_LOG_DIR", args.test_log_dir) is None:
# Use a user-specific test log dir by default
args.test_log_dir = os.path.join(
os.sep, "var", "tmp", f"daos_testing_{args.agent_user}")
args.process_cores = False
args.logs_threshold = None
args.slurm_install = False
args.slurm_setup = False
args.user_create = False
args.fuse_setup = False

# Setup the Launch object
launch = Launch(args.name, args.mode, args.slurm_install, args.slurm_setup)

Expand Down
67 changes: 52 additions & 15 deletions src/tests/ftest/util/environment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@ class TestEnvironment():
'bullseye_file': 'COVFILE',
'daos_prefix': 'DAOS_TEST_PREFIX',
'agent_user': 'DAOS_TEST_AGENT_USER',
'systemd_library_path': 'DAOS_TEST_SYSTEMD_LIBRARY_PATH',
'systemd_path': 'DAOS_TEST_SYSTEMD_PATH',
'systemd_ld_library_path': 'DAOS_TEST_SYSTEMD_LD_LIBRARY_PATH',
}

def __init__(self):
"""Initialize a TestEnvironment object with existing or default test environment values."""
self.set_defaults(None)

def set_defaults(self, logger, servers=None, clients=None, provider=None, insecure_mode=None,
agent_user=None, log_dir=None, systemd_lib_path=None):
agent_user=None, log_dir=None, systemd_path=None, systemd_lib_path=None):
"""Set the default test environment variable values with optional inputs.

Args:
Expand All @@ -131,7 +132,9 @@ def set_defaults(self, logger, servers=None, clients=None, provider=None, insecu
agent_user (str, optional): user account to use when running the daos_agent. Defaults
to None.
log_dir (str, optional): test log directory base path. Defaults to None.
systemd_lib_path (str, optional): systemd library path. Defaults to None.
systemd_path (str, optional): systemd PATH to use in testing. Defaults to None.
systemd_lib_path (str, optional): systemd LD_LIBRARY_PATH to use in testing. Defaults
to None.

Raises:
TestEnvironmentException: if there are any issues setting environment variable default
Expand All @@ -150,8 +153,10 @@ def set_defaults(self, logger, servers=None, clients=None, provider=None, insecu
self.insecure_mode = insecure_mode
if agent_user is not None:
self.agent_user = agent_user
if systemd_path is not None:
self.systemd_path = systemd_path
if systemd_lib_path is not None:
self.systemd_library_path = systemd_lib_path
self.systemd_ld_library_path = systemd_lib_path

# Set defaults for any unset values
if self.log_dir is None:
Expand All @@ -176,8 +181,10 @@ def set_defaults(self, logger, servers=None, clients=None, provider=None, insecu
self.daos_prefix = self._default_daos_prefix(logger)
if self.agent_user is None:
self.agent_user = self._default_agent_user()
if self.systemd_library_path is None:
self.systemd_library_path = self._default_systemd_library_path()
if self.systemd_path is None:
self.systemd_path = self._default_systemd_path()
if self.systemd_ld_library_path is None:
self.systemd_ld_library_path = self._default_systemd_ld_library_path()

def __set_value(self, key, value):
"""Set the test environment variable.
Expand Down Expand Up @@ -582,36 +589,64 @@ def _default_agent_user():
return 'root'

@property
def systemd_library_path(self):
def systemd_ld_library_path(self):
"""Get the systemd LD_LIBRARY_PATH.

Returns:
str: the systemd LD_LIBRARY_PATH
"""
return os.environ.get(self.__ENV_VAR_MAP['systemd_library_path'])
return os.environ.get(self.__ENV_VAR_MAP['systemd_ld_library_path'])

@systemd_library_path.setter
def systemd_library_path(self, value):
@systemd_ld_library_path.setter
def systemd_ld_library_path(self, value):
"""Set the systemd LD_LIBRARY_PATH.

Args:
value (str): the systemd LD_LIBRARY_PATH
"""
self.__set_value('systemd_library_path', value)
self.__set_value('systemd_ld_library_path', value)

@staticmethod
def _default_systemd_library_path():
def _default_systemd_ld_library_path():
"""Get the default systemd LD_LIBRARY_PATH.

Returns:
str: the default systemd LD_LIBRARY_PATH
"""
return None

@property
def systemd_path(self):
"""Get the systemd PATH.

Returns:
str: the systemd PATH
"""
return os.environ.get(self.__ENV_VAR_MAP['systemd_path'])

@systemd_path.setter
def systemd_path(self, value):
"""Set the systemd PATH.

Args:
value (str): the systemd PATH
"""
self.__set_value('systemd_path', value)

@staticmethod
def _default_systemd_path():
"""Get the default systemd PATH.

Returns:
str: the default systemd PATH
"""
return None


def set_test_environment(logger, test_env=None, servers=None, clients=None, provider=None,
insecure_mode=False, details=None, agent_user=None, log_dir=None,
systemd_lib_path=None):
systemd_path=None, systemd_lib_path=None):
# pylint: disable=too-many-arguments
"""Set up the test environment.

Args:
Expand All @@ -629,7 +664,9 @@ def set_test_environment(logger, test_env=None, servers=None, clients=None, prov
agent_user (str, optional): user account to use when running the daos_agent. Defaults to
None.
log_dir (str, optional): test log directory base path. Defaults to None.
systemd_lib_path (str, optional): systemd library path. Defaults to None.
systemd_path (str, optional): systemd PATH to use w/ tests. Defaults to None.
systemd_lib_path (str, optional): systemd LD_LIBRARY_PATH to use in testing. Defaults
to None.

Raises:
TestEnvironmentException: if there is a problem setting up the test environment
Expand All @@ -641,7 +678,7 @@ def set_test_environment(logger, test_env=None, servers=None, clients=None, prov
if test_env:
# Get the default fabric interface, provider, and daos prefix
test_env.set_defaults(
logger, servers, clients, provider, insecure_mode, agent_user, log_dir,
logger, servers, clients, provider, insecure_mode, agent_user, log_dir, systemd_path,
systemd_lib_path)
logger.info("Testing with interface: %s", test_env.interface)
logger.info("Testing with provider: %s", test_env.provider)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ftest/util/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def _setup_test_directory(self, logger, test):
hosts.add(self.local_host)
logger.debug("Setting up '%s' on %s:", test_env.log_dir, hosts)
commands = [
f"sudo -n rm -fr {test_env.log_dir}",
f"rm -fr {test_env.log_dir}",
f"mkdir -p {test_env.log_dir}",
f"chmod a+wrx {test_env.log_dir}",
f"ls -al {test_env.log_dir}",
Expand Down
6 changes: 4 additions & 2 deletions src/tests/ftest/util/server_utils_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DaosServerCommand(YamlCommand):

DEFAULT_CONFIG_FILE = os.path.join(os.sep, "etc", "daos", "daos_server.yml")

def __init__(self, path="", yaml_cfg=None, timeout=45):
def __init__(self, path="", yaml_cfg=None, timeout=45, run_user=None):
"""Create a daos_server command object.

Args:
Expand All @@ -43,9 +43,11 @@ def __init__(self, path="", yaml_cfg=None, timeout=45):
Defaults to None.
timeout (int, optional): number of seconds to wait for patterns to
appear in the subprocess output. Defaults to 45 seconds.
run_user (str, optional): user to run as. Defaults to None, which will run commands as
the current user.
"""
super().__init__(
"/run/daos_server/*", "daos_server", path, yaml_cfg, timeout)
"/run/daos_server/*", "daos_server", path, yaml_cfg, timeout, run_user)
self.pattern = self.NORMAL_PATTERN

# Command line parameters:
Expand Down
1 change: 1 addition & 0 deletions src/tests/ftest/util/server_utils_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ def __init__(self, base_namespace, index, provider=None, max_storage_tiers=MAX_S
if name in self.REQUIRED_ENV_VARS:
default_env_vars.extend(self.REQUIRED_ENV_VARS[name])
self.env_vars = BasicParameter(None, default_env_vars)
self.env_pass_through = BasicParameter(None, None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we update the systemctl env with LD_LIBRARY_PATH, then we need to pass through LD_LIBRARY_PATH here or otherwise it won't work as expected


# the storage configuration for this engine
self.storage = StorageYamlParameters(self.namespace, max_storage_tiers)
Expand Down
Loading