]> git.lttng.org Git - lttng-tools.git/commitdiff
Tests: Start sessiond in python test environments with `--no-kernel`
authorKienan Stewart <kstewart@efficios.com>
Thu, 7 Nov 2024 13:44:36 +0000 (08:44 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 Dec 2024 15:54:59 +0000 (15:54 +0000)
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 <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/config-directory/test_config.py.in
tests/utils/lttngtest/environment.py

index 11b0ad4a14c1915c9650933358db9d755a3a2726..0ed537805e58be5c9e58cbd63205a75a1c747507 100755 (executable)
@@ -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)
index 91ce28bd074e7fdee61137b5a4b3aa1e8181d446..feee83b52288a2ca332a70937019918b3dc74cd0 100644 (file)
@@ -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
This page took 0.030695 seconds and 4 git commands to generate.