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 <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-28 09:25:46 +03:00
1 parent 9987b3de64
commit 5de37ccbc3
2 files changed
+43

No files matched your search

+20
View File
@@ -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'
---
+23
View File
@@ -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