jenkins e2e test script setup
This commit is contained in:
Родитель
36303914a4
Коммит
541f1b77cd
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
mkdir -p _output/bin || true
|
||||
|
||||
option="${1}"
|
||||
case ${option} in
|
||||
"setup")
|
||||
go build -o _output/bin/e2e-setup ./test/e2e/framework/setup/main.go
|
||||
_output/bin/e2e-setup --kubeconfig ${KUBERNETES_KUBECONFIG_PATH}
|
||||
;;
|
||||
"teardown")
|
||||
go build -o _output/bin/e2e-teardown ./test/e2e/framework/teardown/main.go
|
||||
_output/bin/e2e-teardown --kubeconfig ${KUBERNETES_KUBECONFIG_PATH}
|
||||
;;
|
||||
*) echo "Unknown option ${option}"
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
origpwd=$(pwd)
|
||||
GOPATH="${origpwd}/../build-${BUILD_ID}/gopath/"
|
||||
rm -rf $GOPATH
|
||||
mkdir -p $GOPATH
|
||||
cd $GOPATH
|
||||
export GOPATH=`pwd`
|
||||
echo "GOPATH: ${GOPATH}"
|
||||
|
||||
mkdir -p $GOPATH/src/github.com/coreos
|
||||
ln -s "${origpwd}" $GOPATH/src/github.com/coreos/kube-etcd-controller
|
||||
cd $GOPATH/src/github.com/coreos/kube-etcd-controller
|
||||
|
||||
glide install
|
||||
|
||||
if "hack/test"; then
|
||||
echo "Success!"
|
||||
else
|
||||
echo "Fail!"
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [ -z "${PASSES-}" ]; then
|
||||
PASSES="fmt build e2e"
|
||||
fi
|
||||
|
||||
TEST_PKGS=`go list ./test/... | grep -v framework`
|
||||
|
||||
find_files() {
|
||||
find . -not \( \
|
||||
\( \
|
||||
-wholename './_output' \
|
||||
-o -wholename '*/vendor/*' \
|
||||
\) -prune \
|
||||
\) -name '*.go'
|
||||
}
|
||||
|
||||
function fmt_pass {
|
||||
allfiles=$(find_files)
|
||||
echo "Checking gofmt..."
|
||||
for file in $allfiles; do
|
||||
checkRes=$(gofmt -l -s -d $file)
|
||||
if [ -n "${checkRes}" ]; then
|
||||
echo -e "gofmt checking failed:\n${checkRes}"
|
||||
exit 255
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
echo "Checking govet..."
|
||||
for file in $allfiles; do
|
||||
checkRes=$(go vet $file)
|
||||
if [ -n "${checkRes}" ]; then
|
||||
echo -e "go vet checking failed:\n${checkRes}"
|
||||
exit 255
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function build_pass {
|
||||
CONTROLLER_IMAGE=gcr.io/coreos-k8s-scale-testing/kube-etcd-controller hack/build/controller/build
|
||||
BACKUP_IMAGE=gcr.io/coreos-k8s-scale-testing/kube-etcd-backup hack/build/backup/build
|
||||
}
|
||||
|
||||
function e2e_pass {
|
||||
hack/e2e setup
|
||||
test_pass="0"
|
||||
go test -v ${TEST_PKGS} || test_pass="1"
|
||||
hack/e2e teardown
|
||||
return $test_pass
|
||||
}
|
||||
|
||||
for p in $PASSES; do
|
||||
${p}_pass
|
||||
done
|
||||
|
||||
echo "test success"
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
mkdir -p _output/bin || true
|
||||
|
||||
option="${1}"
|
||||
case ${option} in
|
||||
"setup") go build -o _output/bin/e2e-setup ./test/e2e/framework/setup/main.go
|
||||
_output/bin/e2e-setup --kubeconfig ${KUBERNETES_KUBECONFIG_PATH}
|
||||
;;
|
||||
"teardown") go build -o _output/bin/e2e-teardown ./test/e2e/framework/teardown/main.go
|
||||
_output/bin/e2e-teardown --kubeconfig ${KUBERNETES_KUBECONFIG_PATH}
|
||||
;;
|
||||
*) echo "Unknown option ${option}"
|
||||
;;
|
||||
esac
|
|
@ -9,7 +9,7 @@ import (
|
|||
type EtcdCluster struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
api.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec Spec `json: "spec"`
|
||||
Spec `json:"spec"`
|
||||
}
|
||||
|
||||
type Spec struct {
|
||||
|
|
|
@ -10,18 +10,17 @@ Prerequisites:
|
|||
|
||||
As first step, we need to setup environment for testing:
|
||||
```
|
||||
$ ./hack/e2e.sh setup
|
||||
$ ./hack/e2e setup
|
||||
```
|
||||
This will do all preparation work such as creating etcd controller.
|
||||
|
||||
e2e tests are written as go test. All go test techniques applies, e.g. picking what to run, timeout length.
|
||||
Let's say I want to run all tests in "test/e2e/":
|
||||
```
|
||||
$ cd ./test/e2e/
|
||||
$ go test -v
|
||||
$ go test -v ./test/e2e/
|
||||
```
|
||||
|
||||
Finally, we need to tear down the things we setup before:
|
||||
```
|
||||
$ ./hack/e2e.sh teardown
|
||||
$ ./hack/e2e teardown
|
||||
```
|
||||
|
|
Загрузка…
Ссылка в новой задаче