From: Kienan Stewart Date: Thu, 7 Nov 2024 13:44:36 +0000 (-0500) Subject: Tests: Start sessiond in python test environments with `--no-kernel` X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=040bcb88e339d35b847bbee570db86879342c8eb;p=lttng-tools.git Tests: Start sessiond in python test environments with `--no-kernel` Observed issue ============== One of the goals of the lttngtest Environment is to be able to produce separate test environments for each run in order to eventually run some tests in parallel. Solution ======== If `lttng-sessiond` is run as root, by default it will attempt to load the lttng-modules kernel modules. The session daemon is now started with `--no-kernel` to disable the kernel domain and prevent that instance from loading the kernel modules. This behaviour can be changed for specific tests that exercise kernel tracing. Known drawbacks =============== The `--no-kernel` start is less representative of the default usage of the session daemon. Change-Id: Iacb85d0a33d6981bd038d57bf629d61117f9344d Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- diff --git a/tests/regression/tools/config-directory/test_config.py.in b/tests/regression/tools/config-directory/test_config.py.in index 11b0ad4a1..0ed537805 100755 --- a/tests/regression/tools/config-directory/test_config.py.in +++ b/tests/regression/tools/config-directory/test_config.py.in @@ -317,6 +317,7 @@ if __name__ == "__main__": with_relayd=True, extra_env_vars=temp_conf["environment_variables"], skip_temporary_lttng_home=skip_lttng_home, + enable_kernel_domain=lttngtest._Environment.run_kernel_tests(), ) as test_env: test_config_and_socket_paths(test_env, tap, test_identifier, **temp_conf) sys.exit(0 if tap.is_successful else 1) diff --git a/tests/utils/lttngtest/environment.py b/tests/utils/lttngtest/environment.py index 91ce28bd0..feee83b52 100644 --- a/tests/utils/lttngtest/environment.py +++ b/tests/utils/lttngtest/environment.py @@ -642,6 +642,7 @@ class _Environment(logger._Logger): with_relayd=False, # type: bool extra_env_vars=dict(), # type: dict skip_temporary_lttng_home=False, # type: bool + enable_kernel_domain=False, # type: bool ): super().__init__(log) signal.signal(signal.SIGTERM, self._handle_termination_signal) @@ -688,7 +689,7 @@ class _Environment(logger._Logger): print(self._relayd_env_vars) self._sessiond = ( - self._launch_lttng_sessiond() if with_sessiond else None + self._launch_lttng_sessiond(enable_kernel_domain) if with_sessiond else None ) # type: Optional[subprocess.Popen[bytes]] self._dummy_users = {} # type: Dictionary[int, string] @@ -880,6 +881,7 @@ class _Environment(logger._Logger): str(self.lttng_home_location) ) ) + verbose = [] if os.environ.get("LTTNG_TEST_VERBOSE_RELAYD") is not None: verbose = ["-vvv"] @@ -966,7 +968,7 @@ class _Environment(logger._Logger): return process - def _launch_lttng_sessiond(self): + def _launch_lttng_sessiond(self, enable_kernel_domain=False): # type: () -> Optional[subprocess.Popen] is_64bits_host = sys.maxsize > 2**32 @@ -1012,16 +1014,18 @@ class _Environment(logger._Logger): ) ) verbose = [] + sessiond_command = [ + str(sessiond_path), + consumerd_path_option_name, + str(consumerd_path), + "--sig-parent", + ] if os.environ.get("LTTNG_TEST_VERBOSE_SESSIOND") is not None: - verbose = ["-vvv", "--verbose-consumer"] + sessiond_command.extend(["-vvv", "--verbose-consumer"]) + if not enable_kernel_domain: + sessiond_command.extend(["--no-kernel"]) process = subprocess.Popen( - [ - str(sessiond_path), - consumerd_path_option_name, - str(consumerd_path), - "--sig-parent", - ] - + verbose, + sessiond_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=sessiond_env, @@ -1222,10 +1226,16 @@ def test_environment( with_relayd=False, extra_env_vars=dict(), skip_temporary_lttng_home=False, + enable_kernel_domain=False, ): # type: (bool, Optional[Callable[[str], None]], bool) -> Iterator[_Environment] env = _Environment( - with_sessiond, log, with_relayd, extra_env_vars, skip_temporary_lttng_home + with_sessiond, + log, + with_relayd, + extra_env_vars, + skip_temporary_lttng_home, + enable_kernel_domain, ) try: yield env