diff --git a/build b/build index 62891e592..1afe1ed7b 100755 --- a/build +++ b/build @@ -4,7 +4,7 @@ source ./scripts/test_lib.sh GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound") if [[ -n "$FAILPOINTS" ]]; then - GIT_SHA="$GIT_SHA"-FAILPOINTS + GIT_SHA="$GIT_SHA"-FAILPOINTS fi VERSION_SYMBOL="go.etcd.io/etcd/api/v3/version.GitSHA" @@ -16,107 +16,107 @@ GO_BUILD_ENV=("CGO_ENABLED=0" "GO_BUILD_FLAGS=${GO_BUILD_FLAGS}" "GOOS=${GOOS}" # enable/disable failpoints toggle_failpoints() { - mode="$1" - if command -v gofail >/dev/null 2>&1; then - run gofail "$mode" etcdserver/ mvcc/backend/ - elif [[ "$mode" != "disable" ]]; then - log_error "FAILPOINTS set but gofail not found" - exit 1 - fi + mode="$1" + if command -v gofail >/dev/null 2>&1; then + run gofail "$mode" etcdserver/ mvcc/backend/ + elif [[ "$mode" != "disable" ]]; then + log_error "FAILPOINTS set but gofail not found" + exit 1 + fi } toggle_failpoints_default() { - mode="disable" - if [[ -n "$FAILPOINTS" ]]; then mode="enable"; fi - toggle_failpoints "$mode" + mode="disable" + if [[ -n "$FAILPOINTS" ]]; then mode="enable"; fi + toggle_failpoints "$mode" } etcd_build() { - out="bin" - if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi - toggle_failpoints_default + out="bin" + if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi + toggle_failpoints_default - run rm -f "${out}/etcd" - # Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK - # shellcheck disable=SC2086 - run env "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \ - -installsuffix=cgo \ - "-ldflags=${GO_LDFLAGS[*]}" \ - -o="${out}/etcd" . || return 2 + run rm -f "${out}/etcd" + # Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK + # shellcheck disable=SC2086 + run env "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \ + -installsuffix=cgo \ + "-ldflags=${GO_LDFLAGS[*]}" \ + -o="${out}/etcd" . || return 2 - run rm -f "${out}/etcdctl" - # shellcheck disable=SC2086 - ( - cd ./etcdctl - run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build $GO_BUILD_FLAGS \ - -installsuffix=cgo \ - "-ldflags=${GO_LDFLAGS[*]}" \ - -o="../${out}/etcdctl" . || return 2 - ) || return 2 - # Verify whether symbol we overriden exists - # For cross-compiling we cannot run: ${out}/etcd --version | grep -q "Git SHA: ${GIT_SHA}" + run rm -f "${out}/etcdctl" + # shellcheck disable=SC2086 + ( + cd ./etcdctl + run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build $GO_BUILD_FLAGS \ + -installsuffix=cgo \ + "-ldflags=${GO_LDFLAGS[*]}" \ + -o="../${out}/etcdctl" . || return 2 + ) || return 2 + # Verify whether symbol we overriden exists + # For cross-compiling we cannot run: ${out}/etcd --version | grep -q "Git SHA: ${GIT_SHA}" - # We need symbols to do this check: - if [[ "${GO_LDFLAGS[*]}" != *"-s"* ]]; then - go tool nm "${out}/etcd" | grep "${VERSION_SYMBOL}" > /dev/null - if [[ "${PIPESTATUS[*]}" != "0 0" ]]; then - log_error "FAIL: Symbol ${VERSION_SYMBOL} not found in binary: ${out}/etcd" - return 2 - fi - fi + # We need symbols to do this check: + if [[ "${GO_LDFLAGS[*]}" != *"-s"* ]]; then + go tool nm "${out}/etcd" | grep "${VERSION_SYMBOL}" > /dev/null + if [[ "${PIPESTATUS[*]}" != "0 0" ]]; then + log_error "FAIL: Symbol ${VERSION_SYMBOL} not found in binary: ${out}/etcd" + return 2 + fi + fi } tools_build() { - out="bin" - if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi - tools_path="tools/benchmark - tools/etcd-dump-db - tools/etcd-dump-logs - tools/local-tester/bridge" - for tool in ${tools_path} - do - echo "Building" "'${tool}'"... - run rm -f "${out}/${tool}" - # shellcheck disable=SC2086 - run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \ - -installsuffix=cgo \ - "-ldflags='${GO_LDFLAGS[*]}'" \ - -o="${out}/${tool}" "./${tool}" || return 2 - done - tests_build "${@}" + out="bin" + if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi + tools_path="tools/benchmark + tools/etcd-dump-db + tools/etcd-dump-logs + tools/local-tester/bridge" + for tool in ${tools_path} + do + echo "Building" "'${tool}'"... + run rm -f "${out}/${tool}" + # shellcheck disable=SC2086 + run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \ + -installsuffix=cgo \ + "-ldflags='${GO_LDFLAGS[*]}'" \ + -o="${out}/${tool}" "./${tool}" || return 2 + done + tests_build "${@}" } tests_build() { - out="bin" - if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi - tools_path=" - functional/cmd/etcd-agent - functional/cmd/etcd-proxy - functional/cmd/etcd-runner - functional/cmd/etcd-tester" - ( - cd tests || exit 2 - for tool in ${tools_path}; do - echo "Building" "'${tool}'"... - run rm -f "../${out}/${tool}" + out="bin" + if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi + tools_path=" + functional/cmd/etcd-agent + functional/cmd/etcd-proxy + functional/cmd/etcd-runner + functional/cmd/etcd-tester" + ( + cd tests || exit 2 + for tool in ${tools_path}; do + echo "Building" "'${tool}'"... + run rm -f "../${out}/${tool}" - # shellcheck disable=SC2086 - run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build ${GO_BUILD_FLAGS} \ - -installsuffix=cgo \ - "-ldflags='${GO_LDFLAGS[*]}'" \ - -o="../${out}/${tool}" "./${tool}" || return 2 - done - ) || return 2 + # shellcheck disable=SC2086 + run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build ${GO_BUILD_FLAGS} \ + -installsuffix=cgo \ + "-ldflags='${GO_LDFLAGS[*]}'" \ + -o="../${out}/${tool}" "./${tool}" || return 2 + done + ) || return 2 } toggle_failpoints_default # only build when called directly, not sourced if echo "$0" | grep "build$" >/dev/null; then - if etcd_build; then - log_success "SUCCESS: etcd_build" - else - log_error "FAIL: etcd_build" - exit 2 + if etcd_build; then + log_success "SUCCESS: etcd_build" + else + log_error "FAIL: etcd_build" + exit 2 fi fi diff --git a/pkg/proxy/fixtures/gencerts.sh b/pkg/proxy/fixtures/gencerts.sh index fdf3a1086..50147b621 100755 --- a/pkg/proxy/fixtures/gencerts.sh +++ b/pkg/proxy/fixtures/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 2475e99cd..85a7eb3ab 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -7,8 +7,8 @@ set -e VERSION=$1 if [ -z "${VERSION}" ]; then - echo "Usage: ${0} VERSION" >> /dev/stderr - exit 255 + echo "Usage: ${0} VERSION" >> /dev/stderr + exit 255 fi if ! command -v docker >/dev/null; then @@ -19,11 +19,11 @@ fi ETCD_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. pushd "${ETCD_ROOT}" >/dev/null - echo Building etcd binary... - ./scripts/build-binary "${VERSION}" + echo Building etcd binary... + ./scripts/build-binary "${VERSION}" - for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do - echo Building ${TARGET_ARCH} docker image... - GOOS=linux GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker "${VERSION}" - done + for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do + echo Building ${TARGET_ARCH} docker image... + GOOS=linux GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker "${VERSION}" + done popd >/dev/null diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 308d91f0a..405c60dd9 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -6,15 +6,15 @@ set -e if ! [[ "$0" =~ scripts/genproto.sh ]]; then - echo "must be run from repository root" - exit 255 + echo "must be run from repository root" + exit 255 fi source ./scripts/test_lib.sh if [[ $(protoc --version | cut -f2 -d' ') != "3.12.3" ]]; then - echo "could not find protoc 3.12.3, is it installed + in PATH?" - exit 255 + echo "could not find protoc 3.12.3, is it installed + in PATH?" + exit 255 fi run env GO111MODULE=off go get -u github.com/myitcv/gobin @@ -41,16 +41,16 @@ GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf" log_callout -e "\nRunning gofast proto generation..." for dir in ${DIRS}; do - run pushd "${dir}" - run protoc --gofast_out=plugins=grpc:. -I=".:${GOGOPROTO_PATH}:${ETCD_ROOT_DIR}/..:${GRPC_GATEWAY_ROOT}/third_party/googleapis" \ - --plugin="${GOFAST_BIN}" ./*.proto + run pushd "${dir}" + run protoc --gofast_out=plugins=grpc:. -I=".:${GOGOPROTO_PATH}:${ETCD_ROOT_DIR}/..:${GRPC_GATEWAY_ROOT}/third_party/googleapis" \ + --plugin="${GOFAST_BIN}" ./*.proto - sed -i.bak -E 's|"etcd/api/|"go.etcd.io/etcd/api/v3/|g' ./*.pb.go + sed -i.bak -E 's|"etcd/api/|"go.etcd.io/etcd/api/v3/|g' ./*.pb.go - rm -f ./*.bak - run gofmt -s -w ./*.pb.go - run goimports -w ./*.pb.go - run popd + rm -f ./*.bak + run gofmt -s -w ./*.pb.go + run goimports -w ./*.pb.go + run popd done #return @@ -59,60 +59,60 @@ log_callout -e "\nRunning swagger & grpc_gateway proto generation..." # remove old swagger files so it's obvious whether the files fail to generate rm -rf Documentation/dev-guide/apispec/swagger/*json for pb in api/etcdserverpb/rpc etcdserver/api/v3lock/v3lockpb/v3lock etcdserver/api/v3election/v3electionpb/v3election; do - log_callout "grpc & swagger for: ${pb}.proto" - run protoc -I. \ - -I"${GRPC_GATEWAY_ROOT}"/third_party/googleapis \ - -I"${GOGOPROTO_PATH}" \ - -I"${ETCD_ROOT_DIR}/.." \ - --grpc-gateway_out=logtostderr=true,paths=source_relative:. \ - --swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \ - --plugin="${SWAGGER_BIN}" --plugin="${GRPC_GATEWAY_BIN}" \ - ${pb}.proto - # hack to move gw files around so client won't include them - pkgpath=$(dirname "${pb}") - pkg=$(basename "${pkgpath}") - gwfile="${pb}.pb.gw.go" + log_callout "grpc & swagger for: ${pb}.proto" + run protoc -I. \ + -I"${GRPC_GATEWAY_ROOT}"/third_party/googleapis \ + -I"${GOGOPROTO_PATH}" \ + -I"${ETCD_ROOT_DIR}/.." \ + --grpc-gateway_out=logtostderr=true,paths=source_relative:. \ + --swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \ + --plugin="${SWAGGER_BIN}" --plugin="${GRPC_GATEWAY_BIN}" \ + ${pb}.proto + # hack to move gw files around so client won't include them + pkgpath=$(dirname "${pb}") + pkg=$(basename "${pkgpath}") + gwfile="${pb}.pb.gw.go" - sed -i -E "s#package $pkg#package gw#g" "${gwfile}" - sed -i -E "s#import \(#import \(\"go.etcd.io/etcd/${pkgpath}\"#g" "${gwfile}" - sed -i -E "s#([ (])([a-zA-Z0-9_]*(Client|Server|Request)([^(]|$))#\1${pkg}.\2#g" "${gwfile}" - sed -i -E "s# (New[a-zA-Z0-9_]*Client\()# ${pkg}.\1#g" "${gwfile}" - sed -i -E "s|go.etcd.io/etcd|go.etcd.io/etcd/v3|g" "${gwfile}" - sed -i -E "s|go.etcd.io/etcd/v3/api|go.etcd.io/etcd/api/v3|g" "${gwfile}" - - run go fmt "${gwfile}" + sed -i -E "s#package $pkg#package gw#g" "${gwfile}" + sed -i -E "s#import \(#import \(\"go.etcd.io/etcd/${pkgpath}\"#g" "${gwfile}" + sed -i -E "s#([ (])([a-zA-Z0-9_]*(Client|Server|Request)([^(]|$))#\1${pkg}.\2#g" "${gwfile}" + sed -i -E "s# (New[a-zA-Z0-9_]*Client\()# ${pkg}.\1#g" "${gwfile}" + sed -i -E "s|go.etcd.io/etcd|go.etcd.io/etcd/v3|g" "${gwfile}" + sed -i -E "s|go.etcd.io/etcd/v3/api|go.etcd.io/etcd/api/v3|g" "${gwfile}" + + run go fmt "${gwfile}" - gwdir="${pkgpath}/gw/" - run mkdir -p "${gwdir}" - run mv "${gwfile}" "${gwdir}" + gwdir="${pkgpath}/gw/" + run mkdir -p "${gwdir}" + run mv "${gwfile}" "${gwdir}" - swaggerName=$(basename ${pb}) - run mv Documentation/dev-guide/apispec/swagger/${pb}.swagger.json \ - Documentation/dev-guide/apispec/swagger/"${swaggerName}".swagger.json + swaggerName=$(basename ${pb}) + run mv Documentation/dev-guide/apispec/swagger/${pb}.swagger.json \ + Documentation/dev-guide/apispec/swagger/"${swaggerName}".swagger.json done log_callout -e "\nRunning swagger ..." run_go_tool github.com/hexfusion/schwag -input=Documentation/dev-guide/apispec/swagger/rpc.swagger.json if [ "$1" != "--skip-protodoc" ]; then - log_callout "protodoc is auto-generating grpc API reference documentation..." + log_callout "protodoc is auto-generating grpc API reference documentation..." run rm -rf Documentation/dev-guide/api_reference_v3.md - run_go_tool go.etcd.io/protodoc --directories="api/etcdserverpb=service_message,api/mvccpb=service_message,lease/leasepb=service_message,api/authpb=service_message" \ - --title="etcd API Reference" \ - --output="Documentation/dev-guide/api_reference_v3.md" \ - --message-only-from-this-file="api/etcdserverpb/rpc.proto" \ - --disclaimer="This is a generated documentation. Please read the proto files for more." || exit 2 + run_go_tool go.etcd.io/protodoc --directories="api/etcdserverpb=service_message,api/mvccpb=service_message,lease/leasepb=service_message,api/authpb=service_message" \ + --title="etcd API Reference" \ + --output="Documentation/dev-guide/api_reference_v3.md" \ + --message-only-from-this-file="api/etcdserverpb/rpc.proto" \ + --disclaimer="This is a generated documentation. Please read the proto files for more." || exit 2 run rm -rf Documentation/dev-guide/api_concurrency_reference_v3.md - run_go_tool go.etcd.io/protodoc --directories="etcdserver/api/v3lock/v3lockpb=service_message,etcdserver/api/v3election/v3electionpb=service_message,api/mvccpb=service_message" \ - --title="etcd concurrency API Reference" \ - --output="Documentation/dev-guide/api_concurrency_reference_v3.md" \ - --disclaimer="This is a generated documentation. Please read the proto files for more." || exit 2 + run_go_tool go.etcd.io/protodoc --directories="etcdserver/api/v3lock/v3lockpb=service_message,etcdserver/api/v3election/v3electionpb=service_message,api/mvccpb=service_message" \ + --title="etcd concurrency API Reference" \ + --output="Documentation/dev-guide/api_concurrency_reference_v3.md" \ + --disclaimer="This is a generated documentation. Please read the proto files for more." || exit 2 - log_success "protodoc is finished." + log_success "protodoc is finished." else - log_warning "skipping grpc API reference document auto-generation..." + log_warning "skipping grpc API reference document auto-generation..." fi log_success -e "\n./genproto SUCCESS" diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 2387cbdb5..2884fc315 100644 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash if [[ "$(go list)" != "go.etcd.io/etcd/v3" ]]; then - echo "must be run from 'go.etcd.io/etcd/v3' module directory" - exit 255 + echo "must be run from 'go.etcd.io/etcd/v3' module directory" + exit 255 fi ETCD_ROOT_DIR=$(go list -f '{{.Dir}}' "go.etcd.io/etcd/v3") @@ -107,12 +107,12 @@ function run_for_module { function modules() { echo "go.etcd.io/etcd/api/v3 go.etcd.io/etcd/pkg/v3 - go.etcd.io/etcd/raft/v3 - go.etcd.io/etcd/client/v2 - go.etcd.io/etcd/client/v3 - go.etcd.io/etcd/v3 - go.etcd.io/etcd/etcdctl/v3 - go.etcd.io/etcd/tests/v3" + go.etcd.io/etcd/raft/v3 + go.etcd.io/etcd/client/v2 + go.etcd.io/etcd/client/v3 + go.etcd.io/etcd/v3 + go.etcd.io/etcd/etcdctl/v3 + go.etcd.io/etcd/tests/v3" } function modules_exp() { diff --git a/tests/docker-dns-srv/certs-gateway/gencerts.sh b/tests/docker-dns-srv/certs-gateway/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-dns-srv/certs-gateway/gencerts.sh +++ b/tests/docker-dns-srv/certs-gateway/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns-srv/certs-wildcard/gencerts.sh b/tests/docker-dns-srv/certs-wildcard/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-dns-srv/certs-wildcard/gencerts.sh +++ b/tests/docker-dns-srv/certs-wildcard/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns-srv/certs/gencerts.sh b/tests/docker-dns-srv/certs/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-dns-srv/certs/gencerts.sh +++ b/tests/docker-dns-srv/certs/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns/certs-common-name-auth/gencerts.sh b/tests/docker-dns/certs-common-name-auth/gencerts.sh index 7fcfea569..09819cf22 100755 --- a/tests/docker-dns/certs-common-name-auth/gencerts.sh +++ b/tests/docker-dns/certs-common-name-auth/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns/certs-common-name-multi/gencerts.sh b/tests/docker-dns/certs-common-name-multi/gencerts.sh index 0ddc31e58..b2318fd08 100755 --- a/tests/docker-dns/certs-common-name-multi/gencerts.sh +++ b/tests/docker-dns/certs-common-name-multi/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns/certs-gateway/gencerts.sh b/tests/docker-dns/certs-gateway/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-dns/certs-gateway/gencerts.sh +++ b/tests/docker-dns/certs-gateway/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns/certs-san-dns/gencerts.sh b/tests/docker-dns/certs-san-dns/gencerts.sh index 0ddc31e58..b2318fd08 100755 --- a/tests/docker-dns/certs-san-dns/gencerts.sh +++ b/tests/docker-dns/certs-san-dns/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns/certs-wildcard/gencerts.sh b/tests/docker-dns/certs-wildcard/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-dns/certs-wildcard/gencerts.sh +++ b/tests/docker-dns/certs-wildcard/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-dns/certs/gencerts.sh b/tests/docker-dns/certs/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-dns/certs/gencerts.sh +++ b/tests/docker-dns/certs/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-static-ip/certs-metrics-proxy/gencerts.sh b/tests/docker-static-ip/certs-metrics-proxy/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-static-ip/certs-metrics-proxy/gencerts.sh +++ b/tests/docker-static-ip/certs-metrics-proxy/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tests/docker-static-ip/certs/gencerts.sh b/tests/docker-static-ip/certs/gencerts.sh index efc098f53..af8663e09 100755 --- a/tests/docker-static-ip/certs/gencerts.sh +++ b/tests/docker-static-ip/certs/gencerts.sh @@ -1,13 +1,13 @@ #!/bin/bash if ! [[ "$0" =~ "./gencerts.sh" ]]; then - echo "must be run from 'fixtures'" - exit 255 + echo "must be run from 'fixtures'" + exit 255 fi if ! which cfssl; then - echo "cfssl is not installed" - exit 255 + echo "cfssl is not installed" + exit 255 fi cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca diff --git a/tools/etcd-dump-logs/testdecoder/decoder_correctoutputformat.sh b/tools/etcd-dump-logs/testdecoder/decoder_correctoutputformat.sh index 524c28b51..9e31c1b9c 100755 --- a/tools/etcd-dump-logs/testdecoder/decoder_correctoutputformat.sh +++ b/tools/etcd-dump-logs/testdecoder/decoder_correctoutputformat.sh @@ -3,8 +3,8 @@ while read line do LEN=$(echo ${#line}) if [ $LEN -ge 20 ]; then - echo "OK|$line" | tr 1234567890 abcdefghij + echo "OK|$line" | tr 1234567890 abcdefghij else - echo "ERROR|$line" | tr 1234567890 abcdefghij + echo "ERROR|$line" | tr 1234567890 abcdefghij fi done < "${1:-/dev/stdin}" diff --git a/tools/local-tester/bridge.sh b/tools/local-tester/bridge.sh index 3c2b5cb3f..4d2e5f169 100755 --- a/tools/local-tester/bridge.sh +++ b/tools/local-tester/bridge.sh @@ -1,16 +1,16 @@ #!/bin/sh exec tools/local-tester/bridge/bridge \ - -delay-accept \ - -reset-listen \ - -conn-fault-rate=0.25 \ - -immediate-close \ - -blackhole \ - -time-close \ - -write-remote-only \ - -read-remote-only \ - -random-blackhole \ - -corrupt-receive \ - -corrupt-send \ - -reorder \ - $@ + -delay-accept \ + -reset-listen \ + -conn-fault-rate=0.25 \ + -immediate-close \ + -blackhole \ + -time-close \ + -write-remote-only \ + -read-remote-only \ + -random-blackhole \ + -corrupt-receive \ + -corrupt-send \ + -reorder \ + $@ diff --git a/tools/local-tester/faults.sh b/tools/local-tester/faults.sh index 1349f5923..fc6d910b8 100755 --- a/tools/local-tester/faults.sh +++ b/tools/local-tester/faults.sh @@ -4,88 +4,88 @@ PROCFILE="tools/local-tester/Procfile" HTTPFAIL=(127.0.0.1:11180 127.0.0.1:22280 127.0.0.1:33380) function wait_time { - expr $RANDOM % 10 + 1 + expr $RANDOM % 10 + 1 } function cycle { - for a; do - echo "cycling $a" - goreman -f $PROCFILE run stop $a || echo "could not stop $a" - sleep `wait_time`s - goreman -f $PROCFILE run restart $a || echo "could not restart $a" - done + for a; do + echo "cycling $a" + goreman -f $PROCFILE run stop $a || echo "could not stop $a" + sleep `wait_time`s + goreman -f $PROCFILE run restart $a || echo "could not restart $a" + done } function cycle_members { - cycle etcd1 etcd2 etcd3 + cycle etcd1 etcd2 etcd3 } function cycle_pbridge { - cycle pbridge1 pbridge2 pbridge3 + cycle pbridge1 pbridge2 pbridge3 } function cycle_cbridge { - cycle cbridge1 cbridge2 cbridge3 + cycle cbridge1 cbridge2 cbridge3 } function cycle_stresser { - cycle stress-put + cycle stress-put } function kill_maj { - idx="etcd"`expr $RANDOM % 3 + 1` - idx2="$idx" - while [ "$idx" == "$idx2" ]; do - idx2="etcd"`expr $RANDOM % 3 + 1` - done - echo "kill majority $idx $idx2" - goreman -f $PROCFILE run stop $idx || echo "could not stop $idx" - goreman -f $PROCFILE run stop $idx2 || echo "could not stop $idx2" - sleep `wait_time`s - goreman -f $PROCFILE run restart $idx || echo "could not restart $idx" - goreman -f $PROCFILE run restart $idx2 || echo "could not restart $idx2" + idx="etcd"`expr $RANDOM % 3 + 1` + idx2="$idx" + while [ "$idx" == "$idx2" ]; do + idx2="etcd"`expr $RANDOM % 3 + 1` + done + echo "kill majority $idx $idx2" + goreman -f $PROCFILE run stop $idx || echo "could not stop $idx" + goreman -f $PROCFILE run stop $idx2 || echo "could not stop $idx2" + sleep `wait_time`s + goreman -f $PROCFILE run restart $idx || echo "could not restart $idx" + goreman -f $PROCFILE run restart $idx2 || echo "could not restart $idx2" } function kill_all { - for a in etcd1 etcd2 etcd3; do - goreman -f $PROCFILE run stop $a || echo "could not stop $a" - done - sleep `wait_time`s - for a in etcd1 etcd2 etcd3; do - goreman -f $PROCFILE run restart $a || echo "could not restart $a" - done + for a in etcd1 etcd2 etcd3; do + goreman -f $PROCFILE run stop $a || echo "could not stop $a" + done + sleep `wait_time`s + for a in etcd1 etcd2 etcd3; do + goreman -f $PROCFILE run restart $a || echo "could not restart $a" + done } function rand_fp { - echo "$FAILPOINTS" | sed `expr $RANDOM % $NUMFPS + 1`"q;d" + echo "$FAILPOINTS" | sed `expr $RANDOM % $NUMFPS + 1`"q;d" } # fp_activate function fp_activate { - curl "$1"/"$2" -XPUT -d "$3" >/dev/null 2>&1 + curl "$1"/"$2" -XPUT -d "$3" >/dev/null 2>&1 } function fp_rand_single { - fp=`rand_fp` - fp_activate ${HTTPFAIL[`expr $RANDOM % ${#HTTPFAIL[@]}`]} $fp 'panic("'$fp'")' - sleep `wait_time`s + fp=`rand_fp` + fp_activate ${HTTPFAIL[`expr $RANDOM % ${#HTTPFAIL[@]}`]} $fp 'panic("'$fp'")' + sleep `wait_time`s } function fp_rand_all { - fp=`rand_fp` - for a in `seq ${#HTTPFAIL[@]}`; do fp_activate ${HTTPFAIL[$a]} "$fp" 'panic("'$fp'")'; done - sleep `wait_time`s + fp=`rand_fp` + for a in `seq ${#HTTPFAIL[@]}`; do fp_activate ${HTTPFAIL[$a]} "$fp" 'panic("'$fp'")'; done + sleep `wait_time`s } function fp_all_rand_fire { - for fp in $FAILPOINTS; do - for url in "${HTTPFAIL[@]}"; do - fp_activate "$url" "$fp" '0.5%panic("0.5%'$fp'")' - done - done + for fp in $FAILPOINTS; do + for url in "${HTTPFAIL[@]}"; do + fp_activate "$url" "$fp" '0.5%panic("0.5%'$fp'")' + done + done } function choose { - fault=${FAULTS[`expr $RANDOM % ${#FAULTS[@]}`]} - echo $fault - $fault || echo "failed: $fault" + fault=${FAULTS[`expr $RANDOM % ${#FAULTS[@]}`]} + echo $fault + $fault || echo "failed: $fault" } sleep 2s @@ -96,13 +96,13 @@ FAULTS=(cycle_members kill_maj kill_all cycle_pbridge cycle_cbridge cycle_stress FAILPOINTS=`curl http://"${HTTPFAIL[0]}" 2>/dev/null | cut -f1 -d'=' | grep -v "^$"` NUMFPS=`echo $(echo "$FAILPOINTS" | wc -l)` if [ "$NUMFPS" != "0" ]; then - FAULTS+=(fp_rand_single) - FAULTS+=(fp_rand_all) + FAULTS+=(fp_rand_single) + FAULTS+=(fp_rand_all) fi while [ 1 ]; do - choose - # start any nodes that have been killed by failpoints - for a in etcd1 etcd2 etcd3; do goreman -f $PROCFILE run start $a; done - fp_all_rand_fire + choose + # start any nodes that have been killed by failpoints + for a in etcd1 etcd2 etcd3; do goreman -f $PROCFILE run start $a; done + fp_all_rand_fire done