mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
test, build: support failpoints
This commit is contained in:
parent
6009e88077
commit
7f8ffd7dbe
22
build
22
build
@ -6,6 +6,25 @@ REPO_PATH="${ORG_PATH}/etcd"
|
|||||||
export GO15VENDOREXPERIMENT="1"
|
export GO15VENDOREXPERIMENT="1"
|
||||||
eval $(go env)
|
eval $(go env)
|
||||||
GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
|
GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
|
||||||
|
if [ ! -z "$FAILPOINTS" ]; then
|
||||||
|
GIT_SHA="$GIT_SHA"-FAILPOINTS
|
||||||
|
fi
|
||||||
|
|
||||||
|
# enable/disable failpoints
|
||||||
|
toggle_failpoints() {
|
||||||
|
FAILPKGS="etcdserver/"
|
||||||
|
|
||||||
|
mode="disable"
|
||||||
|
if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
|
||||||
|
if [ ! -z "$1" ]; then mode="$1"; fi
|
||||||
|
|
||||||
|
if which gofail >/dev/null 2>&1; then
|
||||||
|
gofail "$mode" $FAILPKGS
|
||||||
|
elif [ "$mode" != "disable" ]; then
|
||||||
|
echo "FAILPOINTS set but gofail not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
etcd_build() {
|
etcd_build() {
|
||||||
if [ -z "${GOARCH}" ] || [ "${GOARCH}" = "$(go env GOHOSTARCH)" ]; then
|
if [ -z "${GOARCH}" ] || [ "${GOARCH}" = "$(go env GOHOSTARCH)" ]; then
|
||||||
@ -13,10 +32,13 @@ etcd_build() {
|
|||||||
else
|
else
|
||||||
out="bin/${GOARCH}"
|
out="bin/${GOARCH}"
|
||||||
fi
|
fi
|
||||||
|
toggle_failpoints
|
||||||
# Static compilation is useful when etcd is run in a container
|
# Static compilation is useful when etcd is run in a container
|
||||||
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=${GIT_SHA}" -o ${out}/etcd ${REPO_PATH}/cmd
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=${GIT_SHA}" -o ${out}/etcd ${REPO_PATH}/cmd
|
||||||
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggle_failpoints
|
||||||
|
|
||||||
# don't build when sourced
|
# don't build when sourced
|
||||||
(echo "$0" | grep "/build$") && etcd_build || true
|
(echo "$0" | grep "/build$") && etcd_build || true
|
||||||
|
5
test
5
test
@ -168,10 +168,13 @@ mkdir -p $GOPATH
|
|||||||
ln -s ${PWD}/cmd/vendor $GOPATH/src
|
ln -s ${PWD}/cmd/vendor $GOPATH/src
|
||||||
|
|
||||||
# fail fast on static tests
|
# fail fast on static tests
|
||||||
GO_BUILD_FLAGS="-a -v" etcd_build
|
toggle_failpoints disable
|
||||||
fmt_tests
|
fmt_tests
|
||||||
dep_tests
|
dep_tests
|
||||||
|
|
||||||
|
# fail fast on static tests
|
||||||
|
GO_BUILD_FLAGS="-a -v" etcd_build
|
||||||
|
|
||||||
unit_tests
|
unit_tests
|
||||||
if [ -n "$INTEGRATION" ]; then
|
if [ -n "$INTEGRATION" ]; then
|
||||||
integration_tests
|
integration_tests
|
||||||
|
Loading…
x
Reference in New Issue
Block a user