diff --git a/.gitignore b/.gitignore index 7ea422a..de34e0c 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ examples/aws/credentials.json # Project-specific config (generated by setup configure) run-config.json demo-config.json +pgbench-config.json # Test kernel RPMs (large binary files) setup/test-kernel-rpms/ diff --git a/src/kernel_ci_cloud_labs/providers/aws_provider.py b/src/kernel_ci_cloud_labs/providers/aws_provider.py index 8ae665d..97a0bbd 100644 --- a/src/kernel_ci_cloud_labs/providers/aws_provider.py +++ b/src/kernel_ci_cloud_labs/providers/aws_provider.py @@ -311,7 +311,10 @@ def wait_for_task_completion(self): finishes the kernelci-api node incomplete/Infrastructure with the matched line surfaced in error_msg. * No new VM console output for PULLAB_TASK_HANG_THRESHOLD_SEC seconds - (default 600) -- silent stall, same treatment as a crash. + (default 1200) -- silent stall, same treatment as a crash. The + default accommodates CPU-heavy benchmarks (e.g. UnixBench) whose + console goes quiet for many minutes during a run; lower it via the + env var for faster hang detection on lighter workloads. * Overall PULLAB_TASK_WAIT_TIMEOUT_SEC seconds elapsed (default 3600) -- final safety net for whatever isn't covered above. @@ -331,7 +334,7 @@ def wait_for_task_completion(self): poll_interval = float(os.getenv("PULLAB_TASK_POLL_INTERVAL_SEC") or 30) log_interval = float(os.getenv("PULLAB_TASK_PROGRESS_LOG_SEC") or 120) - hang_threshold = float(os.getenv("PULLAB_TASK_HANG_THRESHOLD_SEC") or 600) + hang_threshold = float(os.getenv("PULLAB_TASK_HANG_THRESHOLD_SEC") or 1200) overall_timeout = float(os.getenv("PULLAB_TASK_WAIT_TIMEOUT_SEC") or 3600) start = time.time() diff --git a/tests/test-in-venv.sh b/tests/test-in-venv.sh index d1d3a1a..9c54c4f 100755 --- a/tests/test-in-venv.sh +++ b/tests/test-in-venv.sh @@ -14,18 +14,27 @@ set -e # Configuration +# PYTHON selects the interpreter used to create the virtual environment. +# Override it to build the venv with a specific version, e.g. +# PYTHON=python3.12 tests/test-in-venv.sh +# It may be a name on PATH or an absolute path. All pip/pytest calls go through +# " -m ..." (never the bare pip/python3 shims). +PYTHON="${PYTHON:-python3}" VENV_DIR=".venv-testing" MODULE_DIR="$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" STATUS_CACHE="$MODULE_DIR/$VENV_DIR/.git_status_cache" +# Interpreter inside the venv (created from $PYTHON). Used for pip/pytest so the +# correct environment is targeted regardless of which binary bootstrapped it. +VENV_PYTHON="$MODULE_DIR/$VENV_DIR/bin/python" # Function to create and setup virtual environment setup_virtual_environment() { - echo "Setting up virtual environment..." - python3 -m venv "${VENV_DIR}" + echo "Setting up virtual environment with '${PYTHON}'..." + "${PYTHON}" -m venv "${VENV_DIR}" source "${VENV_DIR}/bin/activate" - pip install --upgrade pip - pip install -e ".[dev]" + "${VENV_PYTHON}" -m pip install --upgrade pip + "${VENV_PYTHON}" -m pip install -e ".[dev]" } # Function to activate virtual environment @@ -40,7 +49,7 @@ install_module() { echo "Installing module..." 1>&2 status=0 - output=$(pip install -e "${MODULE_DIR}" 2>&1) || status=$? + output=$("${VENV_PYTHON}" -m pip install -e "${MODULE_DIR}" 2>&1) || status=$? if [ $status -ne 0 ]; then echo "Installation failed, with output:" 1>&2 echo "$output" 1>&2 @@ -53,7 +62,7 @@ run_tests() { echo "Running unit tests..." 1>&2 status=0 - output=$(python3 -m pytest tests/ -v -m "not integration" 2>&1) || status=$? + output=$("${VENV_PYTHON}" -m pytest tests/ -v -m "not integration" 2>&1) || status=$? if [ $status -eq 0 ]; then echo "Unit tests passed" 1>&2 else diff --git a/vm-tests/README.md b/vm-tests/README.md index 1180965..725936e 100644 --- a/vm-tests/README.md +++ b/vm-tests/README.md @@ -12,6 +12,7 @@ See the main [README](../README.md) for writing new tests, configuration, and th | `example-kernel-reboot-test` | 3 | yes | Installs two kernels with reboot between each | | `simple-unixbench` | 1 | no | Runs UnixBench on the default kernel | | `unixbench-kernel-regression` | 3 | yes | Installs two kernels, runs UnixBench on each, produces benchmark CSVs | +| `pgbench-kernel-regression` | 3 | yes | Installs two kernels, runs PostgreSQL pgbench (read-only + read-write) on each, produces benchmark CSVs | | `simple-source-reboot` | 2 | yes | Installs kernel from source RPM, reboots, verifies | ## How Multi-Stage Tests Work diff --git a/vm-tests/TODO-shared-lib.md b/vm-tests/TODO-shared-lib.md new file mode 100644 index 0000000..96046b8 --- /dev/null +++ b/vm-tests/TODO-shared-lib.md @@ -0,0 +1,50 @@ +# Shared kernel-management helpers across vm-tests + +## Approach (implemented) + +The kernel install/upgrade helpers live once in: + + vm-tests/lib/kernel_helpers.sh + +Each kernel test includes it with a **symlink** in its own directory: + + vm-tests//kernel_helpers.sh -> ../lib/kernel_helpers.sh + +and its `common_lib.sh` sources it after setting `SOURCE_DIR`: + + source "${SOURCE_DIR}/kernel_helpers.sh" + +Why a symlink works with zero pipeline changes: `upload_test_payload()` builds +the payload with `Path(test_dir).rglob("*")` + `zf.write(...)`, which follows +the symlink and stores the **target's content** as a real file named +`kernel_helpers.sh`. On the VM the payload is extracted flat, so the test dir +gets a normal `kernel_helpers.sh` next to the `run*.sh` scripts. + +Fix once, benefit everywhere: the underscore/dash RPM-version handling, the +FIPS-disable-before-reboot logic, and the `--allowerasing` cross-series install +live only in the shared lib. + +## Status — migration complete + +All kernel tests now source the shared lib and keep only their test-specific +functions in `common_lib.sh`: + +- [x] `pgbench-kernel-regression` — pgbench/PostgreSQL functions local. +- [x] `example-kernel-reboot-test` — no test-specific functions; just sources + the shared lib. +- [x] `simple-source-reboot` — source-RPM build helpers + (`install_source_kernel_rpm`, `build_kernel_rpm_src`, + `get_first_source_kernel_rpm_from_dir`, `install_and_build_kernel`) local. +- [x] `unixbench-kernel-regression` — UnixBench helpers (`prepare_unixbench`, + `run_unixbench`, `summarize_unixbench_log`) local. + +`simple-unixbench` and other non-kernel tests do not install kernels and do not +use the shared lib. + +## Adding a new kernel test + +1. `cd vm-tests/ && ln -s ../lib/kernel_helpers.sh kernel_helpers.sh` +2. In `common_lib.sh`, `source "${SOURCE_DIR}/kernel_helpers.sh"` and add only + test-specific functions. +3. Verify: `bash -n common_lib.sh` and a source-order smoke test with + `SOURCE_DIR` set. diff --git a/vm-tests/example-kernel-reboot-test/common_lib.sh b/vm-tests/example-kernel-reboot-test/common_lib.sh index 20d3868..fa5894b 100644 --- a/vm-tests/example-kernel-reboot-test/common_lib.sh +++ b/vm-tests/example-kernel-reboot-test/common_lib.sh @@ -2,253 +2,11 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -# Common functions for kernel reboot test - -# Get results bucket and test paths from environment -RESULTS_BUCKET="${S3_BUCKET:-}" -ARCH=$(uname -m) -KERNEL_RPM_DIR="/tmp/kernel-rpms" - -# Validate required environment variables -if [ -z "$RESULTS_BUCKET" ] || [ -z "$RUN_PREFIX" ] || [ -z "$TEST_NAME" ]; then - echo "ERROR: Missing required environment variables (S3_BUCKET, RUN_PREFIX, TEST_NAME)" >&2 - exit 1 -fi - -# Error trap handler to show line where error occurred -error_trap() -{ - local exit_code=$? - local line_number=$1 - echo "$(date): ERROR: Script failed at line $line_number with exit code $exit_code" - echo "$(date): ERROR: Command that failed: $(sed -n "${line_number}p" "$0")" - exit $exit_code -} -trap 'error_trap $LINENO' ERR - -#Return current runnning kernel -get_running_kernel() -{ - uname -r -} - -# Install a single given package -install_package() -{ - local pkg="$1" - local output - echo "Installing package $pkg ..." - if output=$(sudo yum install -y "$pkg" 2>&1) || output=$(sudo dnf install -y "$pkg" 2>&1); then - return 0 - else - echo "Failed to install package $pkg:" - echo "$output" - return 1 - fi -} - -# Install all dependencies for this test -install_test_dependencies() -{ - local deps_file="${SOURCE_DIR}/dependencies.txt" - - if [ -f "$deps_file" ]; then - while IFS= read -r pkg || [ -n "$pkg" ]; do - # Skip empty lines and comments - [[ -z "$pkg" || "$pkg" =~ ^[[:space:]]*# ]] && continue - - # Remove leading/trailing whitespace - pkg=$(echo "$pkg" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') - - # Install package if not empty - if [ -n "$pkg" ]; then - install_package "$pkg" || return 1 - fi - done <"$deps_file" - else - # Fallback to hardcoded dependencies - install_package gcc make tar || return 1 - fi -} - -# List available kernels from S3 -list_kernels_from_s3() -{ - S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/binary/${ARCH}/" - aws s3 ls "${S3_PATH}" | grep "\.rpm$" | awk '{print $4}' -} - -# Download specific kernel RPM from S3 -download_kernel_rpm() -{ - if [ -z "${1:-}" ]; then - echo "ERROR: download_kernel_rpm requires kernel_name parameter" >&2 - return 1 - fi - local kernel_name="$1" - - S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/binary/${ARCH}/" - - mkdir -p "$KERNEL_RPM_DIR" - local local_path="${KERNEL_RPM_DIR}/${kernel_name}" - - # Download if not already present - if [ -f "$local_path" ]; then - echo "$local_path" - return 0 - fi - - if aws s3 cp "${S3_PATH}${kernel_name}" "$local_path" --no-progress >&2; then - echo "$local_path" - return 0 - else - echo "ERROR: Failed to download kernel" >&2 - return 1 - fi -} - -# Dump boot configuration for debugging kernel install issues -dump_boot_info() -{ - echo "=== Boot Debug Info ===" - echo "--- OS ---" - head -2 /etc/os-release 2>/dev/null || true - echo "--- Running kernel ---" - uname -r - echo "--- Installed kernel packages ---" - rpm -qa 'kernel*' | sort - echo "--- vmlinuz files in /boot ---" - ls -la /boot/vmlinuz-* 2>/dev/null || echo "(none)" - echo "--- BLS entries ---" - ls -la /boot/loader/entries/ 2>/dev/null || echo "(no BLS directory)" - echo "--- grubby default ---" - sudo grubby --default-kernel 2>/dev/null || echo "(grubby --default-kernel failed)" - echo "--- grubby --info=ALL ---" - sudo grubby --info=ALL 2>/dev/null || echo "(grubby --info=ALL failed)" - echo "=== End Boot Debug Info ===" -} - -# Install kernel RPM, make sure it's used as boot target -install_kernel_rpm() -{ - if [ -z "${1:-}" ]; then - echo "ERROR: install_kernel_rpm requires kernel_rpm parameter" >&2 - return 1 - fi - local kernel_rpm="$1" - - # Check architecture compatibility - local host_arch=$(uname -m) - local rpm_arch=$(rpm -qp --queryformat '%{ARCH}' "$kernel_rpm" 2>/dev/null) - - if [ "$rpm_arch" != "$host_arch" ]; then - echo "ERROR: Architecture mismatch - Host: $host_arch, RPM: $rpm_arch" >&2 - return 1 - fi - - echo "kernel before installation: $(uname -r)" - echo "Installing kernel from $kernel_rpm (arch: $rpm_arch)" - - if sudo yum localinstall -y "$kernel_rpm" 2>/dev/null || sudo dnf install -y "$kernel_rpm" 2>/dev/null; then - dump_boot_info - - # Set the newly installed kernel as default boot target. - # Without this, GRUB boots the newest kernel which may not be the one we just installed. - local installed_version - installed_version=$(rpm -qp --queryformat '%{VERSION}' "$kernel_rpm" 2>/dev/null) - - # Find the grubby entry matching the installed kernel version. - # Use grep || true to avoid ERR trap when no match is found. - local grub_kernel - grub_kernel=$(sudo grubby --info=ALL 2>/dev/null \ - | grep "^kernel=" \ - | grep "$installed_version" \ - | head -1 \ - | sed 's/^kernel=//' \ - | tr -d '"' \ - || true) - - if [ -z "$grub_kernel" ]; then - # Upstream make binrpm-pkg kernels don't register with grubby. - # Find the vmlinuz file and add a boot entry manually. - local vmlinuz - vmlinuz=$(ls /boot/vmlinuz-*"$installed_version"* 2>/dev/null | head -1) - if [ -n "$vmlinuz" ]; then - echo "Adding grubby entry for $vmlinuz" - local initrd="/boot/initramfs-${installed_version}.img" - if [ ! -f "$initrd" ]; then - echo "Generating initramfs at $initrd" - sudo dracut --force "$initrd" "$installed_version" 2>/dev/null \ - || sudo mkinitrd "$initrd" "$installed_version" 2>/dev/null \ - || true - fi - if [ -f "$initrd" ]; then - sudo grubby --add-kernel="$vmlinuz" \ - --initrd="$initrd" \ - --title="Linux $installed_version" \ - --copy-default \ - --make-default - echo "✓ Added and set default: $vmlinuz" - else - echo "WARNING: No initramfs for $installed_version, trying set-default anyway" - sudo grubby --set-default="$vmlinuz" || true - fi - grub_kernel="$vmlinuz" - else - echo "WARNING: No vmlinuz found for version $installed_version" - fi - else - echo "Setting default boot kernel to $grub_kernel" - sudo grubby --set-default="$grub_kernel" - fi - - if [ -n "$grub_kernel" ]; then - echo "Verifying default kernel:" - sudo grubby --default-kernel - fi - return 0 - else - echo "ERROR: Failed to install new kernel" >&2 - return 1 - fi -} - -# Return kernel RPM with lowest version (downloads from S3) -get_first_kernel_rpm_from_dir() -{ - local kernels=$(list_kernels_from_s3 | sort -V) - local first_kernel=$(echo "$kernels" | head -n 1) - - if [ -z "$first_kernel" ]; then - return 1 - fi - - download_kernel_rpm "$first_kernel" -} - -# Return kernel RPM with highest version (downloads from S3) -get_last_kernel_rpm_from_dir() -{ - local kernels=$(list_kernels_from_s3 | sort -V) - local last_kernel=$(echo "$kernels" | tail -n 1) - - if [ -z "$last_kernel" ]; then - return 1 - fi - - download_kernel_rpm "$last_kernel" -} - -# Install a given kernel RPM (passed as argument) -install_specified_kernel_rpm() -{ - local kernel_rpm="$1" - - if [ -z "$kernel_rpm" ]; then - echo "ERROR: install_specified_kernel_rpm requires a kernel RPM path" - return 1 - fi - - echo "Installing kernel RPM: $(basename "$kernel_rpm")" - install_kernel_rpm "$kernel_rpm" -} +# Common functions for the kernel reboot test. +# +# All kernel-management logic (environment validation, kernel RPM +# download/selection, install_kernel_rpm, reboot helpers) lives in the shared +# vm-tests/lib/kernel_helpers.sh, included here via the kernel_helpers.sh +# symlink in this directory. SOURCE_DIR is set by the run script before this +# file is sourced. +source "${SOURCE_DIR}/kernel_helpers.sh" diff --git a/vm-tests/example-kernel-reboot-test/kernel_helpers.sh b/vm-tests/example-kernel-reboot-test/kernel_helpers.sh new file mode 120000 index 0000000..31ff984 --- /dev/null +++ b/vm-tests/example-kernel-reboot-test/kernel_helpers.sh @@ -0,0 +1 @@ +../lib/kernel_helpers.sh \ No newline at end of file diff --git a/vm-tests/lib/kernel_helpers.sh b/vm-tests/lib/kernel_helpers.sh new file mode 100644 index 0000000..244ea45 --- /dev/null +++ b/vm-tests/lib/kernel_helpers.sh @@ -0,0 +1,331 @@ +# Authors: Norbert Manthey +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Shared kernel-management helpers for vm-tests that install and boot a kernel +# RPM from the pipeline's shared kernel-rpms area. +# +# Sourced by a test's common_lib.sh (which sets SOURCE_DIR first). It packages +# into each test payload via a symlink `kernel_helpers.sh -> ../lib/kernel_helpers.sh` +# in the test directory; the zip step stores the symlink target's content as a +# real file, so on the VM this is a normal file in the flat test dir. +# +# Fix once, benefit everywhere: the underscore/dash RPM-version handling and the +# FIPS-disable-before-reboot logic live here, so all kernel tests share them. + +# --------------------------------------------------------------------------- +# Results bucket and kernel paths from the pipeline environment. +RESULTS_BUCKET="${S3_BUCKET:-}" +ARCH=$(uname -m) +KERNEL_RPM_DIR="/tmp/kernel-rpms" +KERNEL_FILE="${SOURCE_DIR}/kernel_version_before.txt" + +# Validate required environment variables +if [ -z "$RESULTS_BUCKET" ] || [ -z "$RUN_PREFIX" ] || [ -z "$TEST_NAME" ]; then + echo "ERROR: Missing required environment variables (S3_BUCKET, RUN_PREFIX, TEST_NAME)" >&2 + exit 1 +fi + +get_running_kernel() +{ + uname -r +} + +# A build-level fingerprint of the *running* kernel, used to detect that a +# reboot actually switched kernels even when two builds share the same NVR +# (uname -r). +# +# Combines: +# - uname -r : release (NVR); distinguishes normal version bumps. +# - uname -v : build version string, which embeds the build date/time and +# so differs between two builds of the same NVR. +# - sha256 of the booted /boot/vmlinuz- as a strong fallback when +# uname -v happens to match (or is unavailable). +get_running_kernel_id() +{ + local rel ver img_hash="" vmlinuz + rel="$(uname -r)" + ver="$(uname -v)" + vmlinuz="/boot/vmlinuz-${rel}" + if [ -r "$vmlinuz" ] && command -v sha256sum >/dev/null 2>&1; then + img_hash="$(sha256sum "$vmlinuz" 2>/dev/null | awk '{print $1}')" + fi + # Single-line, stable identity string. + echo "${rel}|${ver}|${img_hash}" +} + +save_kernel_version() +{ + local version="$1" + local out_file="$2" + if [ -z "$version" ] || [ -z "$out_file" ]; then + echo "ERROR: save_kernel_version requires version and file" >&2 + return 1 + fi + echo "$version" >"$out_file" +} + +load_kernel_version() +{ + local in_file="$1" + if [ ! -f "$in_file" ]; then + echo "ERROR: Kernel version file not found: $in_file" >&2 + return 1 + fi + cat "$in_file" +} + +assert_kernel_changed() +{ + local before="$1" + local after="$2" + if [ "$before" = "$after" ]; then + echo "ERROR: kernel did not change after reboot (still: $after)" >&2 + echo " If the two kernels share a version-release (NVR) but differ" >&2 + echo " in build (e.g. compiler A/B), ensure run-01 force-reinstalls" >&2 + echo " the RPM and that get_running_kernel_id is used for before/after." >&2 + return 1 + fi + echo "Kernel changed after reboot:" + echo " before: $before" + echo " after: $after" +} + +# List available kernel RPMs from the shared S3 area. +list_kernels_from_s3() +{ + S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/binary/${ARCH}/" + aws s3 ls "${S3_PATH}" | grep "\.rpm$" | awk '{print $4}' +} + +# Download a specific kernel RPM from S3. +download_kernel_rpm() +{ + if [ -z "${1:-}" ]; then + echo "ERROR: download_kernel_rpm requires kernel_name parameter" >&2 + return 1 + fi + local kernel_name="$1" + S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/binary/${ARCH}/" + mkdir -p "$KERNEL_RPM_DIR" + local local_path="${KERNEL_RPM_DIR}/${kernel_name}" + if [ -f "$local_path" ]; then + echo "$local_path" + return 0 + fi + if aws s3 cp "${S3_PATH}${kernel_name}" "$local_path" --no-progress >&2; then + echo "$local_path" + return 0 + else + echo "ERROR: Failed to download kernel" >&2 + return 1 + fi +} + +# Error trap handler to show line where error occurred +error_trap() +{ + local exit_code=$? + local line_number=$1 + echo "$(date): ERROR: Script failed at line $line_number with exit code $exit_code" + echo "$(date): ERROR: Command that failed: $(sed -n "${line_number}p" "$0")" + exit $exit_code +} +trap 'error_trap $LINENO' ERR + +# Install a single given package +install_package() +{ + local pkg="$1" + local output + echo "Installing package $pkg ..." + if output=$(sudo yum install -y "$pkg" 2>&1) || output=$(sudo dnf install -y "$pkg" 2>&1); then + return 0 + else + echo "Failed to install package $pkg:" + echo "$output" + return 1 + fi +} + +# Install all dependencies for this test +install_test_dependencies() +{ + local deps_file="${SOURCE_DIR}/dependencies.txt" + if [ -f "$deps_file" ]; then + while IFS= read -r pkg || [ -n "$pkg" ]; do + [[ -z "$pkg" || "$pkg" =~ ^[[:space:]]*# ]] && continue + pkg=$(echo "$pkg" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + [ -n "$pkg" ] && { install_package "$pkg" || return 1; } + done <"$deps_file" + else + echo "ERROR: dependencies.txt not found" >&2 + return 1 + fi +} + +# List available kernels from S3, dump boot info, install a kernel RPM and make +# it the default boot target. +dump_boot_info() +{ + echo "=== Boot Debug Info ===" + echo "--- OS ---" + head -2 /etc/os-release 2>/dev/null || true + echo "--- Running kernel ---" + uname -r + echo "--- Installed kernel packages ---" + rpm -qa 'kernel*' | sort + echo "--- vmlinuz files in /boot ---" + ls -la /boot/vmlinuz-* 2>/dev/null || echo "(none)" + echo "--- grubby default ---" + sudo grubby --default-kernel 2>/dev/null || echo "(grubby --default-kernel failed)" + echo "=== End Boot Debug Info ===" +} + +install_kernel_rpm() +{ + if [ -z "${1:-}" ]; then + echo "ERROR: install_kernel_rpm requires kernel_rpm parameter" >&2 + return 1 + fi + local kernel_rpm="$1" + + local host_arch=$(uname -m) + local rpm_arch=$(rpm -qp --queryformat '%{ARCH}' "$kernel_rpm" 2>/dev/null) + if [ "$rpm_arch" != "$host_arch" ]; then + echo "ERROR: Architecture mismatch - Host: $host_arch, RPM: $rpm_arch" >&2 + return 1 + fi + + echo "kernel before installation: $(uname -r)" + echo "Installing kernel from $kernel_rpm (arch: $rpm_arch)" + + # Install the kernel RPM. Two wrinkles this must handle: + # + # 1. Same NVR, different build: compiler/optimization A/B kernels can share + # the exact version-release string while carrying different + # code/binaries. A plain "dnf install" of an already-present NVR is a + # no-op ("Nothing to do"), which would leave the old build in place. + # Detect that case and force a reinstall so the new vmlinuz/modules are + # actually written. + # 2. Cross-series conflict: on an AMI whose default kernel is a different + # series (e.g. a 6.18 AMI when installing a 6.1 kernel), the distro + # kernel-tools package conflicts with "kernel-uname-r < ", so a + # plain install is refused; fall back to --allowerasing. + local rpm_nvr + rpm_nvr=$(rpm -qp --queryformat '%{NAME}-%{VERSION}-%{RELEASE}' "$kernel_rpm" 2>/dev/null) + local install_ok=1 + if rpm -q "$rpm_nvr" >/dev/null 2>&1; then + # Same NVR already installed — force reinstall so a different build of + # the same version actually replaces the on-disk kernel image/modules. + echo "Package $rpm_nvr already installed; forcing reinstall (build may differ)" + sudo dnf reinstall -y "$kernel_rpm" 2>/dev/null \ + || sudo rpm -Uvh --force "$kernel_rpm" 2>/dev/null \ + || install_ok=0 + else + sudo dnf install -y "$kernel_rpm" 2>/dev/null \ + || sudo yum localinstall -y "$kernel_rpm" 2>/dev/null \ + || sudo dnf install -y --allowerasing "$kernel_rpm" 2>/dev/null \ + || install_ok=0 + fi + if [ "$install_ok" -eq 1 ]; then + dump_boot_info + local installed_version + installed_version=$(rpm -qp --queryformat '%{VERSION}' "$kernel_rpm" 2>/dev/null) + # RPM VERSION may use underscores (e.g. 6.18.41_nogup) while the kernel + # LOCALVERSION uses dashes (vmlinuz-6.18.41-nogup). Try both variants. + local installed_version_alt="${installed_version//_/-}" + + local grub_kernel + grub_kernel=$(sudo grubby --info=ALL 2>/dev/null \ + | grep "^kernel=" \ + | grep -E "$installed_version|$installed_version_alt" \ + | head -1 \ + | sed 's/^kernel=//' \ + | tr -d '"' \ + || true) + + if [ -z "$grub_kernel" ]; then + local vmlinuz + vmlinuz=$(ls /boot/vmlinuz-*"$installed_version"* 2>/dev/null | head -1) + if [ -z "$vmlinuz" ] && [ "$installed_version_alt" != "$installed_version" ]; then + vmlinuz=$(ls /boot/vmlinuz-*"$installed_version_alt"* 2>/dev/null | head -1) + fi + if [ -n "$vmlinuz" ]; then + echo "Adding grubby entry for $vmlinuz" + # Derive the kernel version from the vmlinuz filename + local kver="${vmlinuz#/boot/vmlinuz-}" + local initrd="/boot/initramfs-${kver}.img" + if [ ! -f "$initrd" ]; then + echo "Generating initramfs at $initrd for kernel $kver" + sudo dracut --force "$initrd" "$kver" 2>/dev/null \ + || sudo mkinitrd "$initrd" "$kver" 2>/dev/null \ + || true + fi + if [ -f "$initrd" ]; then + sudo grubby --add-kernel="$vmlinuz" \ + --initrd="$initrd" \ + --title="Linux $kver" \ + --args="fips=0" \ + --copy-default \ + --make-default + echo "Added and set default: $vmlinuz" + else + echo "WARNING: No initramfs for $kver, trying set-default anyway" + sudo grubby --set-default="$vmlinuz" || true + fi + grub_kernel="$vmlinuz" + else + echo "WARNING: No vmlinuz found for version $installed_version" + fi + else + echo "Setting default boot kernel to $grub_kernel" + sudo grubby --set-default="$grub_kernel" + fi + + if [ -n "$grub_kernel" ]; then + echo "Verifying default kernel:" + sudo grubby --default-kernel + fi + + # Disable FIPS mode system-wide before rebooting into a custom kernel. + # Some AL2023 enable FIPS; unsigned modules (from make binrpm-pkg) + # fail signature verification and cause a kernel panic. + if command -v fips-mode-setup &>/dev/null; then + echo "Disabling FIPS mode for custom kernel boot" + sudo fips-mode-setup --disable 2>/dev/null || true + fi + + return 0 + else + echo "ERROR: Failed to install new kernel" >&2 + return 1 + fi +} + +get_first_kernel_rpm_from_dir() +{ + local kernels=$(list_kernels_from_s3 | sort -V) + local first_kernel=$(echo "$kernels" | head -n 1) + [ -z "$first_kernel" ] && return 1 + download_kernel_rpm "$first_kernel" +} + +get_last_kernel_rpm_from_dir() +{ + local kernels=$(list_kernels_from_s3 | sort -V) + local last_kernel=$(echo "$kernels" | tail -n 1) + [ -z "$last_kernel" ] && return 1 + download_kernel_rpm "$last_kernel" +} + +install_specified_kernel_rpm() +{ + local kernel_rpm="$1" + if [ -z "$kernel_rpm" ]; then + echo "ERROR: install_specified_kernel_rpm requires a kernel RPM path" >&2 + return 1 + fi + echo "Installing kernel RPM: $(basename "$kernel_rpm")" + install_kernel_rpm "$kernel_rpm" +} diff --git a/vm-tests/pgbench-kernel-regression/README.md b/vm-tests/pgbench-kernel-regression/README.md new file mode 100644 index 0000000..3adda28 --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/README.md @@ -0,0 +1,58 @@ +# PostgreSQL pgbench Kernel Regression Test + +Kernel A/B performance regression test using PostgreSQL's `pgbench`. It installs +two kernels in turn on a **single VM** and runs the same read-only and +read-write `pgbench` workload against each, so the pipeline's benchmark analyzer +can flag database-performance regressions between kernel versions. It follows +the same three-stage pattern as `unixbench-kernel-regression`. + +- Dependencies are installed from `dependencies.txt` at run time (not from test + metadata). +- Results are emitted as `benchmark-*.csv` in the schema the pipeline already + supports + +## Test Flow + +1. **run-01-setup-kernel-A.sh** — install PostgreSQL packages, record the running + kernel, install the first (lowest-version) kernel RPM from the shared + `kernel-rpms` area, then reboot. +2. **run-02-run-pgbench-setup-kernel-B.sh** — confirm the kernel changed, run + `pgbench` (read-only + read-write) on the base kernel, then install the second + (highest-version) kernel and reboot. +3. **run-03-run-second-pgbench.sh** — confirm the kernel changed, run `pgbench` + on the tip kernel. + +Single VM, CPU-pinned: PostgreSQL is pinned to the first half of the cores and +the `pgbench` client to the second half, to reduce client/server interference. + +## Output + +- `benchmark-base-.csv` — metrics for the first (base) kernel. +- `benchmark-tip-.csv` — metrics for the second (tip) kernel. + +CSV columns: `metric,unit,value,more_is_better,kernel_version,instance_id,instance_type,arch` + +Metrics captured (per kernel): +- `postgresql.readonly.tps` / `postgresql.readwrite.tps`: transactions/sec (more is better). +- `postgresql.readonly.latency_avg` / `postgresql.readwrite.latency_avg`: average latency in ms (less is better). + +The pipeline's benchmark analyzer compares the base and tip CSVs and reports +regressions. + +## Requirements + +- x86_64 or aarch64 instance with at least 4 vCPUs (CPU pinning splits + server/client across the two halves); `c8i.4xlarge` recommended, `us-west-2` + preferred to raise the chance of landing on the same hardware for both kernels. +- Two kernel RPMs uploaded to the shared kernel-rpms area + (`external_requirements.json` sets `kernel-rpms/binary: true`). The lowest + version becomes the base, the highest becomes the tip. +- System packages from `dependencies.txt` (`postgresql16-server`, + `postgresql16-contrib`, `postgresql16`) are installed in run-01. + +## Configuration (environment overrides) + +| Variable | Default | Purpose | +|---|---|---| +| `PGBENCH_DURATION` | `240` | Duration in seconds of each pgbench run. | +| `PGBENCH_SCALING_FACTOR` | `100` | Database size multiplier passed to `pgbench -i -s`. | diff --git a/vm-tests/pgbench-kernel-regression/common_lib.sh b/vm-tests/pgbench-kernel-regression/common_lib.sh new file mode 100644 index 0000000..4d27ac4 --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/common_lib.sh @@ -0,0 +1,213 @@ +# Authors: Norbert Manthey +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Common library for the pgbench PostgreSQL kernel A/B benchmark. +# +# The kernel-management half (install first/last kernel from the shared +# kernel-rpms area, reboot between stages, assert the running kernel changed) +# is reused from the unixbench-kernel-regression test so behaviour stays +# consistent across the benchmark suites. The PostgreSQL specifics are in this +# file. Results are written as the same benchmark-*.csv the pipeline's benchmark +# analyzer supports. + +# --------------------------------------------------------------------------- +# Configuration (overridable via environment) +# --------------------------------------------------------------------------- +PGBENCH_DURATION="${PGBENCH_DURATION:-240}" +PGBENCH_SCALING_FACTOR="${PGBENCH_SCALING_FACTOR:-100}" + +PGDATA="/tmp/pgdata" +PGPORT=5432 +PGDATABASE="pgbench" +export PGDATA PGPORT + +NUM_CPUS=$(nproc) +HALF_CPUS=$((NUM_CPUS / 2)) +# Single VM with CPU pinning: PostgreSQL on the first half of the cores, +# pgbench client on the second half, to reduce client/server interference. +SERVER_CPUS="0-$((HALF_CPUS - 1))" +CLIENT_CPUS="${HALF_CPUS}-$((NUM_CPUS - 1))" + +# --------------------------------------------------------------------------- +# Kernel management (shared across kernel A/B tests) +# --------------------------------------------------------------------------- +# Sets RESULTS_BUCKET/ARCH/KERNEL_RPM_DIR/KERNEL_FILE, validates the pipeline +# environment, and defines the kernel install/reboot helpers. SOURCE_DIR must +# already be set by the run script before this file is sourced. +source "${SOURCE_DIR}/kernel_helpers.sh" + +# --------------------------------------------------------------------------- +# PostgreSQL / pgbench (test-specific) +# --------------------------------------------------------------------------- +run_as_postgres() +{ + if [ "$(id -u)" -eq 0 ]; then + sudo -u postgres "$@" + else + "$@" + fi +} + +# Shared-buffer size: 25% of RAM, capped at 4GB, floored at 128MB. +get_shared_buffer_size() +{ + local mem_kb buffer_mb + mem_kb=$(awk '/^MemTotal:/{print $2}' /proc/meminfo) + buffer_mb=$((mem_kb / 1024 / 4)) + [ "$buffer_mb" -gt 4096 ] && buffer_mb=4096 + [ "$buffer_mb" -lt 128 ] && buffer_mb=128 + echo "$buffer_mb" +} + +setup_postgresql() +{ + echo "Initializing PostgreSQL database cluster..." + rm -rf "$PGDATA" + mkdir -p "$PGDATA" + + if [ "$(id -u)" -eq 0 ]; then + id postgres &>/dev/null || sudo useradd -r postgres + sudo chown -R postgres:postgres "$PGDATA" + fi + + run_as_postgres /usr/bin/initdb -D "$PGDATA" --encoding=SQL_ASCII --locale=C + + local shared_buffers max_connections + shared_buffers=$(get_shared_buffer_size) + max_connections=$((NUM_CPUS * 4 + 100)) + + cat >>"$PGDATA/postgresql.conf" <"$PGDATA/pg_hba.conf" <>"$PGDATA/logfile" 2>&1 & + + local i + for i in {1..30}; do + sleep 1 + /usr/bin/pg_isready -h localhost -p "$PGPORT" && break + done + if ! /usr/bin/pg_isready -h localhost -p "$PGPORT"; then + echo "ERROR: PostgreSQL failed to start:" >&2 + cat "$PGDATA/logfile" >&2 + return 1 + fi + + run_as_postgres /usr/bin/createdb -h localhost -p "$PGPORT" "$PGDATABASE" + echo "PostgreSQL started" +} + +init_pgbench() +{ + local scaling_factor="${1:-$PGBENCH_SCALING_FACTOR}" + echo "Initializing pgbench tables (scaling factor: $scaling_factor)..." + run_as_postgres /usr/bin/pgbench -h localhost -p "$PGPORT" -i -s "$scaling_factor" "$PGDATABASE" +} + +# Run one pgbench mode (readonly|readwrite) into output_file. +run_pgbench() +{ + local mode="$1" + local output_file="$2" + local duration="${3:-$PGBENCH_DURATION}" + + local clients threads mode_flag="" + [ "$mode" = "readonly" ] && mode_flag="-S" + clients=$((HALF_CPUS * 2)) + threads=$HALF_CPUS + + echo "Running pgbench $mode (clients=$clients, threads=$threads, duration=${duration}s)" + run_as_postgres taskset -c "$CLIENT_CPUS" /usr/bin/pgbench \ + -h localhost -p "$PGPORT" --protocol=prepared \ + -c "$clients" -j "$threads" -T "$duration" -r $mode_flag \ + "$PGDATABASE" >"$output_file" 2>&1 +} + +stop_postgresql() +{ + echo "Stopping PostgreSQL..." + run_as_postgres /usr/bin/pg_ctl -D "$PGDATA" stop -m fast 2>/dev/null || true +} + +# Set up PostgreSQL, run the read-only and read-write benchmarks into +# results_dir, then stop PostgreSQL. Requires at least 4 CPUs. +run_pgbench_suite() +{ + local results_dir="$1" + if [ "$(nproc)" -lt 4 ]; then + echo "ERROR: pgbench benchmark requires at least 4 CPUs" >&2 + return 1 + fi + mkdir -p "$results_dir" + + setup_postgresql + init_pgbench "$PGBENCH_SCALING_FACTOR" + + local mode output + for mode in readonly readwrite; do + echo "=== Running $mode benchmark ===" + output="$results_dir/pgbench_${mode}.txt" + run_pgbench "$mode" "$output" + cat "$output" + done + + stop_postgresql +} + +# Parse pgbench read-only and read-write output into a benchmark CSV that the +# pipeline's benchmark analyzer consumes (same schema as the unixbench test): +# metric,unit,value,more_is_better,kernel_version,instance_id,instance_type,arch +summarize_pgbench_output() +{ + local readonly_file="$1" + local readwrite_file="$2" + local output_csv_file="$3" + + local kernel_version instance_id instance_type arch + kernel_version=$(uname -r) + instance_id=$(ec2-metadata --instance-id 2>/dev/null | cut -d" " -f2 || hostname || echo "unknown") + instance_type=$(ec2-metadata --instance-type 2>/dev/null | cut -d" " -f2 || echo "unknown") + arch=$(uname -m) + + echo "metric,unit,value,more_is_better,kernel_version,instance_id,instance_type,arch" >"$output_csv_file" + + local mode file tps latency + for mode in readonly readwrite; do + [ "$mode" = "readonly" ] && file="$readonly_file" || file="$readwrite_file" + [ -f "$file" ] || { echo "WARNING: $file not found, skipping $mode" >&2; continue; } + + # "tps = NNN (without initial connection time)" / "(excluding connections establishing)" + tps=$(grep "tps = " "$file" | grep -E "(excluding|without)" | awk '{print $3}' | head -1 || true) + # "latency average = NNN ms" + latency=$(grep "latency average" "$file" | awk '{print $4}' | head -1 || true) + + [ -n "$tps" ] && \ + echo "postgresql.${mode}.tps,TPS,${tps},true,${kernel_version},${instance_id},${instance_type},${arch}" >>"$output_csv_file" + [ -n "$latency" ] && \ + echo "postgresql.${mode}.latency_avg,ms,${latency},false,${kernel_version},${instance_id},${instance_type},${arch}" >>"$output_csv_file" + done +} diff --git a/vm-tests/pgbench-kernel-regression/dependencies.txt b/vm-tests/pgbench-kernel-regression/dependencies.txt new file mode 100644 index 0000000..7552a0a --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/dependencies.txt @@ -0,0 +1,5 @@ +# Packages required to run the pgbench PostgreSQL benchmark. +# Provides initdb, postgres, pgbench, pg_isready, createdb and pg_ctl in /usr/bin. +postgresql16-server +postgresql16-contrib +postgresql16 diff --git a/vm-tests/pgbench-kernel-regression/external_requirements.json b/vm-tests/pgbench-kernel-regression/external_requirements.json new file mode 100644 index 0000000..fd217a4 --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/external_requirements.json @@ -0,0 +1,4 @@ +{ + "kernel-rpms/src": false, + "kernel-rpms/binary": true +} diff --git a/vm-tests/pgbench-kernel-regression/kernel_helpers.sh b/vm-tests/pgbench-kernel-regression/kernel_helpers.sh new file mode 120000 index 0000000..31ff984 --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/kernel_helpers.sh @@ -0,0 +1 @@ +../lib/kernel_helpers.sh \ No newline at end of file diff --git a/vm-tests/pgbench-kernel-regression/run-01-setup-kernel-A.sh b/vm-tests/pgbench-kernel-regression/run-01-setup-kernel-A.sh new file mode 100755 index 0000000..db5ef2c --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/run-01-setup-kernel-A.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Authors: Norbert Manthey +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# +# First run: install PostgreSQL dependencies and the first (lower-version) +# kernel to test. The client reboots into it before run-02. + +set -euxo pipefail + +# Set source directory and source common library for functions and constants +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SOURCE_DIR}/common_lib.sh" + +# Install PostgreSQL packages (from dependencies.txt, not test metadata). +install_test_dependencies + +# Save a build-level identity of the kernel running before we install kernel A. +# get_running_kernel_id combines uname -r + uname -v + the booted vmlinuz hash, +# so it detects a real kernel switch even when two builds share the same NVR +# (e.g. compiler A/B kernels). +kernel_before="$(get_running_kernel_id)" +echo "Kernel before installation: $kernel_before" +save_kernel_version "$kernel_before" "$KERNEL_FILE" + +# Install the kernel with the lower version as the kernel to be used next. +first_kernel=$(get_first_kernel_rpm_from_dir) +install_specified_kernel_rpm "$first_kernel" + +# Stop here; re-execution happens after reboot and continues in run-02-*.sh diff --git a/vm-tests/pgbench-kernel-regression/run-02-run-pgbench-setup-kernel-B.sh b/vm-tests/pgbench-kernel-regression/run-02-run-pgbench-setup-kernel-B.sh new file mode 100755 index 0000000..3b44d7c --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/run-02-run-pgbench-setup-kernel-B.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Authors: Norbert Manthey +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# +# Second run: run pgbench on the first (base) kernel, then install the second +# (higher-version) kernel to test. + +set -euxo pipefail + +# Set source directory and source common library for functions and constants +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SOURCE_DIR}/common_lib.sh" + +# Confirm the kernel actually changed after the reboot from run-01. Use the +# build-level identity so a same-NVR-but-different-build kernel still counts. +kernel_after="$(get_running_kernel_id)" +echo "Current running kernel: $(uname -r) (id: $kernel_after)" +kernel_before="$(load_kernel_version "$KERNEL_FILE")" +echo "Kernel before installation: $kernel_before" +assert_kernel_changed "$kernel_before" "$kernel_after" +save_kernel_version "$kernel_after" "$KERNEL_FILE" + +# Make sure PostgreSQL is stopped even if the benchmark fails. +trap stop_postgresql EXIT + +# Run pgbench for the base kernel and record the benchmark CSV. +RESULTS_DIR="${PWD}/results" +run_pgbench_suite "$RESULTS_DIR" +summarize_pgbench_output \ + "$RESULTS_DIR/pgbench_readonly.txt" \ + "$RESULTS_DIR/pgbench_readwrite.txt" \ + "benchmark-base-$(uname -r).csv" + +# Install the kernel with the higher version as the kernel to be used next. +last_kernel=$(get_last_kernel_rpm_from_dir) +install_specified_kernel_rpm "$last_kernel" + +# Stop here; re-execution happens after reboot and continues in run-03-*.sh diff --git a/vm-tests/pgbench-kernel-regression/run-03-run-second-pgbench.sh b/vm-tests/pgbench-kernel-regression/run-03-run-second-pgbench.sh new file mode 100755 index 0000000..c8a3798 --- /dev/null +++ b/vm-tests/pgbench-kernel-regression/run-03-run-second-pgbench.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Authors: Norbert Manthey +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# +# Third run: run pgbench on the second (tip) kernel. + +set -euxo pipefail + +# Set source directory and source common library for functions and constants +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SOURCE_DIR}/common_lib.sh" + +# Confirm the kernel actually changed after the reboot from run-02. +kernel_after="$(get_running_kernel_id)" +echo "Current running kernel: $(uname -r) (id: $kernel_after)" +kernel_before="$(load_kernel_version "$KERNEL_FILE")" +echo "Kernel before installation: $kernel_before" +assert_kernel_changed "$kernel_before" "$kernel_after" +save_kernel_version "$kernel_after" "$KERNEL_FILE" + +# Make sure PostgreSQL is stopped even if the benchmark fails. +trap stop_postgresql EXIT + +# Run pgbench for the tip kernel and record the benchmark CSV. +RESULTS_DIR="${PWD}/results" +run_pgbench_suite "$RESULTS_DIR" +summarize_pgbench_output \ + "$RESULTS_DIR/pgbench_readonly.txt" \ + "$RESULTS_DIR/pgbench_readwrite.txt" \ + "benchmark-tip-$(uname -r).csv" + +# Stop here; this is the last script, no more execution. diff --git a/vm-tests/simple-source-reboot/common_lib.sh b/vm-tests/simple-source-reboot/common_lib.sh index 843816c..3e4cc59 100644 --- a/vm-tests/simple-source-reboot/common_lib.sh +++ b/vm-tests/simple-source-reboot/common_lib.sh @@ -2,112 +2,21 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -KERNEL_BENCH_DIR="kernel-bench" - -# Get results bucket and test paths from environment -RESULTS_BUCKET="${S3_BUCKET:-}" -ARCH=$(uname -m) -KERNEL_RPM_DIR="/tmp/kernel-rpms" -KERNEL_FILE="${SOURCE_DIR}/kernel_version_before.txt" - -# Validate required environment variables -if [ -z "$RESULTS_BUCKET" ] || [ -z "$RUN_PREFIX" ] || [ -z "$TEST_NAME" ]; then - echo "ERROR: Missing required environment variables (S3_BUCKET, RUN_PREFIX, TEST_NAME)" >&2 - exit 1 -fi - -# Error trap handler to show line where error occurred -error_trap() -{ - local exit_code=$? - local line_number=$1 - echo "$(date): ERROR: Script failed at line $line_number with exit code $exit_code" - echo "$(date): ERROR: Command that failed: $(sed -n "${line_number}p" "$0")" - exit $exit_code -} -trap 'error_trap $LINENO' ERR - -get_running_kernel() -{ - uname -r -} - -save_kernel_version() -{ - local version="$1" - local out_file="$2" - - if [ -z "$version" ] || [ -z "$out_file" ]; then - echo "ERROR: save_kernel_version requires version and file" - return 1 - fi - - echo "$version" >"$out_file" -} - -load_kernel_version() -{ - local in_file="$1" - - if [ ! -f "$in_file" ]; then - echo "ERROR: Kernel version file not found: $in_file" - return 1 - fi - - cat "$in_file" -} +# Common library for the simple source-build kernel reboot test. +# +# Binary-kernel install/reboot logic (environment validation, kernel RPM +# download/selection, install_kernel_rpm, reboot helpers) lives in the shared +# vm-tests/lib/kernel_helpers.sh, included via the kernel_helpers.sh symlink in +# this directory. Only the source-RPM build helpers stay here. SOURCE_DIR is +# set by the run script before this file is sourced. -assert_kernel_changed() -{ - local before="$1" - local after="$2" - - if [ "$before" = "$after" ]; then - echo "✗ FAILED: Kernel version did not change (still $after)" - return 1 - fi - - echo "✓ SUCCESS: Kernel version changed from $before to $after" -} - -# Install a single given package -install_package() -{ - local pkg="$1" - local output - echo "Installing package $pkg ..." - if output=$(sudo yum install -y "$pkg" 2>&1) || output=$(sudo dnf install -y "$pkg" 2>&1); then - return 0 - else - echo "Failed to install package $pkg:" - echo "$output" - return 1 - fi -} - -# Install all dependencies for this test -install_test_dependencies() -{ - local deps_file="${SOURCE_DIR}/dependencies.txt" +KERNEL_BENCH_DIR="kernel-bench" - if [ -f "$deps_file" ]; then - while IFS= read -r pkg || [ -n "$pkg" ]; do - # Skip empty lines and comments - [[ -z "$pkg" || "$pkg" =~ ^[[:space:]]*# ]] && continue +source "${SOURCE_DIR}/kernel_helpers.sh" - # Remove leading/trailing whitespace - pkg=$(echo "$pkg" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') - - # Install package if not empty - if [ -n "$pkg" ]; then - install_package "$pkg" || return 1 - fi - done <"$deps_file" - else - # Fallback to hardcoded dependencies - install_package gcc make tar || return 1 - fi -} +# --------------------------------------------------------------------------- +# Source-RPM build helpers (specific to this test) +# --------------------------------------------------------------------------- # Install kernel source RPM (extracts source code to ~/rpmbuild/) install_source_kernel_rpm() @@ -168,156 +77,6 @@ build_kernel_rpm_src() fi } -# Dump boot configuration for debugging kernel install issues -dump_boot_info() -{ - echo "=== Boot Debug Info ===" - echo "--- OS ---" - head -2 /etc/os-release 2>/dev/null || true - echo "--- Running kernel ---" - uname -r - echo "--- Installed kernel packages ---" - rpm -qa 'kernel*' | sort - echo "--- vmlinuz files in /boot ---" - ls -la /boot/vmlinuz-* 2>/dev/null || echo "(none)" - echo "--- BLS entries ---" - ls -la /boot/loader/entries/ 2>/dev/null || echo "(no BLS directory)" - echo "--- grubby default ---" - sudo grubby --default-kernel 2>/dev/null || echo "(grubby --default-kernel failed)" - echo "--- grubby --info=ALL ---" - sudo grubby --info=ALL 2>/dev/null || echo "(grubby --info=ALL failed)" - echo "=== End Boot Debug Info ===" -} - -# Install binary kernel RPM -install_kernel_rpm() -{ - if [ -z "${1:-}" ]; then - echo "ERROR: install_kernel_rpm requires kernel_rpm parameter" >&2 - return 1 - fi - local kernel_rpm="$1" - - # Check it's a binary RPM (not source) - if [[ "$kernel_rpm" =~ \.src\.rpm$ ]]; then - echo "ERROR: This is a source RPM, not a binary RPM: $kernel_rpm" >&2 - return 1 - fi - - # Check architecture compatibility - local host_arch=$(uname -m) - local rpm_arch=$(rpm -qp --queryformat '%{ARCH}' "$kernel_rpm" 2>/dev/null) - - if [ "$rpm_arch" != "$host_arch" ]; then - echo "ERROR: Architecture mismatch - Host: $host_arch, RPM: $rpm_arch" >&2 - return 1 - fi - - echo "Installing binary kernel from $kernel_rpm (arch: $rpm_arch)" - - if sudo yum localinstall -y "$kernel_rpm" 2>/dev/null || sudo dnf install -y "$kernel_rpm" 2>/dev/null; then - dump_boot_info - - # Set the newly installed kernel as default boot target. - # Without this, GRUB boots the newest kernel which may not be the one we just installed. - local installed_version - installed_version=$(rpm -qp --queryformat '%{VERSION}' "$kernel_rpm" 2>/dev/null) - - # Find the grubby entry matching the installed kernel version. - # Use grep || true to avoid ERR trap when no match is found. - local grub_kernel - grub_kernel=$(sudo grubby --info=ALL 2>/dev/null \ - | grep "^kernel=" \ - | grep "$installed_version" \ - | head -1 \ - | sed 's/^kernel=//' \ - | tr -d '"' \ - || true) - - if [ -z "$grub_kernel" ]; then - # Upstream make binrpm-pkg kernels don't register with grubby. - # Find the vmlinuz file and add a boot entry manually. - local vmlinuz - vmlinuz=$(ls /boot/vmlinuz-*"$installed_version"* 2>/dev/null | head -1) - if [ -n "$vmlinuz" ]; then - echo "Adding grubby entry for $vmlinuz" - local initrd="/boot/initramfs-${installed_version}.img" - if [ ! -f "$initrd" ]; then - echo "Generating initramfs at $initrd" - sudo dracut --force "$initrd" "$installed_version" 2>/dev/null \ - || sudo mkinitrd "$initrd" "$installed_version" 2>/dev/null \ - || true - fi - if [ -f "$initrd" ]; then - sudo grubby --add-kernel="$vmlinuz" \ - --initrd="$initrd" \ - --title="Linux $installed_version" \ - --copy-default \ - --make-default - echo "✓ Added and set default: $vmlinuz" - else - echo "WARNING: No initramfs for $installed_version, trying set-default anyway" - sudo grubby --set-default="$vmlinuz" || true - fi - grub_kernel="$vmlinuz" - else - echo "WARNING: No vmlinuz found for version $installed_version" - fi - else - echo "Setting default boot kernel to $grub_kernel" - sudo grubby --set-default="$grub_kernel" - fi - - if [ -n "$grub_kernel" ]; then - echo "Verifying default kernel:" - sudo grubby --default-kernel - fi - echo "✓ Kernel installed successfully" - return 0 - else - echo "ERROR: Failed to install kernel" >&2 - return 1 - fi -} - -##### GET SRC KERNEL FROM S3 AND DOWNLOAD TO LOCAL MACHINE! -# List available kernels from S3 -list_kernels_from_s3() -{ - S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/src/" - aws s3 ls "${S3_PATH}" | grep "\.rpm$" | awk '{print $4}' -} - -# Download specific kernel RPM from S3 -download_kernel_rpm() -{ - if [ -z "${1:-}" ]; then - echo "ERROR: download_kernel_rpm requires kernel_name parameter" >&2 - return 1 - fi - local kernel_name="$1" - - S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/src/" - - mkdir -p "$KERNEL_RPM_DIR" - local local_path="${KERNEL_RPM_DIR}/${kernel_name}" - - # Download if not already present - if [ -f "$local_path" ]; then - echo "$local_path" - return 0 - fi - - if aws s3 cp "${S3_PATH}${kernel_name}" "$local_path" --no-progress >&2; then - echo "$local_path" - return 0 - else - echo "ERROR: Failed to download kernel" >&2 - return 1 - fi -} - -# Return kernel RPM with lowest version (downloads from S3) get_first_source_kernel_rpm_from_dir() { local kernels=$(list_kernels_from_s3 | sort -V) diff --git a/vm-tests/simple-source-reboot/kernel_helpers.sh b/vm-tests/simple-source-reboot/kernel_helpers.sh new file mode 120000 index 0000000..31ff984 --- /dev/null +++ b/vm-tests/simple-source-reboot/kernel_helpers.sh @@ -0,0 +1 @@ +../lib/kernel_helpers.sh \ No newline at end of file diff --git a/vm-tests/simple-unixbench/common_lib.sh b/vm-tests/simple-unixbench/common_lib.sh index bf437f7..e6afeff 100644 --- a/vm-tests/simple-unixbench/common_lib.sh +++ b/vm-tests/simple-unixbench/common_lib.sh @@ -134,9 +134,9 @@ summarize_unixbench_log() # Parse result lines (first section) - use 6th last as value, 5th last as unit in_results && NF >= 6 { - # Extract metric name (everything except last 5 fields) + # Extract metric name (everything except last 6 fields: value unit (timing info)) metric = "" - for (i = 1; i <= NF-4; i++) { + for (i = 1; i <= NF-6; i++) { if (metric == "") { metric = $i } else { @@ -151,43 +151,14 @@ summarize_unixbench_log() # Clean up metric name gsub(/^\s+|\s+$/, "", metric) - # Determine more_is_better - if (metric ~ /System_Call_Overhead/) { - more_is_better = "false" - } else { - more_is_better = "true" - } - - printf "%s.%s,%s,%s,%s,%s,%s,%s,%s\n", benchmark_version, metric, unit, value, more_is_better, kernel_version, instance_id, instance_type, arch - } - - # Parse index section lines - always use second-to-last column as value - in_index && NF >= 3 && !/BASELINE/ && !/RESULT/ && !/INDEX/ && !/^=/ { - # Extract metric name (everything except last 2 fields) - metric = "" - for (i = 1; i <= NF-3; i++) { - if (metric == "") { - metric = $i - } else { - metric = metric "_" $i - } - } - - # Use second-to-last field as value - value = $(NF-1) - - # Skip lines with "---" values - if (value == "---") { - next - } - - # Clean up metric name - gsub(/^\s+|\s+$/, "", metric) - - unit = "score" + # All UnixBench results in this section are throughput rates + # (lps/lpm/KBps), so higher is better — including "System Call + # Overhead", whose value is syscall round-trips per second (lps). more_is_better = "true" printf "%s.%s,%s,%s,%s,%s,%s,%s,%s\n", benchmark_version, metric, unit, value, more_is_better, kernel_version, instance_id, instance_type, arch } + + # Skip index section entirely - do not parse it ' "$unixbench_log" >>"$output_csv_file" } diff --git a/vm-tests/unixbench-kernel-regression/common_lib.sh b/vm-tests/unixbench-kernel-regression/common_lib.sh index 5e161c8..ef65138 100644 --- a/vm-tests/unixbench-kernel-regression/common_lib.sh +++ b/vm-tests/unixbench-kernel-regression/common_lib.sh @@ -2,152 +2,25 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -# Lib with functions required in multiple test steps +# Common library for the UnixBench kernel A/B regression test. +# +# Kernel-management logic (environment validation, kernel RPM +# download/selection, install_kernel_rpm, reboot helpers) lives in the shared +# vm-tests/lib/kernel_helpers.sh, included via the kernel_helpers.sh symlink in +# this directory. Only the UnixBench-specific pieces stay here. SOURCE_DIR is +# set by the run script before this file is sourced. UNIXBENCH_VERSION=byte-unixbench-6.0.0 UNIXBENCH_TAR_FILE="$UNIXBENCH_VERSION.tar.gz" KERNEL_BENCH_DIR="kernel-bench" -# Get results bucket and test paths from environment -RESULTS_BUCKET="${S3_BUCKET:-}" -ARCH=$(uname -m) -KERNEL_RPM_DIR="/tmp/kernel-rpms" -KERNEL_FILE="${SOURCE_DIR}/kernel_version_before.txt" +source "${SOURCE_DIR}/kernel_helpers.sh" -# Validate required environment variables -if [ -z "$RESULTS_BUCKET" ] || [ -z "$RUN_PREFIX" ] || [ -z "$TEST_NAME" ]; then - echo "ERROR: Missing required environment variables (S3_BUCKET, RUN_PREFIX, TEST_NAME)" >&2 - exit 1 -fi +# --------------------------------------------------------------------------- +# UnixBench-specific helpers +# --------------------------------------------------------------------------- -get_running_kernel() -{ - uname -r -} - -save_kernel_version() -{ - local version="$1" - local out_file="$2" - - if [ -z "$version" ] || [ -z "$out_file" ]; then - echo "ERROR: save_kernel_version requires version and file" - return 1 - fi - - echo "$version" >"$out_file" -} - -load_kernel_version() -{ - local in_file="$1" - - if [ ! -f "$in_file" ]; then - echo "ERROR: Kernel version file not found: $in_file" - return 1 - fi - - cat "$in_file" -} - -assert_kernel_changed() -{ - local before="$1" - local after="$2" - - if [ "$before" = "$after" ]; then - echo "✗ FAILED: Kernel version did not change (still $after)" - return 1 - fi - - echo "✓ SUCCESS: Kernel version changed from $before to $after" -} - -# List available kernels from S3 -list_kernels_from_s3() -{ - S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/binary/${ARCH}/" - aws s3 ls "${S3_PATH}" | grep "\.rpm$" | awk '{print $4}' -} - -# Download specific kernel RPM from S3 -download_kernel_rpm() -{ - if [ -z "${1:-}" ]; then - echo "ERROR: download_kernel_rpm requires kernel_name parameter" >&2 - return 1 - fi - local kernel_name="$1" - - S3_PATH="s3://${RESULTS_BUCKET}/${RUN_PREFIX}/shared/kernel-rpms/binary/${ARCH}/" - - mkdir -p "$KERNEL_RPM_DIR" - local local_path="${KERNEL_RPM_DIR}/${kernel_name}" - - # Download if not already present - if [ -f "$local_path" ]; then - echo "$local_path" - return 0 - fi - - if aws s3 cp "${S3_PATH}${kernel_name}" "$local_path" --no-progress >&2; then - echo "$local_path" - return 0 - else - echo "ERROR: Failed to download kernel" >&2 - return 1 - fi -} - -# Error trap handler to show line where error occurred -error_trap() -{ - local exit_code=$? - local line_number=$1 - echo "$(date): ERROR: Script failed at line $line_number with exit code $exit_code" - echo "$(date): ERROR: Command that failed: $(sed -n "${line_number}p" "$0")" - exit $exit_code -} -trap 'error_trap $LINENO' ERR - -# Install a single given package -install_package() -{ - local pkg="$1" - local output - echo "Installing package $pkg ..." - if output=$(sudo yum install -y "$pkg" 2>&1) || output=$(sudo dnf install -y "$pkg" 2>&1); then - return 0 - else - echo "Failed to install package $pkg:" - echo "$output" - return 1 - fi -} - -# Install all dependencies for this test -install_test_dependencies() -{ - local deps_file="${SOURCE_DIR}/dependencies.txt" - - if [ -f "$deps_file" ]; then - while IFS= read -r pkg || [ -n "$pkg" ]; do - # Skip empty lines and comments - [[ -z "$pkg" || "$pkg" =~ ^[[:space:]]*# ]] && continue - - # Remove leading/trailing whitespace - pkg=$(echo "$pkg" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') - - # Install package if not empty - if [ -n "$pkg" ]; then - install_package "$pkg" || return 1 - fi - done <"$deps_file" - else - # Fallback to hardcoded dependencies - install_package gcc make tar || return 1 - fi -} +# Extract unixbench # Extract unixbench prepare_unixbench() @@ -236,12 +109,10 @@ summarize_unixbench_log() # Clean up metric name gsub(/^\s+|\s+$/, "", metric) - # Determine more_is_better - if (metric ~ /System_Call_Overhead/) { - more_is_better = "false" - } else { - more_is_better = "true" - } + # All first-section UnixBench results are throughput rates (lps/lpm/KBps), + # so higher is better — including "System Call Overhead", whose value is + # syscall round-trips per second (lps), not a time. Do NOT invert it. + more_is_better = "true" printf "%s.%s,%s,%s,%s,%s,%s,%s,%s\n", benchmark_version, metric, unit, value, more_is_better, kernel_version, instance_id, instance_type, arch, arch } @@ -249,156 +120,3 @@ summarize_unixbench_log() # Skip index section entirely - do not parse it ' "$unixbench_log" >>"$output_csv_file" } - -# Dump boot configuration for debugging kernel install issues -dump_boot_info() -{ - echo "=== Boot Debug Info ===" - echo "--- OS ---" - head -2 /etc/os-release 2>/dev/null || true - echo "--- Running kernel ---" - uname -r - echo "--- Installed kernel packages ---" - rpm -qa 'kernel*' | sort - echo "--- vmlinuz files in /boot ---" - ls -la /boot/vmlinuz-* 2>/dev/null || echo "(none)" - echo "--- BLS entries ---" - ls -la /boot/loader/entries/ 2>/dev/null || echo "(no BLS directory)" - echo "--- grubby default ---" - sudo grubby --default-kernel 2>/dev/null || echo "(grubby --default-kernel failed)" - echo "--- grubby --info=ALL ---" - sudo grubby --info=ALL 2>/dev/null || echo "(grubby --info=ALL failed)" - echo "=== End Boot Debug Info ===" -} - -# Install current kernel RPM, make sure it's used as boot target -install_kernel_rpm() -{ - if [ -z "${1:-}" ]; then - echo "ERROR: install_kernel_rpm requires kernel_rpm parameter" >&2 - return 1 - fi - local kernel_rpm="$1" - - # Check architecture compatibility - local host_arch=$(uname -m) - local rpm_arch=$(rpm -qp --queryformat '%{ARCH}' "$kernel_rpm" 2>/dev/null) - - if [ "$rpm_arch" != "$host_arch" ]; then - echo "ERROR: Architecture mismatch - Host: $host_arch, RPM: $rpm_arch" >&2 - return 1 - fi - - echo "kernel before installation: $(uname -r)" - echo "Installing kernel from $kernel_rpm (arch: $rpm_arch)" - - if sudo yum localinstall -y "$kernel_rpm" 2>/dev/null || sudo dnf install -y "$kernel_rpm" 2>/dev/null; then - dump_boot_info - - # Set the newly installed kernel as default boot target. - # Without this, GRUB boots the newest kernel which may not be the one we just installed. - local installed_version - installed_version=$(rpm -qp --queryformat '%{VERSION}' "$kernel_rpm" 2>/dev/null) - - # Find the grubby entry matching the installed kernel version. - # Use grep || true to avoid ERR trap when no match is found. - local grub_kernel - grub_kernel=$(sudo grubby --info=ALL 2>/dev/null \ - | grep "^kernel=" \ - | grep "$installed_version" \ - | head -1 \ - | sed 's/^kernel=//' \ - | tr -d '"' \ - || true) - - if [ -z "$grub_kernel" ]; then - # Upstream make binrpm-pkg kernels don't register with grubby. - # Find the vmlinuz file and add a boot entry manually. - local vmlinuz - vmlinuz=$(ls /boot/vmlinuz-*"$installed_version"* 2>/dev/null | head -1) - if [ -n "$vmlinuz" ]; then - echo "Adding grubby entry for $vmlinuz" - # Copy initrd and args from the current default entry - local default_kernel - default_kernel=$(sudo grubby --default-kernel) - local default_initrd - default_initrd=$(sudo grubby --info="$default_kernel" 2>/dev/null \ - | grep "^initrd=" | sed 's/^initrd=//' | tr -d '"' || true) - local initrd="/boot/initramfs-${installed_version}.img" - # Generate initramfs if it doesn't exist - if [ ! -f "$initrd" ]; then - echo "Generating initramfs at $initrd" - sudo dracut --force "$initrd" "$installed_version" 2>/dev/null \ - || sudo mkinitrd "$initrd" "$installed_version" 2>/dev/null \ - || true - fi - if [ -f "$initrd" ]; then - sudo grubby --add-kernel="$vmlinuz" \ - --initrd="$initrd" \ - --title="Linux $installed_version" \ - --copy-default \ - --make-default - echo "✓ Added and set default: $vmlinuz" - else - echo "WARNING: No initramfs for $installed_version, trying set-default anyway" - sudo grubby --set-default="$vmlinuz" || true - fi - grub_kernel="$vmlinuz" - else - echo "WARNING: No vmlinuz found for version $installed_version" - fi - else - echo "Setting default boot kernel to $grub_kernel" - sudo grubby --set-default="$grub_kernel" - fi - - if [ -n "$grub_kernel" ]; then - echo "Verifying default kernel:" - sudo grubby --default-kernel - fi - return 0 - else - echo "ERROR: Failed to install new kernel" >&2 - return 1 - fi -} - -# Return kernel RPM with lowest version (downloads from S3) -get_first_kernel_rpm_from_dir() -{ - local kernels=$(list_kernels_from_s3 | sort -V) - local first_kernel=$(echo "$kernels" | head -n 1) - - if [ -z "$first_kernel" ]; then - return 1 - fi - - download_kernel_rpm "$first_kernel" -} - -# Return kernel RPM with highest version (downloads from S3) -get_last_kernel_rpm_from_dir() -{ - local kernels=$(list_kernels_from_s3 | sort -V) - local last_kernel=$(echo "$kernels" | tail -n 1) - - if [ -z "$last_kernel" ]; then - return 1 - fi - - download_kernel_rpm "$last_kernel" -} - -# Install a given kernel RPM (passed as argument) -install_specified_kernel_rpm() -{ - local kernel_rpm="$1" - - if [ -z "$kernel_rpm" ]; then - echo "ERROR: install_specified_kernel_rpm requires a kernel RPM path" - return 1 - fi - - echo "Installing kernel RPM: $(basename "$kernel_rpm")" - install_kernel_rpm "$kernel_rpm" -} diff --git a/vm-tests/unixbench-kernel-regression/kernel_helpers.sh b/vm-tests/unixbench-kernel-regression/kernel_helpers.sh new file mode 120000 index 0000000..31ff984 --- /dev/null +++ b/vm-tests/unixbench-kernel-regression/kernel_helpers.sh @@ -0,0 +1 @@ +../lib/kernel_helpers.sh \ No newline at end of file diff --git a/vm-tests/unixbench-kernel-regression/run-01-setup-kernel-A.sh b/vm-tests/unixbench-kernel-regression/run-01-setup-kernel-A.sh index 45b3bfd..6c51974 100755 --- a/vm-tests/unixbench-kernel-regression/run-01-setup-kernel-A.sh +++ b/vm-tests/unixbench-kernel-regression/run-01-setup-kernel-A.sh @@ -18,7 +18,7 @@ install_test_dependencies prepare_unixbench # Save kernel version before -kernel_before="$(get_running_kernel)" +kernel_before="$(get_running_kernel_id)" echo "Kernel before installation: $kernel_before" save_kernel_version "$kernel_before" "$KERNEL_FILE" diff --git a/vm-tests/unixbench-kernel-regression/run-02-run-unixbench-setup-kernel-B.sh b/vm-tests/unixbench-kernel-regression/run-02-run-unixbench-setup-kernel-B.sh index e9d413b..81bc170 100755 --- a/vm-tests/unixbench-kernel-regression/run-02-run-unixbench-setup-kernel-B.sh +++ b/vm-tests/unixbench-kernel-regression/run-02-run-unixbench-setup-kernel-B.sh @@ -14,7 +14,7 @@ SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${SOURCE_DIR}/common_lib.sh" #Assert if kernel version has changed -kernel_after="$(get_running_kernel)" +kernel_after="$(get_running_kernel_id)" echo "Current running kernel: $kernel_after" kernel_before="$(load_kernel_version "$KERNEL_FILE")" @@ -27,7 +27,7 @@ save_kernel_version "$kernel_after" "$KERNEL_FILE" RESULTS_DIR="${PWD}/${KERNEL_BENCH_DIR}/first_kernel" mkdir -p "$RESULTS_DIR" run_unixbench "$RESULTS_DIR" -summarize_unixbench_log "$RESULTS_DIR"/unixbench.log "benchmark-base-$(basename $kernel_after).csv" +summarize_unixbench_log "$RESULTS_DIR"/unixbench.log "benchmark-base-$(uname -r).csv" # Install kernel with higher version as kernel to be used next last_kernel=$(get_last_kernel_rpm_from_dir "$KERNEL_RPM_DIR") diff --git a/vm-tests/unixbench-kernel-regression/run-03-run-second-unixbench.sh b/vm-tests/unixbench-kernel-regression/run-03-run-second-unixbench.sh index 242f976..e5ebe41 100755 --- a/vm-tests/unixbench-kernel-regression/run-03-run-second-unixbench.sh +++ b/vm-tests/unixbench-kernel-regression/run-03-run-second-unixbench.sh @@ -14,7 +14,7 @@ SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${SOURCE_DIR}/common_lib.sh" #Assert if kernel version has changed -kernel_after="$(get_running_kernel)" +kernel_after="$(get_running_kernel_id)" echo "Current running kernel: $kernel_after" kernel_before="$(load_kernel_version "$KERNEL_FILE")" @@ -27,6 +27,6 @@ save_kernel_version "$kernel_after" "$KERNEL_FILE" RESULTS_DIR="${PWD}/${KERNEL_BENCH_DIR}/last_kernel" mkdir -p "$RESULTS_DIR" run_unixbench "$RESULTS_DIR" -summarize_unixbench_log "$RESULTS_DIR"/unixbench.log "benchmark-tip-$(basename $kernel_after).csv" +summarize_unixbench_log "$RESULTS_DIR"/unixbench.log "benchmark-tip-$(uname -r).csv" # Stop here, this is the last script, no more execution