diff --git a/build-tools.Dockerfile b/build-tools.Dockerfile index 89481c1843..39bc9854eb 100644 --- a/build-tools.Dockerfile +++ b/build-tools.Dockerfile @@ -167,32 +167,7 @@ RUN set -ex \ xz-utils \ zlib1g-dev \ zstd \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && git clone --depth 1 --branch v${KERNEL_VERSION} https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git \ - && cd linux \ - && make mrproper \ - && make defconfig \ - && scripts/config --module CONFIG_IKHEADERS \ - && scripts/config --enable CONFIG_MODULE_COMPRESS \ - && scripts/config --disable CONFIG_MODULE_COMPRESS_GZIP \ - && scripts/config --enable CONFIG_MODULE_COMPRESS_ZSTD \ - && make olddefconfig \ - && make WERROR=0 NO_WERROR=1 modules_prepare -j \ - && make WERROR=0 NO_WERROR=1 -j 10 \ - && make WERROR=0 NO_WERROR=1 modules -j10 \ - && mkdir -p /lib/modules/$(uname -r)/build \ - && mkdir -p /lib/modules/$(uname -r)/kernel/kernel \ - && cp -a include arch/${KERNEL_ARCH}/include scripts Module.symvers .config Makefile /lib/modules/$(uname -r)/build/ \ - && make headers_install INSTALL_HDR_PATH=/lib/modules/$(uname -r)/build \ - && mkdir -p /lib/modules/$(uname -r)/build/arch/${KERNEL_ARCH}/include \ - && rsync -a arch/${KERNEL_ARCH}/include /lib/modules/$(uname -r)/build/arch/${KERNEL_ARCH}/ \ - && zstd -19 ./kernel/kheaders.ko -o ./kernel/kheaders.ko.zst \ - && cp -a kernel/kheaders.ko.zst /lib/modules/$(uname -r)/kernel/kernel \ - && find /lib/modules/ -iname "*rwonce.h*" \ - && mkdir -p /virtual/include \ - && cp -a /lib/modules/$(uname -r)/build/include /virtual/include/ \ - && execsnoop-bpfcc \ - && rm -rf linux + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # sql_exporter diff --git a/test_runner/fixtures/utils.py b/test_runner/fixtures/utils.py index 0d7345cc82..0b98f45a84 100644 --- a/test_runner/fixtures/utils.py +++ b/test_runner/fixtures/utils.py @@ -6,6 +6,7 @@ import json import os import re import subprocess +import sys import tarfile import threading import time @@ -717,6 +718,33 @@ def skip_in_debug_build(reason: str): ) +def run_only_on_linux_kernel_higher_than(version: float, reason: str): + """ + Skip tests if the Linux kernel version is lower than the specified version. + The version is specified as a float, e.g. 5.4 for kernel. + + Also skips if the host is not Linux. + """ + + should_skip = False + if sys.platform != "linux": + should_skip = True + else: + try: + kernel_version_list = os.uname()[2].split("-")[0].split(".") + kernel_version = float(f"{kernel_version_list[0]}.{kernel_version_list[1]}") + if kernel_version < version: + should_skip = True + except ValueError: + log.error(f"Failed to parse kernel version: {os.uname()[2]}") + should_skip = True + + return pytest.mark.skipif( + should_skip, + reason=reason, + ) + + def skip_on_ci(reason: str): # `CI` variable is always set to `true` on GitHub # Ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables diff --git a/test_runner/regress/test_compute_profiling.py b/test_runner/regress/test_compute_profiling.py index 145d2d035c..a0de8593dc 100644 --- a/test_runner/regress/test_compute_profiling.py +++ b/test_runner/regress/test_compute_profiling.py @@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any import pytest from data.profile_pb2 import Profile # type: ignore from fixtures.log_helper import log -from fixtures.utils import run_only_on_default_postgres +from fixtures.utils import run_only_on_default_postgres, run_only_on_linux_kernel_higher_than from google.protobuf.message import Message from requests import HTTPError @@ -17,7 +17,9 @@ if TYPE_CHECKING: from fixtures.endpoint.http import EndpointHttpClient from fixtures.neon_fixtures import NeonEnv -REASON = "test doesn't use postgres" +LINUX_VERSION_REQUIRED = 6.0 +PG_REASON = "test doesn't use postgres" +LINUX_REASON = f"test requires linux {LINUX_VERSION_REQUIRED} for ebpfs" def _start_profiling_cpu( @@ -135,7 +137,8 @@ def _wait_and_assert_cpu_profiling(http_client: EndpointHttpClient, event: threa ) -@run_only_on_default_postgres(reason=REASON) +@run_only_on_default_postgres(reason=PG_REASON) +@run_only_on_linux_kernel_higher_than(version=LINUX_VERSION_REQUIRED, reason=LINUX_REASON) def test_compute_profiling_cpu_with_timeout(neon_simple_env: NeonEnv): """ Test that CPU profiling works correctly with timeout. @@ -185,7 +188,8 @@ def test_compute_profiling_cpu_with_timeout(neon_simple_env: NeonEnv): thread2.join(timeout=60) -@run_only_on_default_postgres(reason=REASON) +@run_only_on_default_postgres(reason=PG_REASON) +@run_only_on_linux_kernel_higher_than(version=LINUX_VERSION_REQUIRED, reason=LINUX_REASON) def test_compute_profiling_cpu_with_archiving_the_response(neon_simple_env: NeonEnv): """ Test that CPU profiling works correctly with archiving the data. @@ -199,7 +203,8 @@ def test_compute_profiling_cpu_with_archiving_the_response(neon_simple_env: Neon ) -@run_only_on_default_postgres(reason=REASON) +@run_only_on_default_postgres(reason=PG_REASON) +@run_only_on_linux_kernel_higher_than(version=LINUX_VERSION_REQUIRED, reason=LINUX_REASON) def test_compute_profiling_cpu_start_and_stop(neon_simple_env: NeonEnv): """ Test that CPU profiling can be started and stopped correctly. @@ -225,7 +230,8 @@ def test_compute_profiling_cpu_start_and_stop(neon_simple_env: NeonEnv): thread.join(timeout=60) -@run_only_on_default_postgres(reason=REASON) +@run_only_on_default_postgres(reason=PG_REASON) +@run_only_on_linux_kernel_higher_than(version=LINUX_VERSION_REQUIRED, reason=LINUX_REASON) def test_compute_profiling_cpu_conflict(neon_simple_env: NeonEnv): """ Test that CPU profiling can be started once and the second time @@ -281,7 +287,8 @@ def test_compute_profiling_cpu_conflict(neon_simple_env: NeonEnv): thread2.join(timeout=600) -@run_only_on_default_postgres(reason=REASON) +@run_only_on_default_postgres(reason=PG_REASON) +@run_only_on_linux_kernel_higher_than(version=LINUX_VERSION_REQUIRED, reason=LINUX_REASON) def test_compute_profiling_cpu_stop_when_not_running(neon_simple_env: NeonEnv): """ Test that CPU profiling throws the expected error when is attempted @@ -296,7 +303,8 @@ def test_compute_profiling_cpu_stop_when_not_running(neon_simple_env: NeonEnv): assert status == 412 -@run_only_on_default_postgres(reason=REASON) +@run_only_on_default_postgres(reason=PG_REASON) +@run_only_on_linux_kernel_higher_than(version=LINUX_VERSION_REQUIRED, reason=LINUX_REASON) def test_compute_profiling_cpu_start_arguments_validation_works(neon_simple_env: NeonEnv): """ Test that CPU profiling start request properly validated the