Skip to content

Commit d5a4ac9

Browse files
committed
e2e-tests.md: update description of labels
This explains how to use --filter-label (possible since Kubernetes 1.29) and clarifies the usage of feature gate labels.
1 parent cf0b315 commit d5a4ac9

File tree

1 file changed

+94
-17
lines changed

1 file changed

+94
-17
lines changed

contributors/devel/sig-testing/e2e-tests.md

Lines changed: 94 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@ kubetest --up
9292
# Run all tests
9393
kubetest --test
9494

95-
# Run tests matching the regex "\[Feature:Performance\]" against a local cluster
95+
# Run tests which have been labeled with "Feature:Performance" against a local cluster
9696
# Specify "--provider=local" flag when running the tests locally
97-
kubetest --test --test_args="--ginkgo.focus=\[Feature:Performance\]" --provider=local
97+
kubetest --test --test_args='--ginkgo.label-filter=Feature:Performance' --provider=local
9898

9999
# Conversely, exclude tests that match the regex "Pods.*env"
100-
kubetest --test --test_args="--ginkgo.skip=Pods.*env"
100+
kubetest --test --test_args='--ginkgo.skip=Pods.*env'
101101

102-
# Exclude tests tha require a certain minimum version of the kubelet
103-
kubetest --test --test_args="--ginkgo.skip=\[MinimumKubeletVersion:1.20\]"
102+
# Exclude tests that require a certain minimum version of the kubelet
103+
kubetest --test --test_args='--ginkgo.label-filter=!MinimumKubeletVersion:1.20'
104104

105105
# Run tests in parallel, skip any that must be run serially
106-
GINKGO_PARALLEL=y kubetest --test --test_args="--ginkgo.skip=\[Serial\]"
106+
GINKGO_PARALLEL=y kubetest --test --test_args='--ginkgo.label-filter=!Serial'
107107

108108
# Run tests in parallel, skip any that must be run serially and keep the test namespace if test failed
109-
GINKGO_PARALLEL=y kubetest --test --test_args="--ginkgo.skip=\[Serial\] --delete-namespace-on-failure=false"
109+
GINKGO_PARALLEL=y kubetest --test --test_args='--ginkgo.label-filter=!Serial --delete-namespace-on-failure=false'
110110

111111
# Flags can be combined, and their actions will take place in this order:
112112
# --build, --up, --test, --down
@@ -187,11 +187,15 @@ if any specs are pending.
187187
--ginkgo.focus="": If set, ginkgo will only run specs that match this regular
188188
expression.
189189
190-
--ginkgo.noColor="n": If set to "y", ginkgo will not use color in the output
191-
192190
--ginkgo.skip="": If set, ginkgo will only run specs that do not match this
193191
regular expression.
194192
193+
--ginkgo.label-filter="": If set, select tests based on their labels as described under
194+
"Spec Labels" in https://onsi.github.io/ginkgo/#filtering-specs. This can focus
195+
on tests and exclude others in a single parameter without using regular expressions.
196+
197+
--ginkgo.noColor="n": If set to "y", ginkgo will not use color in the output
198+
195199
--ginkgo.trace=false: If set, default reporter prints out the full stack trace
196200
when a failure occurs
197201
@@ -281,7 +285,7 @@ First, compile the E2E test suite with additional compiler flags
281285
make WHAT=test/e2e/e2e.test GOGCFLAGS="all=-N -l" GOLDFLAGS=""
282286
```
283287

284-
Then set the env var `E2E_TEST_DEBUG_TOOL=delve` and then run the test with `./hack/gingko.sh` instead of `kubetest`, you should see the delve command line prompt
288+
Then set the env var `E2E_TEST_DEBUG_TOOL=delve` and then run the test with `./hack/ginkgo.sh` instead of `kubetest`, you should see the delve command line prompt
285289

286290
```sh
287291
E2E_TEST_DEBUG_TOOL=delve ./hack/ginkgo-e2e.sh --ginkgo.focus="sig-storage.*csi-hostpath.*Dynamic.PV.*default.fs.*provisioning.should.provision.storage.with.snapshot.data.source" --allowed-not-ready-nodes=10
@@ -460,7 +464,7 @@ kubetest --up
460464
#
461465
# You can target Feature:MasterUpgrade or Feature:ClusterUpgrade
462466
cd ../kubernetes
463-
kubetest --provider=gke --test --check-version-skew=false --test_args="--ginkgo.focus=\[Feature:MasterUpgrade\]"
467+
kubetest --provider=gke --test --check-version-skew=false --test_args="--ginkgo.label-filter=Feature:MasterUpgrade"
464468

465469
# Run old tests with new kubectl
466470
cd ../kubernetes_old
@@ -521,8 +525,10 @@ where `->` means upgrading; container_vm (cvm) and gci are image names.
521525
522526
## Kinds of tests
523527
524-
Tests can be labeled with any of the following labels, in order of increasing
525-
precedence (that is, each label listed below supersedes the previous ones):
528+
Tests can be labeled. Labels appear with square brackets inside the test names
529+
(the traditional approach) *and* are Ginkgo v2 labels (since Kubernetes v1.29).
530+
Available labels in order of increasing precedence (that is, each label listed
531+
below supersedes the previous ones):
526532
527533
- If a test has no labels, it is expected to run fast (under five minutes), be
528534
able to be run in parallel, and be consistent.
@@ -553,8 +559,12 @@ monitored closely in CI. `[Flaky]` tests are by default not run, unless a
553559
554560
- `[Feature:.+]`: If a test has non-default requirements to run or targets
555561
some non-core functionality, and thus should not be run as part of the standard
556-
suite, it receives a `[Feature:.+]` label, e.g. `[Feature:Performance]` or
557-
`[Feature:Ingress]`. `[Feature:.+]` tests are not run in our core suites,
562+
suite, it receives a `[Feature:.+]` label. This non-default requirement could
563+
be some special cluster setup (e.g. `Feature:IPv6DualStack` indicates that the
564+
cluster must support dual-stack pod and service networks) or that the test has
565+
special behavior that makes it unsuitable for a normal test run (e.g.
566+
`Feature:PerformanceDNS` marks a test that stresses cluster DNS performance
567+
with many services). `[Feature:.+]` tests are not run in our core suites,
558568
instead running in custom suites. If a feature is experimental or alpha and is
559569
not enabled by default due to being incomplete or potentially subject to
560570
breaking changes, it does *not* block PR merges, and thus should run in
@@ -575,21 +585,80 @@ to be eligible for this tag. This tag does not supersed any other labels.
575585
- `[LinuxOnly]`: If a test is known to be using Linux-specific features
576586
(e.g.: seLinuxOptions) or is unable to run on Windows nodes, it is labeled
577587
`[LinuxOnly]`. When using Windows nodes, this tag should be added to the
578-
`skip` argument.
588+
`skip` argument. This is not using `[Feature:LinuxOnly]` because that
589+
would have implied changing all CI jobs which skip tests with unknown
590+
requirements.
579591
580592
- The following tags are not considered to be exhaustively applied, but are
581593
intended to further categorize existing `[Conformance]` tests, or tests that are
582594
being considered as candidate for promotion to `[Conformance]` as we work to
583595
refine requirements:
584596
- `[Privileged]`: This is a test that requires privileged access
585-
- `[Internet]`: This is a test that assumes access to the public internet
586597
- `[Deprecated]`: This is a test that exercises a deprecated feature
598+
599+
- For tests that depend on feature gates, the following are set automatically:
587600
- `[Alpha]`: This is a test that exercises an alpha feature
588601
- `[Beta]`: This is a test that exercises a beta feature
589602
603+
Conceptually, these are non-default requirements as defined above under
604+
`[Feature:.+]`, but for historic reasons and the sake of brevity they don't
605+
have that prefix when embedded in test names. They *do* have that prefix in the
606+
Ginkgo v2 label, so use e.g. `--filter-label=Feature: containsAny Alpha`.
607+
590608
Every test should be owned by a [SIG](/sig-list.md),
591609
and have a corresponding `[sig-<name>]` label.
592610
611+
## Selecting tests to run
612+
613+
See https://onsi.github.io/ginkgo/#filtering-specs for a general introduction.
614+
615+
Focusing on a specific test by its name is useful when interactively running
616+
just one or a few related tests. The test name is a concatenation of multiple
617+
strings. To get a list of all full test names, run:
618+
619+
```console
620+
$ e2e.test -list-tests
621+
The following spec names can be used with 'ginkgo run --focus/skip':
622+
test/e2e/apimachinery/watchlist.go:41: [sig-api-machinery] API Streaming (aka. WatchList) [Serial] [Feature:WatchList] should be requested when ENABLE_CLIENT_GO_WATCH_LIST_ALPHA is set
623+
test/e2e/apimachinery/flowcontrol.go:65: [sig-api-machinery] API priority and fairness should ensure that requests can be classified by adding FlowSchema and PriorityLevelConfiguration
624+
test/e2e/apimachinery/flowcontrol.go:190: [sig-api-machinery] API priority and fairness should ensure that requests can't be drowned out (fairness)
625+
...
626+
```
627+
628+
Or within the Kubernetes repo:
629+
630+
```console
631+
$ go test -v ./test/e2e -args -list-tests
632+
The following spec names can be used with 'ginkgo run --focus/skip':
633+
test/e2e/apimachinery/watchlist.go:41: [sig-api-machinery] API Streaming (aka. WatchList) [Serial] [Feature:WatchList] should be requested when ENABLE_CLIENT_GO_WATCH_LIST_ALPHA is set
634+
...
635+
```
636+
637+
The same works for other Kubernetes E2E suites, like `e2e_node`.
638+
639+
In Prow jobs, selection by labels is often simpler. See
640+
[below]((#kinds-of-tests) for documentation of the different labels that are in
641+
use. A full list of labels used by a specific E2E suite can be obtained with
642+
`--list-labels`.
643+
644+
A common pattern is to run only tests which have no special cluster setup
645+
requirements and are not flaky:
646+
647+
--filter-label='Feature: isEmpty && !Flaky'
648+
649+
Feature owners have to ensure that tests excluded that way from shared CI
650+
jobs are executed in dedicated jobs (more on CI below):
651+
652+
--filter-label='Feature: containsAny MyAwesomeFeature'
653+
654+
In jobs that support certain well-known features it is possible to run tests
655+
which have no special requirements or at least only depend on the supported
656+
features:
657+
658+
# Alpha APIs and features enabled, allow tests depending on that as
659+
# long as they have no other special requirements.
660+
--filter-label='Feature: isSubsetOf Alpha'
661+
593662
### Viper configuration and hierarchichal test parameters.
594663
595664
The future of e2e test configuration idioms will be increasingly defined using viper, and decreasingly via flags.
@@ -663,6 +732,14 @@ non-`[Disruptive]`, non-`[Flaky]`, non-`[Feature:.+]` tests in parallel.
663732
- `kubernetes-e2e-<provider>-serial` runs all `[Serial]` and `[Disruptive]`,
664733
non-`[Flaky]`, non-`[Feature:.+]` tests in serial.
665734
735+
- `ci-kubernetes-e2e-kind-alpha-features` runs all tests without any special
736+
requirements and tests that only have alpha feature gates and API groups
737+
as requirement.
738+
739+
- `ci-kubernetes-e2e-kind-beta-features` runs all tests without any special
740+
requirements and tests that only have beta feature gates and API groups
741+
as requirement.
742+
666743
We also run non-default tests if the tests exercise general-availability ("GA")
667744
features that require a special environment to run in, e.g.
668745
`kubernetes-e2e-gce-scalability` and `kubernetes-kubemark-gce`, which test for

0 commit comments

Comments
 (0)