From 9b29321a53de6a43adf04371e21d8a3684703405 Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Thu, 12 Feb 2026 14:56:31 +0100 Subject: [PATCH] Enhance version testing in smoke tests to extract and validate output version Signed-off-by: Matthias Bertschy --- build/goreleaser-post-e2e.sh | 2 +- smoke_testing/test_version.py | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/build/goreleaser-post-e2e.sh b/build/goreleaser-post-e2e.sh index 18881977..a71edaf8 100644 --- a/build/goreleaser-post-e2e.sh +++ b/build/goreleaser-post-e2e.sh @@ -128,7 +128,7 @@ gha_group_start "Smoke tests" log "Running smoke tests with $PYTHON $SMOKE_RUNNER \"$ART_PATH\"" # Run the test runner, propagate exit code set +e -"$PYTHON" "$SMOKE_RUNNER" "$ART_PATH" +RELEASE="${RELEASE:-}" "$PYTHON" "$SMOKE_RUNNER" "$ART_PATH" rc=$? set -e diff --git a/smoke_testing/test_version.py b/smoke_testing/test_version.py index 22600aa7..faf122af 100644 --- a/smoke_testing/test_version.py +++ b/smoke_testing/test_version.py @@ -1,7 +1,9 @@ import os -import smoke_utils +import re import sys +import smoke_utils + def run(kubescape_exec: str): print("Testing version") @@ -10,7 +12,22 @@ def run(kubescape_exec: str): msg = smoke_utils.run_command(command=[kubescape_exec, "version"]) if isinstance(msg, bytes): msg = msg.decode('utf-8') - assert (ver and ver in msg) or (ver and ver.lstrip('v') in msg), f"expected version: {ver}, found: {msg}" + + # Extract version from output + version_match = re.search(r'Your current version is: ([^\s\n]+)', msg) + if version_match: + output_version = version_match.group(1) + print(f"Found version in output: {output_version}") + + # If RELEASE is set, verify it matches the output + if ver: + # Check if RELEASE (with or without 'v' prefix) is in the output + assert (ver in msg) or (ver.lstrip('v') in msg), f"expected version: {ver}, found: {output_version}" + else: + # If RELEASE is not set, just verify that a version was found + assert output_version, f"no version found in output: {msg}" + else: + raise AssertionError(f"no version found in output: {msg}") print("Done testing version")