From b785b4741dec955562550bfa3b84a7e298ec41a5 Mon Sep 17 00:00:00 2001 From: hasbro17 Date: Wed, 23 May 2018 14:15:27 -0700 Subject: [PATCH] test: run e2e test pod without framework setup --- test/e2e/framework/framework.go | 11 +++++++++++ test/pod/simple/Dockerfile | 21 +++++++++++++++++++++ test/pod/simple/run-e2e | 9 +++++++++ test/pod/simple/simple-pod-templ.yaml | 15 +++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 test/pod/simple/Dockerfile create mode 100755 test/pod/simple/run-e2e create mode 100644 test/pod/simple/simple-pod-templ.yaml diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index aef00cdaf..8909b99d8 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -76,10 +76,21 @@ func setup() error { Namespace: *ns, opImage: *opImage, } + + // Skip the etcd-operator deployment setup if the operator image was not specified + if len(Global.opImage) == 0 { + return nil + } + return Global.setup() } func teardown() error { + // Skip the etcd-operator teardown if the operator image was not specified + if len(Global.opImage) == 0 { + return nil + } + err := Global.deleteOperatorCompletely("etcd-operator") if err != nil { return err diff --git a/test/pod/simple/Dockerfile b/test/pod/simple/Dockerfile new file mode 100644 index 000000000..55130b2a0 --- /dev/null +++ b/test/pod/simple/Dockerfile @@ -0,0 +1,21 @@ +# golang:X-alpine can't be used since it does not support the race detector flag which assumes a glibc based system, whereas alpine linux uses musl libc +# https://github.com/golang/go/issues/14481 +FROM golang:1.10.2 as builder + +RUN wget -nv -O /bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.10.2/bin/linux/amd64/kubectl + +RUN chmod a+x /bin/kubectl + +ADD ./ /go/src/github.com/coreos/etcd-operator + +WORKDIR /go/src/github.com/coreos/etcd-operator + +RUN go test ./test/e2e/ -c -o /bin/etcd-operator-e2e --race + +FROM busybox:1.28.3-glibc + +COPY --from=builder /bin/etcd-operator-e2e /bin +COPY --from=builder /bin/kubectl /bin +COPY --from=builder /go/src/github.com/coreos/etcd-operator/test/pod/simple/run-e2e /bin/run-e2e + +CMD ["/bin/run-e2e"] diff --git a/test/pod/simple/run-e2e b/test/pod/simple/run-e2e new file mode 100755 index 000000000..b055d9732 --- /dev/null +++ b/test/pod/simple/run-e2e @@ -0,0 +1,9 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +: ${TEST_NAMESPACE:?"Need to set TEST_NAMESPACE"} + +# Run e2e tests +/bin/etcd-operator-e2e -test.timeout 30m -test.failfast -test.parallel 4 --namespace=${TEST_NAMESPACE} diff --git a/test/pod/simple/simple-pod-templ.yaml b/test/pod/simple/simple-pod-templ.yaml new file mode 100644 index 000000000..a9f35eee6 --- /dev/null +++ b/test/pod/simple/simple-pod-templ.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: etcd-operator-e2e-tests +spec: + restartPolicy: Never + containers: + - name: etcd-operator-e2e-tests + image: + imagePullPolicy: Always + env: + - name: TEST_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace