Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit e94e1c6

Browse files
committed
Node e2e Makefile support for running remote tests against kubernetes-node-e2e-images.
Also includes other improvements: - Makefile rule to run tests against remote instance using existing host or image - Makefile will reuse an instance created from an image if it was not torn down - Runner starts gce instances in parallel with building source - Runner uses instance ip instead of hostname so that it doesn't need to resolve - Runner supports cleaning up files and processes on an instance without stopping / deleting it - Runner runs tests using `ginkgo` binary to support running tests in parallel
1 parent 0d3be6a commit e94e1c6

File tree

10 files changed

+437
-168
lines changed

10 files changed

+437
-168
lines changed

Diff for: Makefile

+16-4
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,28 @@ test_e2e:
9393
# Build and run node end-to-end tests.
9494
#
9595
# Args:
96-
# FOCUS: regexp that matches the tests to be run
97-
# SKIP: regexp that matches the tests that needs to be skipped
96+
# FOCUS: regexp that matches the tests to be run. Defaults to "".
97+
# SKIP: regexp that matches the tests that needs to be skipped. Defaults to "".
98+
# RUN_UNTIL_FAILURE: Ff true, pass --untilItFails to ginkgo so tests are run repeatedly until they fail. Defaults to false.
99+
# REMOTE: If true, run the tests on a remote host instance on GCE. Defaults to false.
100+
# IMAGES: for REMOTE=true only. Comma delimited list of images for creating remote hosts to run tests against. Defaults to "e2e-node-containervm-v20160321-image".
101+
# LIST_IMAGES: If true, don't run tests. Just output the list of available images for testing. Defaults to false.
102+
# HOSTS: for REMOTE=true only. Comma delimited list of running gce hosts to run tests against. Defaults to "".
103+
# DELETE_INSTANCES: for REMOTE=true only. Delete any instances created as part of this test run. Defaults to false.
104+
# ARTIFACTS: for REMOTE=true only. Local directory to scp test artifacts into from the remote hosts. Defaults to ""/tmp/_artifacts".
105+
# REPORT: for REMOTE=false only. Local directory to write juntil xml results to. Defaults to "/tmp/".
106+
# CLEANUP: for REMOTE=true only. If false, do not stop processes or delete test files on remote hosts. Defaults to true.
107+
# IMAGE_PROJECT: for REMOTE=true only. Project containing images provided to IMAGES. Defaults to "kubernetes-node-e2e-images".
108+
# INSTANCE_PREFIX: for REMOTE=true only. Instances created from images will have the name "${INSTANCE_PREFIX}-${IMAGE_NAME}". Defaults to "test"/
109+
#
98110
# Example:
99111
# make test_e2e_node FOCUS=kubelet SKIP=container
112+
# make test_e2e_node REMOTE=true DELETE_INSTANCES=true
100113
# Build and run tests.
101114
test_e2e_node:
102-
hack/e2e-node-test.sh FOCUS=$(FOCUS) SKIP=$(SKIP)
115+
hack/e2e-node-test.sh
103116
.PHONY: test_e2e_node
104117

105-
106118
# Remove all build artifacts.
107119
#
108120
# Example:

Diff for: docs/devel/e2e-node-tests.md

+134-94
Original file line numberDiff line numberDiff line change
@@ -34,147 +34,187 @@ Documentation for other releases can be found at
3434

3535
# Node End-To-End tests
3636

37-
Node e2e tests start kubelet and minimal supporting infrastructure to validate
38-
the kubelet on a host. Tests can be run either locally, against a remote host or
39-
against a GCE image.
37+
Node e2e tests are component tests meant for testing the Kubelet code on a custom host environment.
38+
39+
Tests can be run either locally or against a host running on GCE.
40+
41+
Node e2e tests are run as both pre- and post- submit tests by the Kubernetes project.
4042

4143
*Note: Linux only. Mac and Windows unsupported.*
4244

43-
## Running tests locally
45+
# Running tests
4446

45-
etcd must be installed and on the PATH to run the node e2e tests. To verify
46-
etcd is installed: `which etcd`. You can find instructions for installing etcd
47-
[on the etcd releases page](https://github.com/coreos/etcd/releases).
47+
## Locally
4848

49-
Run the tests locally: `make test_e2e_node`
49+
Why run tests *Locally*? Much faster than running tests Remotely.
5050

51-
Running the node e2e tests locally will build the kubernetes go source files and
52-
then start the kubelet, kube-apiserver, and etcd binaries on localhost before
53-
executing the ginkgo tests under test/e2e_node against the local kubelet
54-
instance.
51+
Prerequisites:
52+
- [Install etcd](https://github.com/coreos/etcd/releases) on your PATH
53+
- Verify etcd is installed correctly by running `which etcd`
54+
- [Install ginkgo](https://github.com/onsi/ginkgo) on your PATH
55+
- Verify ginkgo is installed correctly by running `which ginkgo`
5556

56-
## Running tests against a remote host
57+
From the Kubernetes base directory, run:
5758

58-
The node e2e tests can be run against one or more remote hosts using one of:
59-
* [e2e-node-jenkins.sh](../../test/e2e_node/jenkins/e2e-node-jenkins.sh) (gce
60-
only)
61-
* [run_e2e.go](../../test/e2e_node/runner/run_e2e.go) (requires passwordless ssh
62-
and remote passwordless sudo access over ssh)
63-
* using [run_e2e.go](../../test/e2e_node/runner/run_e2e.go) to build a tar.gz
64-
and executing on host (requires host access w/ remote sudo)
59+
```sh
60+
make test_e2e_node
61+
```
6562

66-
### Option 1: Configuring a new remote host from scratch for testing
63+
This will: run the *ginkgo* binary against the subdirectory *test/e2e_node*, which will in turn:
64+
- Ask for sudo access (needed for running some of the processes)
65+
- Build the Kubernetes source code
66+
- Pre-pull docker images used by the tests
67+
- Start a local instance of *etcd*
68+
- Start a local instance of *kube-apiserver*
69+
- Start a local instance of *kubelet*
70+
- Run the test using the locally started processes
71+
- Output the test results to STDOUT
72+
- Stop *kubelet*, *kube-apiserver*, and *etcd*
6773

68-
The host must contain an environment capable of running a minimal kubernetes cluster
69-
consisting of etcd, the kube-apiserver, and kubelet. The steps required to step a host vary between distributions
70-
(coreos, rhel, ubuntu, etc), but may include:
71-
* install etcd
72-
* install docker
73-
* add user running tests to docker group
74-
* install lxc and update grub commandline
75-
* enable tty-less sudo access
74+
## Remotely
7675

77-
These steps should be captured in [setup_host.sh](../../test/e2e_node/environment/setup_host.sh)
76+
Why Run tests *Remotely*? Tests will be run in a customized pristine environment. Closely mimics what will be done
77+
as pre- and post- submit testing performed by the project.
7878

79-
### Option 2: Copying an existing host image from another project
79+
Prerequisites:
80+
- [join the googlegroup](https://groups.google.com/forum/#!forum/kubernetes-dev)
81+
82+
- *This provides read access to the node test images.*
83+
- Setup a [Google Cloud Platform](https://cloud.google.com/) account and project with Google Compute Engine enabled
84+
- Install and setup the [gcloud sdk](https://cloud.google.com/sdk/downloads)
85+
- Verify the sdk is setup correctly by running `gcloud compute instances list` and `gcloud compute images list --project kubernetes-node-e2e-images`
8086

81-
If there is an existing image in another project you would like to use, you can use the script
82-
[copy-e2e-image.sh](../../test/e2e_node/jenkins/copy-e2e-image.sh) to copy an image
83-
from one GCE project to another.
87+
Run:
8488

8589
```sh
86-
copy-e2e-image.sh <image-to-be-copied-name> <from-gce-project> <to-gce-project>
90+
make test_e2e_node REMOTE=true
8791
```
8892

89-
### Running the tests
93+
This will:
94+
- Build the Kubernetes source code
95+
- Create a new GCE instance using the default test image
96+
- Instance will be called **test-e2e-node-containervm-v20160321-image**
97+
- Lookup the instance public ip address
98+
- Copy a compressed archive file to the host containing the following binaries:
99+
- ginkgo
100+
- kubelet
101+
- kube-apiserver
102+
- e2e_node.test (this binary contains the actual tests to be run)
103+
- Unzip the archive to a directory under **/tmp/gcloud**
104+
- Run the tests using the `ginkgo` command
105+
- Starts etcd, kube-apiserver, kubelet
106+
- The ginkgo command is used because this supports more features than running the test binary directly
107+
- Output the remote test results to STDOUT
108+
- `scp` the log files back to the local host under /tmp/_artifacts/e2e-node-containervm-v20160321-image
109+
- Stop the processes on the remote host
110+
- **Leave the GCE instance running**
90111

91-
1. If running tests against a running host on gce
112+
**Note: Subsequent tests run using the same image will *reuse the existing host* instead of deleting it and
113+
provisioning a new one. To delete the GCE instance after each test see
114+
*[DELETE_INSTANCE](#delete-instance-after-tests-run)*.**
92115

93-
* Make sure host names are resolvable to ssh by running `gcloud compute config-ssh` to
94-
update ~/.ssh/config with the GCE hosts. After running this command, check the hostnames
95-
in the ~/.ssh/config file and verify you have the correct access by running `ssh <host>`.
96116

97-
* Copy [template.properties](../../test/e2e_node/jenkins/template.properties)
117+
# Additional Remote Options
98118

99-
* Fill in `GCE_HOSTS` with the name of the host
119+
## Run tests using different images
100120

101-
* Run `test/e2e_node/jenkins/e2e-node-jenkins.sh <path to properties file>`
102-
* **Must be run from kubernetes root**
121+
This is useful if you want to run tests against a host using a different OS distro or container runtime than
122+
provided by the default image.
103123

104-
2. If running against a host anywhere else
124+
List the available test images using gcloud.
105125

106-
* **Requires password-less ssh and sudo access**
126+
```sh
127+
make test_e2e_node LIST_IMAGES=true
128+
```
107129

108-
* Make sure this works - e.g. `ssh <hostname> -- sudo echo "ok"`
109-
* If ssh flags are required (e.g. `-i`), they can be used and passed to the
110-
tests with `--ssh-options`
130+
This will output a list of the available images for the default image project.
111131

112-
* `go run test/e2e_node/runner/run_e2e.go --logtostderr --hosts <comma
113-
separated hosts>`
132+
Then run:
114133

115-
* **Must be run from kubernetes root**
134+
```sh
135+
make test_e2e_node REMOTE=true IMAGES="<comma-separated-list-images>"
136+
```
116137

117-
3. Alternatively, manually build and copy `e2e_node_test.tar.gz` to a remote
118-
host
138+
## Run tests against a running GCE instance (not an image)
119139

120-
* Build the tar.gz `go run test/e2e_node/runner/run_e2e.go --logtostderr
121-
--build-only`
140+
This is useful if you have an host instance running already and want to run the tests there instead of on a new instance.
122141

123-
* Copy `e2e_node_test.tar.gz` to the remote host
142+
```sh
143+
make test_e2e_node REMOTE=true HOSTS="<comma-separated-list-of-hostnames>"
144+
```
124145

125-
* Extract the archive on the remote host `tar -xzvf e2e_node_test.tar.gz`
146+
## Delete instance after tests run
126147

127-
* Run the tests `./e2e_node.test --logtostderr --vmodule=*=2
128-
--build-services=false --node-name=<hostname>`
148+
This is useful if you want recreate the instance for each test run to trigger flakes related to starting the instance.
129149

130-
* Note: This must be run from the directory containing the kubelet and
131-
kube-apiserver binaries.
150+
```sh
151+
make test_e2e_node REMOTE=true DELETE_INSTANCES=true
152+
```
132153

133-
## Running tests against a gce image
154+
## Keep instance, test binaries, and *processes* around after tests run
134155

135-
* Option 1: Build a gce image from a prepared gce host
136-
* Create the host from a base image and configure it (see above)
137-
* Run tests against this remote host to ensure that it is setup correctly
138-
before doing anything else
139-
* Create a gce *snapshot* of the instance
140-
* Create a gce *disk* from the snapshot
141-
* Create a gce *image* from the disk
142-
* Option 2: Copy a prepared image from another project
143-
* Instructions above
144-
* Test that the necessary gcloud credentials are setup for the project
145-
* `gcloud compute --project <project> --zone <zone> images list`
146-
* Verify that your image appears in the list
147-
* Copy [template.properties](../../test/e2e_node/jenkins/template.properties)
148-
* Fill in `GCE_PROJECT`, `GCE_ZONE`, `GCE_IMAGES`
149-
* Run `test/e2e_node/jenkins/e2e-node-jenkins.sh <path to properties file>`
150-
* **Must be run from kubernetes root**
156+
This is useful if you want to manually inspect or debug the kubelet process run as part of the tests.
151157

152-
## Kubernetes Jenkins CI and PR builder
158+
```sh
159+
make test_e2e_node REMOTE=true CLEANUP=false
160+
```
153161

154-
Node e2e tests are run against a static list of host environments continuously
155-
or when manually triggered on a github.com pull requests using the trigger
156-
phrase `@k8s-bot test node e2e`
162+
## Run tests using an image in another project
157163

158-
### CI Host environments
164+
This is useful if you want to create your own host image in another project and use it for testing.
159165

160-
TBD
166+
```sh
167+
make test_e2e_node REMOTE=true IMAGE_PROJECT="<name-of-project-with-images>" IMAGES="<image-name>"
168+
```
161169

162-
### PR builder host environments
170+
Setting up your own host image may require additional steps such as installing etcd or docker. See
171+
[setup_host.sh](../../test/e2e_node/environment/setup_host.sh) for common steps to setup hosts to run node tests.
163172

164-
| linux distro | distro version | docker version | etcd version | cloud provider |
165-
|-----------------|----------------|----------------|--------------|----------------|
166-
| containervm | | 1.8 | | gce |
167-
| coreos | stable | 1.8 | | gce |
168-
| debian | jessie | 1.10 | | gce |
169-
| ubuntu | trusty | 1.8 | | gce |
170-
| ubuntu | trusty | 1.9 | | gce |
171-
| ubuntu | trusty | 1.10 | | gce |
173+
## Create instances using a different instance name prefix
172174

175+
This is useful if you want to create instances using a different name so that you can run multiple copies of the
176+
test in parallel against different instances of the same image.
173177

178+
```sh
179+
make test_e2e_node REMOTE=true INSTANCE_PREFIX="my-prefix"
180+
```
181+
182+
# Additional Test Options for both Remote and Local execution
183+
184+
## Only run a subset of the tests
185+
186+
To run tests matching a regex:
187+
188+
```sh
189+
make test_e2e_node REMOTE=true FOCUS="<regex-to-match>"
190+
```
191+
192+
To run tests NOT matching a regex:
193+
194+
```sh
195+
make test_e2e_node REMOTE=true SKIP="<regex-to-match>"
196+
```
197+
198+
## Run tests continually until they fail
199+
200+
This is useful if you are trying to debug a flaky test failure. This will cause ginkgo to continually
201+
run the tests until they fail. **Note: this will only perform test setup once (e.g. creating the instance) and is
202+
less useful for catching flakes related creating the instance from an image.**
203+
204+
```sh
205+
make test_e2e_node REMOTE=true RUN_UNTIL_FAILURE=true
206+
```
174207

208+
# Notes on tests run by the Kubernetes project during pre-, post- submit.
175209

210+
The node e2e tests are run by the PR builder for each Pull Request and the results published at
211+
the bottom of the comments section. To re-run just the node e2e tests from the PR builder add the comment
212+
`@k8s-bot node e2e test this issue: #<Flake-Issue-Number or IGNORE>` and **include a link to the test
213+
failure logs if caused by a flake.**
176214

215+
The PR builder runs tests against the images listed in [jenkins-pull.properties](../../test/e2e_node/jenkins/jenkins-pull.properties)
177216

217+
The post submit tests run against the images listed in [jenkins-ci.properties](../../test/e2e_node/jenkins/jenkins-ci.properties)
178218

179219

180220
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

0 commit comments

Comments
 (0)