@@ -1248,6 +1248,37 @@ jobs:
12481248 echo "Download dependencies"
12491249 go mod download
12501250
1251+ - name : Detect Kubernetes version for E2E
1252+ id : detect-k8s-version
1253+ run : |
1254+ set -euo pipefail
1255+
1256+ VERSION_JSON=$(kubectl version -o json)
1257+ SERVER_VERSION=$(echo "$VERSION_JSON" | jq -r '.serverVersion.gitVersion')
1258+ SERVER_MAJOR=$(echo "$VERSION_JSON" | jq -r '.serverVersion.major' | tr -cd '0-9')
1259+ SERVER_MINOR=$(echo "$VERSION_JSON" | jq -r '.serverVersion.minor' | tr -cd '0-9')
1260+
1261+ if [[ -z "$SERVER_MAJOR" || -z "$SERVER_MINOR" ]]; then
1262+ echo "[ERROR] Failed to parse Kubernetes server version: $SERVER_VERSION"
1263+ exit 1
1264+ fi
1265+
1266+ LABEL_FILTER=""
1267+ USB_SUPPORTED=false
1268+
1269+ if (( SERVER_MAJOR > 1 || (SERVER_MAJOR == 1 && SERVER_MINOR >= 34) )); then
1270+ USB_SUPPORTED=true
1271+ echo "[INFO] Kubernetes server version $SERVER_VERSION supports USB E2E tests"
1272+ else
1273+ LABEL_FILTER="!usb-precheck"
1274+ echo "[INFO] Kubernetes server version $SERVER_VERSION does not support USB E2E tests"
1275+ echo "[INFO] USB-labeled specs will be excluded with label filter: $LABEL_FILTER"
1276+ fi
1277+
1278+ echo "server-version=$SERVER_VERSION" >> "$GITHUB_OUTPUT"
1279+ echo "usb-supported=$USB_SUPPORTED" >> "$GITHUB_OUTPUT"
1280+ echo "label-filter=$LABEL_FILTER" >> "$GITHUB_OUTPUT"
1281+
12511282 - name : Create vmclass for e2e tests
12521283 run : |
12531284 if ! (kubectl get vmclass generic-for-e2e 2>/dev/null); then
@@ -1270,6 +1301,9 @@ jobs:
12701301 TIMEOUT : ${{ inputs.e2e_timeout }}
12711302 CSI : ${{ inputs.storage_type }}
12721303 STORAGE_CLASS_NAME : ${{ inputs.nested_storageclass_name }}
1304+ LABELS : ${{ steps.detect-k8s-version.outputs.label-filter }}
1305+ SERVER_K8S_VERSION : ${{ steps.detect-k8s-version.outputs.server-version }}
1306+ USB_SUPPORTED : ${{ steps.detect-k8s-version.outputs.usb-supported }}
12731307 working-directory : ./test/e2e/
12741308 run : |
12751309 GINKGO_RESULT=$(mktemp -p $RUNNER_TEMP)
@@ -1278,25 +1312,36 @@ jobs:
12781312 summary_file_name_junit="e2e_summary_${CSI}_${DATE}.xml"
12791313 ginkgo_json_report="ginkgo_report_${CSI}_${DATE}.json"
12801314 summary_file_name_json="e2e_summary_${CSI}_${DATE}.json"
1315+ FOCUS="${{ inputs.e2e_focus_tests }}"
12811316
12821317 cp -a legacy/testdata /tmp/testdata
12831318
1319+ echo "[INFO] Kubernetes server version: ${SERVER_K8S_VERSION}"
1320+ echo "[INFO] USB E2E supported: ${USB_SUPPORTED}"
1321+ if [ -n "${LABELS:-}" ]; then
1322+ echo "[INFO] Applying Ginkgo label filter: ${LABELS}"
1323+ fi
1324+
12841325 ./scripts/precheck-prepare_ci.sh
12851326
12861327 set +e
1287- FOCUS="${{ inputs.e2e_focus_tests }}"
1328+ GINKGO_ARGS=(
1329+ -v
1330+ --race
1331+ --timeout="$TIMEOUT"
1332+ --json-report="$ginkgo_json_report"
1333+ --junit-report="$summary_file_name_junit"
1334+ )
1335+
1336+ if [ -n "${LABELS:-}" ]; then
1337+ GINKGO_ARGS+=(--label-filter="$LABELS")
1338+ fi
1339+
12881340 if [ -n "$FOCUS" ]; then
1289- go tool ginkgo \
1290- --focus="$FOCUS" \
1291- -v --race --timeout=$TIMEOUT \
1292- --json-report=$ginkgo_json_report \
1293- --junit-report=$summary_file_name_junit | tee $GINKGO_RESULT
1294- else
1295- go tool ginkgo \
1296- -v --race --timeout=$TIMEOUT \
1297- --json-report=$ginkgo_json_report \
1298- --junit-report=$summary_file_name_junit | tee $GINKGO_RESULT
1341+ GINKGO_ARGS+=(--focus="$FOCUS")
12991342 fi
1343+
1344+ go tool ginkgo "${GINKGO_ARGS[@]}" | tee $GINKGO_RESULT
13001345 GINKGO_EXIT_CODE=$?
13011346 set -e
13021347
0 commit comments