Skip to content

Commit a08ccca

Browse files
committed
Adding Conformance Guidelines document.
1 parent ea61fe5 commit a08ccca

File tree

4 files changed

+161
-56
lines changed

4 files changed

+161
-56
lines changed

contributors/devel/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Guide](http://kubernetes.io/docs/admin/).
2626

2727
* **Testing** ([testing.md](testing.md)): How to run unit, integration, and end-to-end tests in your development sandbox.
2828

29+
* **Conformance Testing** ([conformance-tests.md](conformance-tests.md))
30+
What is conformance testing and how to create/manage them.
31+
2932
* **Hunting flaky tests** ([flaky-tests.md](flaky-tests.md)): We have a goal of 99.9% flake free tests.
3033
Here's how to run your tests many times.
3134

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Conformance Testing in Kubernetes
2+
3+
The Kubernetes conformance test suite is a set of testcases, currently a
4+
subset of the integration/e2e tests, that the Architecture SIG has approved
5+
to define the core set of interoperable features that all Kubernetes
6+
deployments must support.
7+
8+
Contributors must write and submit e2e tests first (approved by owning Sigs).
9+
Once the new tests prove to be stable in CI runs, later create a follow up PR
10+
to add the test to conformance. This approach also decouples the development
11+
of useful tests from their promotion to conformance.
12+
13+
A conformance test verifies the expected functionality works as a user might encounter it in the wild,
14+
and tests should begin by covering the most important and visible aspects of the function.
15+
16+
### Conformance Test Requirements
17+
18+
A test is eligible for promotion to conformance if it meets the following requirements:
19+
20+
- testing GA feature (not alpha or beta APIs, nor deprecated features)
21+
- must be portable (not dependent on provider-specific capabilities or on the public internet)
22+
- cannot test a feature which obviously cannot be supported on a broad range of platforms
23+
(i.e. testing of multiple disk mounts, GPUs, high density)
24+
- cannot test an optional feature (e.g. not policy enforcement)
25+
- should be non-privileged (neither root on nodes, network, nor cluster)
26+
- cannot rely on any particular non-standard file system permissions granted to containers or users
27+
(i.e. sharing writable host /tmp with a container)
28+
- should be stable and run consistently
29+
- cannot skip providers (there should be no Skip like directives added to the test),
30+
especially in the Nucleus or Application layers as described
31+
[here](https://github.com/kubernetes/community/blob/master/contributors/devel/architectural-roadmap.md).
32+
- cannot test cloud provider specific features (i.e. GCE monitoring, S3 Bucketing, ...)
33+
- should work with default settings for all configuration parameters
34+
(example: the default list of admission plugins should not have to be tweaked for passing conformance).
35+
- cannot rely on any binaries that are not required for the
36+
linux kernel or for a kubelet to run (i.e. git)
37+
38+
### Conformance Test Version Skew Policy
39+
40+
As each new release of Kubernetes provides new functionality, the subset of
41+
tests necessary to demonstrate conformance grows with each release. Conformance
42+
is thus considered versioned, with the same backwards compatibility guarantees
43+
as laid out in [our versioning policy](/contributors/design-proposals/release/versioning.md#supported-releases-and-component-skew).
44+
Conformance tests for a given version should be run off of the release branch
45+
that corresponds to that version. Thus `v1.2` conformance tests would be run
46+
from the head of the `release-1.2` branch. eg:
47+
48+
- A v1.3 development cluster should pass v1.1, v1.2 conformance tests
49+
50+
- A v1.2 cluster should pass v1.1, v1.2 conformance tests
51+
52+
- A v1.1 cluster should pass v1.0, v1.1 conformance tests, and fail v1.2
53+
conformance tests
54+
55+
56+
### Running Conformance Tests
57+
58+
Conformance tests are designed to be run with no cloud provider configured.
59+
Conformance tests can be run against clusters that have not been created with
60+
`hack/e2e.go`, just provide a kubeconfig with the appropriate endpoint and
61+
credentials.
62+
63+
```sh
64+
# setup for conformance tests
65+
export KUBECONFIG=/path/to/kubeconfig
66+
export KUBERNETES_CONFORMANCE_TEST=y
67+
68+
# run all conformance tests
69+
go run hack/e2e.go -- --provider=skeleton --test --test_args="--ginkgo.focus=\[Conformance\]"
70+
71+
# run all parallel-safe conformance tests in parallel
72+
GINKGO_PARALLEL=y go run hack/e2e.go -- --provider=skeleton --test --test_args="--ginkgo.focus=\[Conformance\] --ginkgo.skip=\[Serial\]"
73+
74+
# ... and finish up with remaining tests in serial
75+
go run hack/e2e.go -- --provider=skeleton --test --test_args="--ginkgo.focus=\[Serial\].*\[Conformance\]"
76+
```
77+
78+
### Kubernetes Conformance Document
79+
For each Kubernetes release, a Conformance Document will be generated
80+
that lists all of the tests that comprise the conformance test suite, along
81+
with the formal specification of each test. For example conformance document for
82+
1.9 can be found [here](https://github.com/cncf/k8s-conformance/blob/master/docs/KubeConformance-1.9.md).
83+
This document will help people understand what features are being tested without having to look through
84+
the testcase's code directly.
85+
86+
87+
## Adding New Tests
88+
89+
To promote a testcase to the conformance test suite, the following
90+
steps must be taken:
91+
- as a prerequisite, the test case is already part of e2e and is not flaky
92+
- the testcase must use the `framework.ConformanceIt()` function rather
93+
than the `framework.It()` function
94+
- the testcase must include a comment immediately before the
95+
`framework.ConformanceIt()` call that includes all of the required
96+
metadata about the test (see the [Test Metadata](#test-metadata) section)
97+
- use "Promote xxx e2e test to Conformance" as template of your PR title
98+
- tag your PR with "/area conformance" label
99+
- send your PR to Sig-Architecture for review by adding "@kubernetes/sig-architecture-pr-reviews"
100+
also CC the relevant Sig and Sig-Architecture
101+
102+
103+
### Test Metadata
104+
105+
Each conformance test must include the following piece of metadata
106+
within its associated comment:
107+
108+
- `Release`: indicates the Kubernetes release that the test was added to the
109+
conformance test suite. If the test was modified in subsequent releases
110+
then those releases should be included as well (comma separated)
111+
- `Testname`: a human readable short name of the test
112+
- `Description`: a detailed description of the test. This field must describe
113+
the required behaviour of the Kubernetes components being tested using
114+
[RFC2119](https://tools.ietf.org/html/rfc2119) keywords. This field
115+
is meant to be a "specification" of the tested Kubernetes features, as
116+
such, it must be detailed enough so that readers can fully understand
117+
the aspects of Kubernetes that are being tested without having to read
118+
the test's code directly. Additionally, this test should provide a clear
119+
distinction between the parts of the test that are there for the purpose
120+
of validating Kubernetes rather than simply infrastructure logic that
121+
is necessary to setup, or clean up, the test.
122+
123+
### Sample Conformance Test
124+
125+
The following snippet of code shows a sample conformance test's metadata:
126+
127+
```
128+
/*
129+
Release : v1.9
130+
Testname: Kubelet: log output
131+
Description: By default the stdout and stderr from the process being
132+
executed in a pod MUST be sent to the pod's logs.
133+
*/
134+
framework.ConformanceIt("it should print the output to logs", func() {
135+
...
136+
})
137+
```
138+
139+
The corresponding portion of the Kubernetes Conformance Documentfor this test would then look
140+
like this:
141+
142+
>
143+
> ## [Kubelet: log output](https://github.com/kubernetes/kubernetes/tree/release-1.9/test/e2e_node/kubelet_test.go#L47)
144+
>
145+
> Release : v1.9
146+
>
147+
> By default the stdout and stderr from the process being executed in a pod MUST be sent to the pod's logs.
148+
149+
### Reporting Conformance Test Results
150+
151+
Conformance test results, by provider and releases, can be viewed in the
152+
federated [Conformance TestGrid dashboard](https://k8s-testgrid.appspot.com/conformance-all).
153+
If you wish to contribute conformance test results for your provider,
154+
please follow this [on-boarding document](https://docs.google.com/document/d/1lGvP89_DdeNO84I86BVAU4qY3h2VCRll45tGrpyx90A/edit#).
155+

contributors/devel/e2e-tests.md

+1-55
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
- [Kinds of tests](#kinds-of-tests)
2727
- [Viper configuration and hierarchichal test parameters.](#viper-configuration-and-hierarchichal-test-parameters)
2828
- [Conformance tests](#conformance-tests)
29-
- [Defining Conformance Subset](#defining-conformance-subset)
3029
- [Continuous Integration](#continuous-integration)
3130
- [What is CI?](#what-is-ci)
3231
- [What runs in CI?](#what-runs-in-ci)
@@ -606,60 +605,7 @@ Finally, `[Conformance]` tests represent a subset of the e2e-tests we expect to
606605
pass on **any** Kubernetes cluster. The `[Conformance]` label does not supersede
607606
any other labels.
608607

609-
As each new release of Kubernetes providers new functionality, the subset of
610-
tests necessary to demonstrate conformance grows with each release. Conformance
611-
is thus considered versioned, with the same backwards compatibility guarantees
612-
as laid out in [our versioning policy](/contributors/design-proposals/release/versioning.md#supported-releases-and-component-skew).
613-
Conformance tests for a given version should be run off of the release branch
614-
that corresponds to that version. Thus `v1.2` conformance tests would be run
615-
from the head of the `release-1.2` branch. eg:
616-
617-
- A v1.3 development cluster should pass v1.1, v1.2 conformance tests
618-
619-
- A v1.2 cluster should pass v1.1, v1.2 conformance tests
620-
621-
- A v1.1 cluster should pass v1.0, v1.1 conformance tests, and fail v1.2
622-
conformance tests
623-
624-
Conformance tests are designed to be run with no cloud provider configured.
625-
Conformance tests can be run against clusters that have not been created with
626-
`hack/e2e.go`, just provide a kubeconfig with the appropriate endpoint and
627-
credentials.
628-
629-
```sh
630-
# setup for conformance tests
631-
export KUBECONFIG=/path/to/kubeconfig
632-
export KUBERNETES_CONFORMANCE_TEST=y
633-
634-
# run all conformance tests
635-
go run hack/e2e.go -- --provider=skeleton --test --test_args="--ginkgo.focus=\[Conformance\]"
636-
637-
# run all parallel-safe conformance tests in parallel
638-
GINKGO_PARALLEL=y go run hack/e2e.go -- --provider=skeleton --test --test_args="--ginkgo.focus=\[Conformance\] --ginkgo.skip=\[Serial\]"
639-
640-
# ... and finish up with remaining tests in serial
641-
go run hack/e2e.go -- --provider=skeleton --test --test_args="--ginkgo.focus=\[Serial\].*\[Conformance\]"
642-
```
643-
644-
### Defining Conformance Subset
645-
646-
It is impossible to define the entire space of Conformance tests without knowing
647-
the future, so instead, we define the compliment of conformance tests, below
648-
(`Please update this with companion PRs as necessary`):
649-
650-
- A conformance test cannot test cloud provider specific features (i.e. GCE
651-
monitoring, S3 Bucketing, ...)
652-
653-
- A conformance test cannot rely on any particular non-standard file system
654-
permissions granted to containers or users (i.e. sharing writable host /tmp with
655-
a container)
656-
657-
- A conformance test cannot rely on any binaries that are not required for the
658-
linux kernel or for a kubelet to run (i.e. git)
659-
660-
- A conformance test cannot test a feature which obviously cannot be supported
661-
on a broad range of platforms (i.e. testing of multiple disk mounts, GPUs, high
662-
density)
608+
For more information on Conformance tests please see the [Conformance Testing](conformance-tests.md)
663609

664610
## Continuous Integration
665611

contributors/guide/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,12 @@ Testing is the responsibility of all contributors and is in part owned by all si
183183

184184
The main testing overview document is [here](/contributors/devel/testing.md).
185185

186-
There are three types of tests in kubernetes. The location of the test code varies with type, as do the specifics of the environment needed to successfully run the test:
186+
There are multiple types of tests in kubernetes. The location of the test code varies with type, as do the specifics of the environment needed to successfully run the test:
187187

188188
* Unit: These confirm that a particular function behaves as intended. Golang includes a native ability for unit testing via the [testing](https://golang.org/pkg/testing/) package. Unit test source code can be found adjacent to the corresponding source code within a given package. For example: functions defined in [kubernetes/cmd/kubeadm/app/util/version.go](https://git.k8s.io/kubernetes/cmd/kubeadm/app/util/version.go) will have unit tests in [kubernetes/cmd/kubeadm/app/util/version_test.go](https://git.k8s.io/kubernetes/cmd/kubeadm/app/util/version_test.go). These are easily run locally by any developer on any OS.
189189
* Integration: These tests cover interactions of package components or interactions between kubernetes components and some other non-kubernetes system resource (eg: etcd). An example would be testing whether a piece of code can correctly store data to or retrieve data from etcd. Integration tests are stored in [kubernetes/test/integration/](https://git.k8s.io/kubernetes/test/integration). Running these can require the developer set up additional functionality on their development system.
190190
* End-to-end ("e2e"): These are broad tests of overall kubernetes system behavior and coherence. These are more complicated as they require a functional kubernetes cluster built from the sources to be tested. A separate document [here](/contributors/devel/e2e-tests.md) details e2e testing and test cases themselves can be found in [kubernetes/test/e2e/](https://git.k8s.io/kubernetes/test/e2e).
191+
* Conformance: These are a set of testcases, currently a subset of the integration/e2e tests, that the Architecture SIG has approved to define the core set of interoperable features that all Kubernetes deployments must support. For more information on Conformance tests please see the [Conformance Testing](/contributors/devel/conformance-tests.md) Document.
191192

192193
Continuous integration will run these tests either as pre-submits on PRs, post-submits against master/release branches, or both. The results appear on [testgrid](https://testgrid.k8s.io).
193194

0 commit comments

Comments
 (0)