From 5de37ccbc30892eabf927f8143f71b146ed631da Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Tue, 3 Nov 2026 15:23:51 +0300 Subject: [PATCH] test(e2e): enable gpu-operator in the e2e platform install GPU class admission needs the GPU-for-VMs variant and a permitted resource name. Enable the optional operator when the install selection keeps it and permit a fake external resource for GPU-free CI. Validated with 13 platform-manifest Bats tests, including an install selection that drops the operator. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- hack/e2e-platform-packages.sh | 20 ++++++++++++++++++++ hack/platform-packages_test.bats | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/hack/e2e-platform-packages.sh b/hack/e2e-platform-packages.sh index 5fe18739d..465219c46 100755 --- a/hack/e2e-platform-packages.sh +++ b/hack/e2e-platform-packages.sh @@ -80,6 +80,15 @@ spec: - cozystack.metallb-iad EOF +# Optional packages need explicit enabling even when the install closure keeps them. +gpu_operator=true +case " $disabled " in + *" cozystack.gpu-operator "*) gpu_operator=false ;; +esac +if [ "$gpu_operator" = true ]; then + echo " - cozystack.gpu-operator" +fi + if [ -n "$disabled" ]; then echo " disabledPackages:" for pkg in $disabled; do @@ -87,6 +96,17 @@ if [ -n "$disabled" ]; then done fi +if [ "$gpu_operator" = true ]; then + cat <<'EOF' + gpu: + permittedHostDevices: + pciHostDevices: + - pciVendorSelector: "10DE:FFFF" + resourceName: nvidia.com/E2E_FAKE_GPU + externalResourceProvider: true +EOF +fi + if [ "$linstor_drbd_enabled" = false ]; then cat <<'EOF' --- diff --git a/hack/platform-packages_test.bats b/hack/platform-packages_test.bats index 693f4d056..0902f9be5 100644 --- a/hack/platform-packages_test.bats +++ b/hack/platform-packages_test.bats @@ -166,6 +166,29 @@ load test_helper done } +@test "gpu-operator serves VMs and permits the fake GPU unless the selection drops it" { + manifest=$(hack/e2e-platform-packages.sh) + enabled=$(printf '%s\n' "$manifest" | yq '.spec.components.platform.values.bundles.enabledPackages | join(",")') + fake=$(printf '%s\n' "$manifest" | yq '.spec.components.platform.values.gpu.permittedHostDevices.pciHostDevices[] | select(.resourceName == "nvidia.com/E2E_FAKE_GPU") | .externalResourceProvider') + + if ! printf '%s\n' "$enabled" | tr ',' '\n' | grep -qx 'cozystack.gpu-operator'; then + echo "an unscoped install does not enable gpu-operator: $enabled" >&2 + return 1 + fi + if [ "$fake" != "true" ]; then + echo "the fake GPU resource name is not permitted as an external provider: '$fake'" >&2 + return 1 + fi + + manifest=$(COZY_DISABLED_PACKAGES="cozystack.gpu-operator" hack/e2e-platform-packages.sh) + enabled=$(printf '%s\n' "$manifest" | yq '.spec.components.platform.values.bundles.enabledPackages | join(",")') + gpu=$(printf '%s\n' "$manifest" | yq '.spec.components.platform.values | has("gpu")') + if printf '%s\n' "$enabled" | tr ',' '\n' | grep -qx 'cozystack.gpu-operator' || [ "$gpu" != "false" ]; then + echo "a selection without gpu-operator still enables it: enabled=$enabled gpu=$gpu" >&2 + return 1 + fi +} + @test "a malformed package name fails before emitting YAML" { for bad in "goldpinger" "cozystack." "cozystack.Gold" "cozystack.a;b"; do if manifest=$(COZY_DISABLED_PACKAGES="cozystack.keda $bad" hack/e2e-platform-packages.sh 2>/dev/null); then