From 165e08b4bb611c68fa76a8b52447594fb56ad0cf Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 16 Apr 2024 17:05:19 +0200 Subject: [PATCH] e2e-k8s.sh: support --ginkgo.label-filter The label filter query is more expressive (logical operations) and readable (no regexp unless absolutely required). Such a query can be combined with focus + skip, but in practice a single label filter can replace both of those and is easier to understand. Kubernetes has supported ginkgo v2 and thus --label-filter since v1.25.0. This makes it safe to pass that command line flag unconditionally when invoking the E2E suite. --- hack/ci/e2e-k8s.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hack/ci/e2e-k8s.sh b/hack/ci/e2e-k8s.sh index a51b671d2a..f440d64d52 100755 --- a/hack/ci/e2e-k8s.sh +++ b/hack/ci/e2e-k8s.sh @@ -22,6 +22,12 @@ set -o errexit -o nounset -o xtrace # Settings: # SKIP: ginkgo skip regex # FOCUS: ginkgo focus regex +# LABEL_FILTER: ginkgo label query for selecting tests (see "Spec Labels" in https://onsi.github.io/ginkgo/#filtering-specs) +# +# The default is to focus on conformance tests. Serial tests get skipped when +# parallel testing is enabled. Using LABEL_FILTER instead of combining SKIP and +# FOCUS is recommended (more expressive, easier to read than regexp). +# # GA_ONLY: true - limit to GA APIs/features as much as possible # false - (default) APIs and features left at defaults # FEATURE_GATES: @@ -237,9 +243,13 @@ run_tests() { printf '%s' "${fixed_coredns}" | kubectl apply -f - fi - # ginkgo regexes + # ginkgo regexes and label filter SKIP="${SKIP:-}" - FOCUS="${FOCUS:-"\\[Conformance\\]"}" + FOCUS="${FOCUS:-}" + LABEL_FILTER="${LABEL_FILTER:-}" + if [ -z "${FOCUS}" ] && [ -z "${LABEL_FILTER}" ]; then + FOCUS="\\[Conformance\\]" + fi # if we set PARALLEL=true, skip serial tests set --ginkgo-parallel if [ "${PARALLEL:-false}" = "true" ]; then export GINKGO_PARALLEL=y @@ -262,7 +272,7 @@ run_tests() { # interrupt ./hack/ginkgo-e2e.sh \ '--provider=skeleton' "--num-nodes=${NUM_NODES}" \ - "--ginkgo.focus=${FOCUS}" "--ginkgo.skip=${SKIP}" \ + "--ginkgo.focus=${FOCUS}" "--ginkgo.skip=${SKIP}" "--ginkgo.label-filter=${LABEL_FILTER}" \ "--report-dir=${ARTIFACTS}" '--disable-log-dump=true' & GINKGO_PID=$! wait "$GINKGO_PID"