Enhance version testing in smoke tests to extract and validate output version

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
This commit is contained in:
Matthias Bertschy
2026-02-12 14:56:31 +01:00
parent 466a11fa1c
commit 9b29321a53
2 changed files with 20 additions and 3 deletions

View File

@@ -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

View File

@@ -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")