You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/devel/development.md
+1-103
Original file line number
Diff line number
Diff line change
@@ -294,109 +294,7 @@ hack/test-integration.sh
294
294
295
295
## End-to-End tests
296
296
297
-
You can run an end-to-end test which will bring up a master and two nodes, perform some tests, and then tear everything down. Make sure you have followed the getting started steps for your chosen cloud platform (which might involve changing the `KUBERNETES_PROVIDER` environment variable to something other than "gce".
298
-
299
-
```sh
300
-
cd kubernetes
301
-
hack/e2e-test.sh
302
-
```
303
-
304
-
Pressing control-C should result in an orderly shutdown but if something goes wrong and you still have some VMs running you can force a cleanup with this command:
305
-
306
-
```sh
307
-
go run hack/e2e.go --down
308
-
```
309
-
310
-
### Flag options
311
-
312
-
See the flag definitions in `hack/e2e.go` for more options, such as reusing an existing cluster, here is an overview:
313
-
314
-
```sh
315
-
# Build binaries for testing
316
-
go run hack/e2e.go --build
317
-
318
-
# Create a fresh cluster. Deletes a cluster first, if it exists
319
-
go run hack/e2e.go --up
320
-
321
-
# Create a fresh cluster at a specific release version.
322
-
go run hack/e2e.go --up --version=0.7.0
323
-
324
-
# Test if a cluster is up.
325
-
go run hack/e2e.go --isup
326
-
327
-
# Push code to an existing cluster
328
-
go run hack/e2e.go --push
329
-
330
-
# Push to an existing cluster, or bring up a cluster if it's down.
331
-
go run hack/e2e.go --pushup
332
-
333
-
# Run all tests
334
-
go run hack/e2e.go --test
335
-
336
-
# Run tests matching the regex "Pods.*env"
337
-
go run hack/e2e.go -v -test --test_args="--ginkgo.focus=Pods.*env"
338
-
339
-
# Alternately, if you have the e2e cluster up and no desire to see the event stream, you can run ginkgo-e2e.sh directly:
340
-
hack/ginkgo-e2e.sh --ginkgo.focus=Pods.*env
341
-
```
342
-
343
-
### Combining flags
344
-
345
-
```sh
346
-
# Flags can be combined, and their actions will take place in this order:
Copy file name to clipboardExpand all lines: docs/devel/e2e-tests.md
+105-25
Original file line number
Diff line number
Diff line change
@@ -32,33 +32,91 @@ Documentation for other releases can be found at
32
32
33
33
<!-- END MUNGE: UNVERSIONED_WARNING -->
34
34
35
-
# End-2-End Testing in Kubernetes
35
+
# End-to-End Testing in Kubernetes
36
36
37
37
## Overview
38
38
39
-
The end-2-end tests for kubernetes provide a mechanism to test behavior of the system, and to ensure end user operations match developer specifications. In distributed systems it is not uncommon that a minor change may pass all unit tests, but cause unforseen changes at the system level. Thus, the primary objectives of the end-2-end tests are to ensure a consistent and reliable behavior of the kubernetes code base, and to catch bugs early.
39
+
End-to-end (e2e) tests for Kubernetes provide a mechanism to test end-to-end behavior of the system, and is the last signal to ensure end user operations match developer specifications. Although unit and integration tests should ideally provide a good signal, the reality is in a distributed system like Kubernetes it is not uncommon that a minor change may pass all unit and integration tests, but cause unforseen changes at the system level. e2e testing is very costly, both in time to run tests and difficulty debugging, though: it takes a long time to build, deploy, and exercise a cluster. Thus, the primary objectives of the e2e tests are to ensure a consistent and reliable behavior of the kubernetes code base, and to catch hard-to-test bugs before users do, when unit and integration tests are insufficient.
40
40
41
-
The end-2-end tests in kubernetes are built atop of [ginkgo](http://onsi.github.io/ginkgo/) and [gomega](http://onsi.github.io/gomega/). There are a host of features that this BDD testing framework provides, and it is recommended that the developer read the documentation prior to diving into the tests.
41
+
The e2e tests in kubernetes are built atop of [Ginkgo](http://onsi.github.io/ginkgo/) and [Gomega](http://onsi.github.io/gomega/). There are a host of features that this BDD testing framework provides, and it is recommended that the developer read the documentation prior to diving into the tests.
42
42
43
-
The purpose of *this* document is to serve as a primer for developers who are looking to execute, or add tests, using a local development environment.
43
+
The purpose of *this* document is to serve as a primer for developers who are looking to execute or add tests using a local development environment.
44
44
45
45
## Building and Running the Tests
46
46
47
-
**NOTE:** The tests have an array of options. For simplicity, the examples will focus on leveraging the tests on a local cluster using `sudo ./hack/local-up-cluster.sh`
47
+
There are a variety of ways to run e2e tests, but we aim to decrease the number of ways to run e2e tests to a canonical way: `hack/e2e.go`.
48
48
49
-
### Building the Tests
49
+
You can run an end-to-end test which will bring up a master and nodes, perform some tests, and then tear everything down. Make sure you have followed the getting started steps for your chosen cloud platform (which might involve changing the `KUBERNETES_PROVIDER` environment variable to something other than "gce").
50
50
51
-
The tests are built into a single binary which can be run against any deployed kubernetes system. To build the tests, navigate to your source directory and execute:
51
+
To build Kubernetes, up a cluster, run tests, and tear everything down, use:
52
52
53
-
`$ make all`
53
+
```sh
54
+
go run hack/e2e.go -v --build --up --test --down
55
+
```
56
+
57
+
If you'd like to just perform one of these steps, here are some examples:
58
+
59
+
```sh
60
+
# Build binaries for testing
61
+
go run hack/e2e.go -v --build
62
+
63
+
# Create a fresh cluster. Deletes a cluster first, if it exists
64
+
go run hack/e2e.go -v --up
65
+
66
+
# Create a fresh cluster at a specific release version.
67
+
go run hack/e2e.go -v --up --version=0.7.0
68
+
69
+
# Test if a cluster is up.
70
+
go run hack/e2e.go -v --isup
71
+
72
+
# Push code to an existing cluster
73
+
go run hack/e2e.go -v --push
74
+
75
+
# Push to an existing cluster, or bring up a cluster if it's down.
76
+
go run hack/e2e.go -v --pushup
77
+
78
+
# Run all tests
79
+
go run hack/e2e.go -v --test
54
80
55
-
The output for the end-2-end tests will be a single binary called `e2e.test` under the default output directory, which is typically `_output/local/bin/linux/amd64/`. Within the repository there are scripts that are provided under the `./hack` directory that are helpful for automation, but may not apply for a local development purposes. Instead, we recommend familiarizing yourself with the executable options. To obtain the full list of options, run the following:
81
+
# Run tests matching the regex "\[Conformance\]" (the conformance tests)
82
+
go run hack/e2e.go -v -test --test_args="--ginkgo.focus=\[Conformance\]"
56
83
57
-
`$ ./e2e.test --help`
84
+
# Conversely, exclude tests that match the regex "Pods.*env"
85
+
go run hack/e2e.go -v -test --test_args="--ginkgo.focus=Pods.*env"
58
86
59
-
### Running the Tests
87
+
# Flags can be combined, and their actions will take place in this order:
# You can also specify an alternative provider, such as 'aws'
91
+
#
92
+
# e.g.:
93
+
KUBERNETES_PROVIDER=aws go run hack/e2e.go -v --build --pushup --test --down
60
94
61
-
For the purposes of brevity, we will look at a subset of the options, which are listed below:
95
+
# -ctl can be used to quickly call kubectl against your e2e cluster. Useful for
96
+
# cleaning up after a failed test or viewing logs. Use -v to avoid suppressing
97
+
# kubectl output.
98
+
go run hack/e2e.go -v -ctl='get events'
99
+
go run hack/e2e.go -v -ctl='delete pod foobar'
100
+
101
+
# Alternately, if you have the e2e cluster up and no desire to see the event stream, you can run ginkgo-e2e.sh directly:
102
+
hack/ginkgo-e2e.sh --ginkgo.focus=\[Conformance\]
103
+
```
104
+
105
+
The tests are built into a single binary which can be run used to deploy a Kubernetes system or run tests against an already-deployed Kubernetes system. See `go run hack/e2e.go --help` (or the flag definitions in `hack/e2e.go`) for more options, such as reusing an existing cluster.
106
+
107
+
### Cleaning up
108
+
109
+
During a run, pressing `control-C` should result in an orderly shutdown, but if something goes wrong and you still have some VMs running you can force a cleanup with this command:
110
+
111
+
```sh
112
+
go run hack/e2e.go -v --down
113
+
```
114
+
115
+
## Advanced testing
116
+
117
+
### Bringing up a cluster for testing
118
+
119
+
If you want, you may bring up a cluster in some other manner and run tests against it. To do so, or to do other non-standard test things, you can pass arguments into Ginkgo using `--test_args` (e.g. see above). For the purposes of brevity, we will look at a subset of the options, which are listed below:
62
120
63
121
```
64
122
-ginkgo.dryRun=false: If set, ginkgo will walk the test hierarchy without actually running anything. Best paired with -v.
@@ -75,7 +133,7 @@ For the purposes of brevity, we will look at a subset of the options, which are
75
133
-repo-root="../../": Root directory of kubernetes repository, for finding test files.
76
134
```
77
135
78
-
Prior to running the tests, it is recommended that you first create a simple auth file in your home directory, e.g. `$HOME/.kube/config` , with the following:
136
+
Prior to running the tests, you may want to first create a simple auth file in your home directory, e.g. `$HOME/.kube/config` , with the following:
79
137
80
138
```
81
139
{
@@ -84,23 +142,39 @@ Prior to running the tests, it is recommended that you first create a simple aut
84
142
}
85
143
```
86
144
87
-
Next, you will need a cluster that you can test against. As mentioned earlier, you will want to execute `sudo ./hack/local-up-cluster.sh`. To get a sense of what tests exist, you may want to run:
145
+
As mentioned earlier there are a host of other options that are available, but they are left to the developer.
Conversely, if you wish to exclude a set of tests, you can run:
154
+
It can be much faster to iterate on a local cluster instead of a cloud-based one. To start a local cluster, you can run:
96
155
97
-
`e2e.test ... --ginkgo.skip="Density|Scale"`
156
+
```sh
157
+
# The PATH construction is needed because PATH is one of the special-cased
158
+
# environment variables not passed by sudo -E
159
+
sudo PATH=$PATH hack/local-up-cluster.sh
160
+
```
98
161
99
-
As mentioned earlier there are a host of other options that are available, but are left to the developer
162
+
This will start a single-node Kubernetes cluster than runs pods using the local docker daemon. Press Control-C to stop the cluster.
100
163
101
-
**NOTE:** If you are running tests on a local cluster repeatedly, you may need to periodically perform some manual cleanup.
102
-
-`rm -rf /var/run/kubernetes`, clear kube generated credentials, sometimes stale permissions can cause problems.
103
-
-`sudo iptables -F`, clear ip tables rules left by the kube-proxy.
164
+
#### Testing against local clusters
165
+
166
+
In order to run an E2E test against a locally running cluster, point the tests at a custom host directly:
167
+
168
+
```sh
169
+
export KUBECONFIG=/path/to/kubeconfig
170
+
go run hack/e2e.go -v --test_args="--host=http://127.0.0.1:8080"
171
+
```
172
+
173
+
To control the tests that are run:
174
+
175
+
```sh
176
+
go run hack/e2e.go -v --test_args="--host=http://127.0.0.1:8080" --ginkgo.focus="Secrets"
177
+
```
104
178
105
179
## Kinds of tests
106
180
@@ -114,7 +188,13 @@ We are working on implementing clearer partitioning of our e2e tests to make run
114
188
-`[Skipped]`: `[Skipped]` is a legacy label that we're phasing out. If a test is marked `[Skipped]`, there should be an issue open to label it properly. `[Skipped]` tests are by default not run, unless a `focus` or `skip` argument is explicitly given.
115
189
-`[Feature:.+]`: If a test has non-default requirements to run or targets some non-core functionality, and thus should not be run as part of the standard suite, it receives a `[Feature:.+]` label, e.g. `[Feature:Performance]` or `[Feature:Ingress]`. `[Feature:.+]` tests are not run in our core suites, instead running in custom suites. If a feature is experimental or alpha and is not enabled by default due to being incomplete or potentially subject to breaking changes, it does *not* block the merge-queue, and thus should run in some separate test suites owned by the feature owner(s) (see #continuous_integration below).
116
190
117
-
Finally, `[Conformance]` tests are tests we expect to pass on **any** Kubernetes cluster. The `[Conformance]` label does not supersede any other labels. `[Conformance]` test policies are a work-in-progress; see #18162.
191
+
### Conformance tests
192
+
193
+
Finally, `[Conformance]` tests are tests we expect to pass on **any** Kubernetes cluster. The `[Conformance]` label does not supersede any other labels. `[Conformance]` test policies are a work-in-progress (see #18162).
194
+
195
+
End-to-end testing, as described above, is for [development distributions](writing-a-getting-started-guide.md). A conformance test is used on a [versioned distro](writing-a-getting-started-guide.md). (Links WIP)
196
+
197
+
The conformance test runs a subset of the e2e-tests against a manually-created cluster. It does not require support for up/push/down and other operations. To run a conformance test, you need to know the IP of the master for your cluster and the authorization arguments to use. The conformance test is intended to run against a cluster at a specific binary release of Kubernetes. See [conformance-test.sh](http://releases.k8s.io/HEAD/hack/conformance-test.sh).
118
198
119
199
## Continuous Integration
120
200
@@ -166,7 +246,7 @@ If we have determined that a test is known-flaky and cannot be fixed in the shor
166
246
167
247
## Performance Evaluation
168
248
169
-
Another benefit of the end-2-end tests is the ability to create reproducible loads on the system, which can then be used to determine the responsiveness, or analyze other characteristics of the system. For example, the density tests load the system to 30,50,100 pods per/node and measures the different characteristics of the system, such as throughput, api-latency, etc.
249
+
Another benefit of the e2e tests is the ability to create reproducible loads on the system, which can then be used to determine the responsiveness, or analyze other characteristics of the system. For example, the density tests load the system to 30,50,100 pods per/node and measures the different characteristics of the system, such as throughput, api-latency, etc.
170
250
171
251
For a good overview of how we analyze performance data, please read the following [post](http://blog.kubernetes.io/2015/09/kubernetes-performance-measurements-and.html)
0 commit comments