Skip to content

Commit 0c8727f

Browse files
committed
doc/testing/end-to-end.md: add end-to-end.md doc
1 parent d40444d commit 0c8727f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

doc/testing/end-to-end.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# End-to-End Testing the Operator SDK
2+
The operator-sdk is automatically tested using both unit tests and end-to-end tests anytime
3+
a pull request is made. The end-to-end tests ensure that the operator-sdk acts as intended by
4+
simulating how a typical user might use the SDK. The automated tests test each PR and run in
5+
Travis CI, and Travis CI has a couple of features to simplify the end-to-end tests that we run.
6+
However, it is possible to run the end-to-end tests locally as well.
7+
8+
## Running the E2E Tests Locally
9+
To run the tests locally, the tests either need access to a remote kubernetes cluster or a
10+
local minikube instance running on the machine.
11+
12+
### Remote Kubernetes Instance
13+
To run the tests on a remote cluster, the tests need access to a remote kubernetes cluster
14+
running kubernetes 1.10 as well as a docker image repo to push the operator image to,
15+
such as quay.io. To run the test, use this command:
16+
```
17+
$ go test ./test/e2e/... -kubeconfig "path-to-config" -image "<repository>:<tag>"
18+
```
19+
20+
This will run the tests on the cluster specified by the provided kubeconfig and the
21+
memcached-operator image that it build will be pushed to `<repository>:<tag>`.
22+
23+
### Local Minikube Instance
24+
To run the end-to-end tests on a local minikube cluster, the minikube instance must be
25+
started and its local docker repo must be linked to the host's docker repo. To do this,
26+
run these commands:
27+
```
28+
$ minikube start --kubernetes-version 1.10.0
29+
$ eval $(minikube docker-env)
30+
```
31+
32+
Once that is complete, the test can be run with this command:
33+
```
34+
$ go test ./test/e2e/...
35+
```
36+
37+
The test will run using the kube config in $HOME/.kube/config (which is where the minikube
38+
kubeconfig is placed by default) and the operator image will be built to directly to the
39+
minikube instance's local docker repo.
40+
41+
## Cleanup of the E2E Tests
42+
The end-to-end tests create a new project using the operator-sdk to run in the provided
43+
cluster. The tests are designed to cleanup everything that gets created, but some errors
44+
can cause these cleanups to fail. For example, if a segfault occurs or a user kills the
45+
testing process, the cleanup functions will not run. To manually clean up a test:
46+
1. Delete the created project in $GOPATH/src/github.com/example-inc/memcached-operator
47+
2. Delete the namespaces that the tests run in, which also deletes any resources created
48+
within the namespaces. The namespaces start with `memcached-memcached-group`.
49+
3. Delete the CRD (`kubectl delete -f deploy/crd.yaml`).

0 commit comments

Comments
 (0)