-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ozdanborne/solo-tests
Run e2e's as standalone
- Loading branch information
Showing
7 changed files
with
1,663 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
bin | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,25 @@ | |
# Inspiration: https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/conformance/build/Dockerfile | ||
FROM golang | ||
LABEL maintainer "[email protected]" | ||
RUN go get github.com/Masterminds/glide | ||
RUN go get -u github.com/jteeuwen/go-bindata/... | ||
WORKDIR /go/src/github.com/ozdanborne/k8s-e2e-containerized | ||
ADD glide.yaml . | ||
ADD glide.lock . | ||
RUN glide install -v | ||
# generate go-bindata. see: https://github.com/kubernetes/kubernetes/issues/24976 | ||
RUN cd vendor/k8s.io/kubernetes && \ | ||
go-bindata \ | ||
-pkg generated -ignore .jpg -ignore .png -ignore .md \ | ||
./examples/* ./docs/user-guide/* test/e2e/testing-manifests/kubectl/* test/images/* && \ | ||
mv bindata.go test/e2e/generated | ||
ADD src . | ||
RUN CGO_ENABLED=0 go test -c -o e2e.test . | ||
FROM alpine:3.6 | ||
VOLUME /report | ||
ENV FOCUS="(Networking).*(\[Conformance\])|\[Feature:NetworkPolicy\]" | ||
COPY --from=0 /go/src/github.com/ozdanborne/k8s-e2e-containerized/e2e.test /usr/local/bin/e2e.test | ||
ADD kubeconfig /root/kubeconfig | ||
ADD ./bin/e2e.test . | ||
CMD ./e2e.test -kubeconfig=/root/kubeconfig --ginkgo.focus="$FOCUS" -report-dir=/report | ||
ENV FOCUS="(Networking).*(\[Conformance\])|\[Feature:NetworkPolicy\]" | ||
ENV SKIP="named port" | ||
CMD e2e.test -kubeconfig=/root/kubeconfig --ginkgo.focus="$FOCUS" --ginkgo.skip="$SKIP" -report-dir=/report | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,68 @@ | ||
# I Containerized the k8s e2e's. | ||
# Containerized Kubernetes e2e's | ||
|
||
[![Docker Pulls](https://img.shields.io/docker/pulls/ozdanborne/k8s-e2e.svg)](https://hub.docker.com/r/ozdanborne/k8s-e2e/) | ||
|
||
#### Usage | ||
|
||
#### How to run the k8s-e2e's before I containerized them: | ||
If your k8s-apiserver is running at `localhost:8080` with no auth: | ||
|
||
Step 1: **Build Kubernetes**. | ||
|
||
Step 2: Run the Kubernetes End-to-End Tests. | ||
``` | ||
docker run --net=host ozdanborne/k8s-e2e | ||
``` | ||
|
||
#### How to run the k8s-e2e's now that I containerized them: | ||
Otherwise, volume mount your own kubeconfig: | ||
|
||
Step 1: Run the Kubernetes End-to-End Tests. | ||
```bash | ||
docker run --net=host -v ~/.kube/config:/root/kubeconfig ozdanborne/k8s-e2e | ||
``` | ||
|
||
Step 2: Congratulate yourself on not even having to build Kubernetes first. | ||
###### Configure ginkgo.focus | ||
|
||
### You too can run the k8s-e2e's on your cluster without having to build Kubernetes first. | ||
``` | ||
docker run --net=host -e FOCUS='Conformance' ozdanborne/k8s-e2e | ||
``` | ||
|
||
#### Run using Docker | ||
###### XML Results | ||
|
||
To run the e2e's using Docker, volume mount in a populated kubeconfig: | ||
XML test results will be output to `/result` in the container. Volume mount this | ||
directory onto the host to view results once the container has finished: | ||
|
||
```docker run --net=host ozdanborne/k8s-e2e | ||
docker run --net=host -v ./result:/result ozdanborne/k8s-e2e | ||
``` | ||
docker run -v ~/.kube/config:/root/kubeconfig ozdanborne/k8s-e2e | ||
``` | ||
|
||
If your apiserver is running at `localhost:8080` with no auth, you can | ||
rely on [the default kubeconfig already at `/root/kubeconfig`](https://github.com/ozdanborne/k8s-e2e-containerized/blob/run-as-plain-container/kubeconfig). | ||
#### Building | ||
|
||
###### Docker Image | ||
|
||
``` | ||
docker run --net=host ozdanborne/k8s-e2e | ||
docker build -t ozdanborne/k8s-e2e:dev . | ||
``` | ||
|
||
#### Run using Kubernetes | ||
> Docker builds use multi-stage builds and do not leave a binary on the host. If you need a binary on the host, you must manually build it (see next section). | ||
You can also run the e2e's as a Kubernetes pod by overriding the default | ||
command with one which leaves out `-kubeconfig`. When omitted, the e2e's will | ||
rely on the `KUBERNETES_SERVICE_HOST` and `KUBERNETES_SERVICE_PORT` which | ||
are set for every pod: | ||
###### Binary | ||
|
||
``` | ||
kubectl run e2e --image=ozdanborne/k8s-e2e --restart=Never --attach -- ./e2e.test --ginkgo.focus="(Networking).*(\[Conformance\])|\[Feature:NetworkPolicy\]" | ||
``` | ||
1. Install glide dependencies: | ||
|
||
### Test Results XML | ||
``` | ||
glide install -v | ||
``` | ||
|
||
XML test results will be output to `/result` in the container. Volume mount this | ||
directory onto the host to view results once the container has finished. | ||
2. Generate go-bindata for Kubernetes: | ||
|
||
``` | ||
pushd vendor/k8s.io/kubernetes | ||
go-bindata \ | ||
-pkg generated -ignore .jpg -ignore .png -ignore .md \ | ||
./examples/* ./docs/user-guide/* test/e2e/testing-manifests/kubectl/* test/images/* | ||
mv bindata.go test/e2e/generated | ||
popd | ||
``` | ||
|
||
## Future Work | ||
3. Build e2e.test | ||
|
||
**Pass Target Apiserver as Param** | ||
``` | ||
go test -o e2e.test -c . | ||
``` | ||
|
||
It'd be useful to accept an apiserver address as a param at runtime. | ||
Unfortunately, I couldn't get `e2e.test` to use the `-host` passed to it. |
Oops, something went wrong.