Skip to content

Commit 4a6113a

Browse files
authored
Merge pull request #7824 from pohly/e2e-tests-labels
e2e-tests.md: update description of labels
2 parents 38bfa85 + b4797e0 commit 4a6113a

File tree

1 file changed

+100
-17
lines changed

1 file changed

+100
-17
lines changed

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

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

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

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

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

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

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

113113
# Flags can be combined, and their actions will take place in this order:
114114
# --build, --up, --test, --down
@@ -189,11 +189,15 @@ if any specs are pending.
189189
--ginkgo.focus="": If set, ginkgo will only run specs that match this regular
190190
expression.
191191
192-
--ginkgo.noColor="n": If set to "y", ginkgo will not use color in the output
193-
194192
--ginkgo.skip="": If set, ginkgo will only run specs that do not match this
195193
regular expression.
196194
195+
--ginkgo.label-filter="": If set, select tests based on their labels as described under
196+
"Spec Labels" in https://onsi.github.io/ginkgo/#filtering-specs. This can focus
197+
on tests and exclude others in a single parameter without using regular expressions.
198+
199+
--ginkgo.noColor="n": If set to "y", ginkgo will not use color in the output
200+
197201
--ginkgo.trace=false: If set, default reporter prints out the full stack trace
198202
when a failure occurs
199203
@@ -283,7 +287,7 @@ First, compile the E2E test suite with additional compiler flags
283287
make WHAT=test/e2e/e2e.test GOGCFLAGS="all=-N -l" GOLDFLAGS=""
284288
```
285289

286-
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
290+
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
287291

288292
```sh
289293
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
@@ -462,7 +466,7 @@ kubetest --up
462466
#
463467
# You can target Feature:MasterUpgrade or Feature:ClusterUpgrade
464468
cd ../kubernetes
465-
kubetest --provider=gke --test --check-version-skew=false --test_args="--ginkgo.focus=\[Feature:MasterUpgrade\]"
469+
kubetest --provider=gke --test --check-version-skew=false --test_args="--ginkgo.label-filter=Feature:MasterUpgrade"
466470

467471
# Run old tests with new kubectl
468472
cd ../kubernetes_old
@@ -523,8 +527,10 @@ where `->` means upgrading; container_vm (cvm) and gci are image names.
523527
524528
## Kinds of tests
525529
526-
Tests can be labeled with any of the following labels, in order of increasing
527-
precedence (that is, each label listed below supersedes the previous ones):
530+
Tests can be labeled. Labels appear with square brackets inside the test names
531+
(the traditional approach) *and* are Ginkgo v2 labels (since Kubernetes v1.29).
532+
Available labels in order of increasing precedence (that is, each label listed
533+
below supersedes the previous ones):
528534
529535
- If a test has no labels, it is expected to run fast (under five minutes), be
530536
able to be run in parallel, and be consistent.
@@ -555,8 +561,12 @@ monitored closely in CI. `[Flaky]` tests are by default not run, unless a
555561
556562
- `[Feature:.+]`: If a test has non-default requirements to run or targets
557563
some non-core functionality, and thus should not be run as part of the standard
558-
suite, it receives a `[Feature:.+]` label, e.g. `[Feature:Performance]` or
559-
`[Feature:Ingress]`. `[Feature:.+]` tests are not run in our core suites,
564+
suite, it receives a `[Feature:.+]` label. This non-default requirement could
565+
be some special cluster setup (e.g. `Feature:IPv6DualStack` indicates that the
566+
cluster must support dual-stack pod and service networks) or that the test has
567+
special behavior that makes it unsuitable for a normal test run (e.g.
568+
`Feature:PerformanceDNS` marks a test that stresses cluster DNS performance
569+
with many services). `[Feature:.+]` tests are not run in our core suites,
560570
instead running in custom suites. If a feature is experimental or alpha and is
561571
not enabled by default due to being incomplete or potentially subject to
562572
breaking changes, it does *not* block PR merges, and thus should run in
@@ -577,21 +587,86 @@ to be eligible for this tag. This tag does not supersed any other labels.
577587
- `[LinuxOnly]`: If a test is known to be using Linux-specific features
578588
(e.g.: seLinuxOptions) or is unable to run on Windows nodes, it is labeled
579589
`[LinuxOnly]`. When using Windows nodes, this tag should be added to the
580-
`skip` argument.
590+
`skip` argument. This is not using `[Feature:LinuxOnly]` because that
591+
would have implied changing all CI jobs which skip tests with unknown
592+
requirements.
581593
582594
- The following tags are not considered to be exhaustively applied, but are
583595
intended to further categorize existing `[Conformance]` tests, or tests that are
584596
being considered as candidate for promotion to `[Conformance]` as we work to
585597
refine requirements:
586598
- `[Privileged]`: This is a test that requires privileged access
587-
- `[Internet]`: This is a test that assumes access to the public internet
588599
- `[Deprecated]`: This is a test that exercises a deprecated feature
600+
601+
- For tests that depend on feature gates, the following are set automatically:
589602
- `[Alpha]`: This is a test that exercises an alpha feature
590603
- `[Beta]`: This is a test that exercises a beta feature
591604
605+
Conceptually, these are non-default requirements as defined above under
606+
`[Feature:.+]`, but for historic reasons and the sake of brevity they don't
607+
have that prefix when embedded in test names. They *do* have that prefix in the
608+
Ginkgo v2 label, so use e.g. `--filter-label=Feature: containsAny Alpha` to
609+
run them. The normal `--filter-label=Feature: isEmpty` excludes them.
610+
611+
Note that at the moment, not all jobs filter out tests with `Alpha` or `Beta`
612+
requirements like that. Therefore all tests with such a requirement also
613+
have to be annotated with a `[Feature]` tag. This restriction will be lifted
614+
once migration of jobs to `--filter-label` is completed.
615+
592616
Every test should be owned by a [SIG](/sig-list.md),
593617
and have a corresponding `[sig-<name>]` label.
594618
619+
## Selecting tests to run
620+
621+
See https://onsi.github.io/ginkgo/#filtering-specs for a general introduction.
622+
623+
Focusing on a specific test by its name is useful when interactively running
624+
just one or a few related tests. The test name is a concatenation of multiple
625+
strings. To get a list of all full test names, run:
626+
627+
```console
628+
$ e2e.test -list-tests
629+
The following spec names can be used with 'ginkgo run --focus/skip':
630+
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
631+
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
632+
test/e2e/apimachinery/flowcontrol.go:190: [sig-api-machinery] API priority and fairness should ensure that requests can't be drowned out (fairness)
633+
...
634+
```
635+
636+
Or within the Kubernetes repo:
637+
638+
```console
639+
$ go test -v ./test/e2e -args -list-tests
640+
The following spec names can be used with 'ginkgo run --focus/skip':
641+
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
642+
...
643+
```
644+
645+
The same works for other Kubernetes E2E suites, like `e2e_node`.
646+
647+
In Prow jobs, selection by labels is often simpler. See
648+
[below]((#kinds-of-tests) for documentation of the different labels that are in
649+
use. A full list of labels used by a specific E2E suite can be obtained with
650+
`--list-labels`.
651+
652+
A common pattern is to run only tests which have no special cluster setup
653+
requirements and are not flaky:
654+
655+
--filter-label='Feature: isEmpty && !Flaky'
656+
657+
Feature owners have to ensure that tests excluded that way from shared CI
658+
jobs are executed in dedicated jobs (more on CI below):
659+
660+
--filter-label='Feature: containsAny MyAwesomeFeature'
661+
662+
In jobs that support certain well-known features it is possible to run tests
663+
which have no special requirements or at least only depend on the supported
664+
features:
665+
666+
# Alpha APIs and features enabled, allow tests depending on that as
667+
# long as they have no other special requirements.
668+
--filter-label='Feature: isSubsetOf Alpha'
669+
595670
### Viper configuration and hierarchichal test parameters.
596671
597672
The future of e2e test configuration idioms will be increasingly defined using viper, and decreasingly via flags.
@@ -665,6 +740,14 @@ non-`[Disruptive]`, non-`[Flaky]`, non-`[Feature:.+]` tests in parallel.
665740
- `kubernetes-e2e-<provider>-serial` runs all `[Serial]` and `[Disruptive]`,
666741
non-`[Flaky]`, non-`[Feature:.+]` tests in serial.
667742
743+
- `ci-kubernetes-e2e-kind-alpha-features` runs all tests without any special
744+
requirements and tests that only have alpha feature gates and API groups
745+
as requirement.
746+
747+
- `ci-kubernetes-e2e-kind-beta-features` runs all tests without any special
748+
requirements and tests that only have beta feature gates and API groups
749+
as requirement.
750+
668751
We also run non-default tests if the tests exercise general-availability ("GA")
669752
features that require a special environment to run in, e.g.
670753
`kubernetes-e2e-gce-scalability` and `kubernetes-kubemark-gce`, which test for

0 commit comments

Comments
 (0)