*: Convert tabulators to whitespaces in bash scripts.

Execution of `./scripts/fix.sh` that executed:
```
find ./ -name '*.sh' | xargs sed --follow-symlinks -i 's|\t|  |g'
```
This commit is contained in:
Piotr Tabor 2020-10-26 10:42:25 +01:00
parent c035df5317
commit 0ba16d8ee1
19 changed files with 262 additions and 262 deletions

162
build
View File

@ -4,7 +4,7 @@ source ./scripts/test_lib.sh
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound") GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
if [[ -n "$FAILPOINTS" ]]; then if [[ -n "$FAILPOINTS" ]]; then
GIT_SHA="$GIT_SHA"-FAILPOINTS GIT_SHA="$GIT_SHA"-FAILPOINTS
fi fi
VERSION_SYMBOL="go.etcd.io/etcd/api/v3/version.GitSHA" 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 # enable/disable failpoints
toggle_failpoints() { toggle_failpoints() {
mode="$1" mode="$1"
if command -v gofail >/dev/null 2>&1; then if command -v gofail >/dev/null 2>&1; then
run gofail "$mode" etcdserver/ mvcc/backend/ run gofail "$mode" etcdserver/ mvcc/backend/
elif [[ "$mode" != "disable" ]]; then elif [[ "$mode" != "disable" ]]; then
log_error "FAILPOINTS set but gofail not found" log_error "FAILPOINTS set but gofail not found"
exit 1 exit 1
fi fi
} }
toggle_failpoints_default() { toggle_failpoints_default() {
mode="disable" mode="disable"
if [[ -n "$FAILPOINTS" ]]; then mode="enable"; fi if [[ -n "$FAILPOINTS" ]]; then mode="enable"; fi
toggle_failpoints "$mode" toggle_failpoints "$mode"
} }
etcd_build() { etcd_build() {
out="bin" out="bin"
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
toggle_failpoints_default toggle_failpoints_default
run rm -f "${out}/etcd" run rm -f "${out}/etcd"
# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK # Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
# shellcheck disable=SC2086 # shellcheck disable=SC2086
run env "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \ run env "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \
-installsuffix=cgo \ -installsuffix=cgo \
"-ldflags=${GO_LDFLAGS[*]}" \ "-ldflags=${GO_LDFLAGS[*]}" \
-o="${out}/etcd" . || return 2 -o="${out}/etcd" . || return 2
run rm -f "${out}/etcdctl" run rm -f "${out}/etcdctl"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
( (
cd ./etcdctl cd ./etcdctl
run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build $GO_BUILD_FLAGS \ run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build $GO_BUILD_FLAGS \
-installsuffix=cgo \ -installsuffix=cgo \
"-ldflags=${GO_LDFLAGS[*]}" \ "-ldflags=${GO_LDFLAGS[*]}" \
-o="../${out}/etcdctl" . || return 2 -o="../${out}/etcdctl" . || return 2
) || return 2 ) || return 2
# Verify whether symbol we overriden exists # Verify whether symbol we overriden exists
# For cross-compiling we cannot run: ${out}/etcd --version | grep -q "Git SHA: ${GIT_SHA}" # For cross-compiling we cannot run: ${out}/etcd --version | grep -q "Git SHA: ${GIT_SHA}"
# We need symbols to do this check: # We need symbols to do this check:
if [[ "${GO_LDFLAGS[*]}" != *"-s"* ]]; then if [[ "${GO_LDFLAGS[*]}" != *"-s"* ]]; then
go tool nm "${out}/etcd" | grep "${VERSION_SYMBOL}" > /dev/null go tool nm "${out}/etcd" | grep "${VERSION_SYMBOL}" > /dev/null
if [[ "${PIPESTATUS[*]}" != "0 0" ]]; then if [[ "${PIPESTATUS[*]}" != "0 0" ]]; then
log_error "FAIL: Symbol ${VERSION_SYMBOL} not found in binary: ${out}/etcd" log_error "FAIL: Symbol ${VERSION_SYMBOL} not found in binary: ${out}/etcd"
return 2 return 2
fi fi
fi fi
} }
tools_build() { tools_build() {
out="bin" out="bin"
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
tools_path="tools/benchmark tools_path="tools/benchmark
tools/etcd-dump-db tools/etcd-dump-db
tools/etcd-dump-logs tools/etcd-dump-logs
tools/local-tester/bridge" tools/local-tester/bridge"
for tool in ${tools_path} for tool in ${tools_path}
do do
echo "Building" "'${tool}'"... echo "Building" "'${tool}'"...
run rm -f "${out}/${tool}" run rm -f "${out}/${tool}"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \ run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \
-installsuffix=cgo \ -installsuffix=cgo \
"-ldflags='${GO_LDFLAGS[*]}'" \ "-ldflags='${GO_LDFLAGS[*]}'" \
-o="${out}/${tool}" "./${tool}" || return 2 -o="${out}/${tool}" "./${tool}" || return 2
done done
tests_build "${@}" tests_build "${@}"
} }
tests_build() { tests_build() {
out="bin" out="bin"
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
tools_path=" tools_path="
functional/cmd/etcd-agent functional/cmd/etcd-agent
functional/cmd/etcd-proxy functional/cmd/etcd-proxy
functional/cmd/etcd-runner functional/cmd/etcd-runner
functional/cmd/etcd-tester" functional/cmd/etcd-tester"
( (
cd tests || exit 2 cd tests || exit 2
for tool in ${tools_path}; do for tool in ${tools_path}; do
echo "Building" "'${tool}'"... echo "Building" "'${tool}'"...
run rm -f "../${out}/${tool}" run rm -f "../${out}/${tool}"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build ${GO_BUILD_FLAGS} \ run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build ${GO_BUILD_FLAGS} \
-installsuffix=cgo \ -installsuffix=cgo \
"-ldflags='${GO_LDFLAGS[*]}'" \ "-ldflags='${GO_LDFLAGS[*]}'" \
-o="../${out}/${tool}" "./${tool}" || return 2 -o="../${out}/${tool}" "./${tool}" || return 2
done done
) || return 2 ) || return 2
} }
toggle_failpoints_default toggle_failpoints_default
# only build when called directly, not sourced # only build when called directly, not sourced
if echo "$0" | grep "build$" >/dev/null; then if echo "$0" | grep "build$" >/dev/null; then
if etcd_build; then if etcd_build; then
log_success "SUCCESS: etcd_build" log_success "SUCCESS: etcd_build"
else else
log_error "FAIL: etcd_build" log_error "FAIL: etcd_build"
exit 2 exit 2
fi fi
fi fi

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -7,8 +7,8 @@ set -e
VERSION=$1 VERSION=$1
if [ -z "${VERSION}" ]; then if [ -z "${VERSION}" ]; then
echo "Usage: ${0} VERSION" >> /dev/stderr echo "Usage: ${0} VERSION" >> /dev/stderr
exit 255 exit 255
fi fi
if ! command -v docker >/dev/null; then if ! command -v docker >/dev/null; then
@ -19,11 +19,11 @@ fi
ETCD_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. ETCD_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
pushd "${ETCD_ROOT}" >/dev/null pushd "${ETCD_ROOT}" >/dev/null
echo Building etcd binary... echo Building etcd binary...
./scripts/build-binary "${VERSION}" ./scripts/build-binary "${VERSION}"
for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do
echo Building ${TARGET_ARCH} docker image... echo Building ${TARGET_ARCH} docker image...
GOOS=linux GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker "${VERSION}" GOOS=linux GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker "${VERSION}"
done done
popd >/dev/null popd >/dev/null

View File

@ -6,15 +6,15 @@
set -e set -e
if ! [[ "$0" =~ scripts/genproto.sh ]]; then if ! [[ "$0" =~ scripts/genproto.sh ]]; then
echo "must be run from repository root" echo "must be run from repository root"
exit 255 exit 255
fi fi
source ./scripts/test_lib.sh source ./scripts/test_lib.sh
if [[ $(protoc --version | cut -f2 -d' ') != "3.12.3" ]]; then if [[ $(protoc --version | cut -f2 -d' ') != "3.12.3" ]]; then
echo "could not find protoc 3.12.3, is it installed + in PATH?" echo "could not find protoc 3.12.3, is it installed + in PATH?"
exit 255 exit 255
fi fi
run env GO111MODULE=off go get -u github.com/myitcv/gobin 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..." log_callout -e "\nRunning gofast proto generation..."
for dir in ${DIRS}; do for dir in ${DIRS}; do
run pushd "${dir}" run pushd "${dir}"
run protoc --gofast_out=plugins=grpc:. -I=".:${GOGOPROTO_PATH}:${ETCD_ROOT_DIR}/..:${GRPC_GATEWAY_ROOT}/third_party/googleapis" \ run protoc --gofast_out=plugins=grpc:. -I=".:${GOGOPROTO_PATH}:${ETCD_ROOT_DIR}/..:${GRPC_GATEWAY_ROOT}/third_party/googleapis" \
--plugin="${GOFAST_BIN}" ./*.proto --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 rm -f ./*.bak
run gofmt -s -w ./*.pb.go run gofmt -s -w ./*.pb.go
run goimports -w ./*.pb.go run goimports -w ./*.pb.go
run popd run popd
done done
#return #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 # remove old swagger files so it's obvious whether the files fail to generate
rm -rf Documentation/dev-guide/apispec/swagger/*json 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 for pb in api/etcdserverpb/rpc etcdserver/api/v3lock/v3lockpb/v3lock etcdserver/api/v3election/v3electionpb/v3election; do
log_callout "grpc & swagger for: ${pb}.proto" log_callout "grpc & swagger for: ${pb}.proto"
run protoc -I. \ run protoc -I. \
-I"${GRPC_GATEWAY_ROOT}"/third_party/googleapis \ -I"${GRPC_GATEWAY_ROOT}"/third_party/googleapis \
-I"${GOGOPROTO_PATH}" \ -I"${GOGOPROTO_PATH}" \
-I"${ETCD_ROOT_DIR}/.." \ -I"${ETCD_ROOT_DIR}/.." \
--grpc-gateway_out=logtostderr=true,paths=source_relative:. \ --grpc-gateway_out=logtostderr=true,paths=source_relative:. \
--swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \ --swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \
--plugin="${SWAGGER_BIN}" --plugin="${GRPC_GATEWAY_BIN}" \ --plugin="${SWAGGER_BIN}" --plugin="${GRPC_GATEWAY_BIN}" \
${pb}.proto ${pb}.proto
# hack to move gw files around so client won't include them # hack to move gw files around so client won't include them
pkgpath=$(dirname "${pb}") pkgpath=$(dirname "${pb}")
pkg=$(basename "${pkgpath}") pkg=$(basename "${pkgpath}")
gwfile="${pb}.pb.gw.go" gwfile="${pb}.pb.gw.go"
sed -i -E "s#package $pkg#package gw#g" "${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#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#([ (])([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# (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|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}" sed -i -E "s|go.etcd.io/etcd/v3/api|go.etcd.io/etcd/api/v3|g" "${gwfile}"
run go fmt "${gwfile}" run go fmt "${gwfile}"
gwdir="${pkgpath}/gw/" gwdir="${pkgpath}/gw/"
run mkdir -p "${gwdir}" run mkdir -p "${gwdir}"
run mv "${gwfile}" "${gwdir}" run mv "${gwfile}" "${gwdir}"
swaggerName=$(basename ${pb}) swaggerName=$(basename ${pb})
run mv Documentation/dev-guide/apispec/swagger/${pb}.swagger.json \ run mv Documentation/dev-guide/apispec/swagger/${pb}.swagger.json \
Documentation/dev-guide/apispec/swagger/"${swaggerName}".swagger.json Documentation/dev-guide/apispec/swagger/"${swaggerName}".swagger.json
done done
log_callout -e "\nRunning swagger ..." log_callout -e "\nRunning swagger ..."
run_go_tool github.com/hexfusion/schwag -input=Documentation/dev-guide/apispec/swagger/rpc.swagger.json run_go_tool github.com/hexfusion/schwag -input=Documentation/dev-guide/apispec/swagger/rpc.swagger.json
if [ "$1" != "--skip-protodoc" ]; then 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 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" \ 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" \ --title="etcd API Reference" \
--output="Documentation/dev-guide/api_reference_v3.md" \ --output="Documentation/dev-guide/api_reference_v3.md" \
--message-only-from-this-file="api/etcdserverpb/rpc.proto" \ --message-only-from-this-file="api/etcdserverpb/rpc.proto" \
--disclaimer="This is a generated documentation. Please read the proto files for more." || exit 2 --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 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" \ 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" \ --title="etcd concurrency API Reference" \
--output="Documentation/dev-guide/api_concurrency_reference_v3.md" \ --output="Documentation/dev-guide/api_concurrency_reference_v3.md" \
--disclaimer="This is a generated documentation. Please read the proto files for more." || exit 2 --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 else
log_warning "skipping grpc API reference document auto-generation..." log_warning "skipping grpc API reference document auto-generation..."
fi fi
log_success -e "\n./genproto SUCCESS" log_success -e "\n./genproto SUCCESS"

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [[ "$(go list)" != "go.etcd.io/etcd/v3" ]]; then if [[ "$(go list)" != "go.etcd.io/etcd/v3" ]]; then
echo "must be run from 'go.etcd.io/etcd/v3' module directory" echo "must be run from 'go.etcd.io/etcd/v3' module directory"
exit 255 exit 255
fi fi
ETCD_ROOT_DIR=$(go list -f '{{.Dir}}' "go.etcd.io/etcd/v3") ETCD_ROOT_DIR=$(go list -f '{{.Dir}}' "go.etcd.io/etcd/v3")
@ -107,12 +107,12 @@ function run_for_module {
function modules() { function modules() {
echo "go.etcd.io/etcd/api/v3 echo "go.etcd.io/etcd/api/v3
go.etcd.io/etcd/pkg/v3 go.etcd.io/etcd/pkg/v3
go.etcd.io/etcd/raft/v3 go.etcd.io/etcd/raft/v3
go.etcd.io/etcd/client/v2 go.etcd.io/etcd/client/v2
go.etcd.io/etcd/client/v3 go.etcd.io/etcd/client/v3
go.etcd.io/etcd/v3 go.etcd.io/etcd/v3
go.etcd.io/etcd/etcdctl/v3 go.etcd.io/etcd/etcdctl/v3
go.etcd.io/etcd/tests/v3" go.etcd.io/etcd/tests/v3"
} }
function modules_exp() { function modules_exp() {

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if ! [[ "$0" =~ "./gencerts.sh" ]]; then if ! [[ "$0" =~ "./gencerts.sh" ]]; then
echo "must be run from 'fixtures'" echo "must be run from 'fixtures'"
exit 255 exit 255
fi fi
if ! which cfssl; then if ! which cfssl; then
echo "cfssl is not installed" echo "cfssl is not installed"
exit 255 exit 255
fi fi
cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca

View File

@ -3,8 +3,8 @@ while read line
do do
LEN=$(echo ${#line}) LEN=$(echo ${#line})
if [ $LEN -ge 20 ]; then if [ $LEN -ge 20 ]; then
echo "OK|$line" | tr 1234567890 abcdefghij echo "OK|$line" | tr 1234567890 abcdefghij
else else
echo "ERROR|$line" | tr 1234567890 abcdefghij echo "ERROR|$line" | tr 1234567890 abcdefghij
fi fi
done < "${1:-/dev/stdin}" done < "${1:-/dev/stdin}"

View File

@ -1,16 +1,16 @@
#!/bin/sh #!/bin/sh
exec tools/local-tester/bridge/bridge \ exec tools/local-tester/bridge/bridge \
-delay-accept \ -delay-accept \
-reset-listen \ -reset-listen \
-conn-fault-rate=0.25 \ -conn-fault-rate=0.25 \
-immediate-close \ -immediate-close \
-blackhole \ -blackhole \
-time-close \ -time-close \
-write-remote-only \ -write-remote-only \
-read-remote-only \ -read-remote-only \
-random-blackhole \ -random-blackhole \
-corrupt-receive \ -corrupt-receive \
-corrupt-send \ -corrupt-send \
-reorder \ -reorder \
$@ $@

View File

@ -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) HTTPFAIL=(127.0.0.1:11180 127.0.0.1:22280 127.0.0.1:33380)
function wait_time { function wait_time {
expr $RANDOM % 10 + 1 expr $RANDOM % 10 + 1
} }
function cycle { function cycle {
for a; do for a; do
echo "cycling $a" echo "cycling $a"
goreman -f $PROCFILE run stop $a || echo "could not stop $a" goreman -f $PROCFILE run stop $a || echo "could not stop $a"
sleep `wait_time`s sleep `wait_time`s
goreman -f $PROCFILE run restart $a || echo "could not restart $a" goreman -f $PROCFILE run restart $a || echo "could not restart $a"
done done
} }
function cycle_members { function cycle_members {
cycle etcd1 etcd2 etcd3 cycle etcd1 etcd2 etcd3
} }
function cycle_pbridge { function cycle_pbridge {
cycle pbridge1 pbridge2 pbridge3 cycle pbridge1 pbridge2 pbridge3
} }
function cycle_cbridge { function cycle_cbridge {
cycle cbridge1 cbridge2 cbridge3 cycle cbridge1 cbridge2 cbridge3
} }
function cycle_stresser { function cycle_stresser {
cycle stress-put cycle stress-put
} }
function kill_maj { function kill_maj {
idx="etcd"`expr $RANDOM % 3 + 1` idx="etcd"`expr $RANDOM % 3 + 1`
idx2="$idx" idx2="$idx"
while [ "$idx" == "$idx2" ]; do while [ "$idx" == "$idx2" ]; do
idx2="etcd"`expr $RANDOM % 3 + 1` idx2="etcd"`expr $RANDOM % 3 + 1`
done done
echo "kill majority $idx $idx2" echo "kill majority $idx $idx2"
goreman -f $PROCFILE run stop $idx || echo "could not stop $idx" goreman -f $PROCFILE run stop $idx || echo "could not stop $idx"
goreman -f $PROCFILE run stop $idx2 || echo "could not stop $idx2" goreman -f $PROCFILE run stop $idx2 || echo "could not stop $idx2"
sleep `wait_time`s sleep `wait_time`s
goreman -f $PROCFILE run restart $idx || echo "could not restart $idx" goreman -f $PROCFILE run restart $idx || echo "could not restart $idx"
goreman -f $PROCFILE run restart $idx2 || echo "could not restart $idx2" goreman -f $PROCFILE run restart $idx2 || echo "could not restart $idx2"
} }
function kill_all { function kill_all {
for a in etcd1 etcd2 etcd3; do for a in etcd1 etcd2 etcd3; do
goreman -f $PROCFILE run stop $a || echo "could not stop $a" goreman -f $PROCFILE run stop $a || echo "could not stop $a"
done done
sleep `wait_time`s sleep `wait_time`s
for a in etcd1 etcd2 etcd3; do for a in etcd1 etcd2 etcd3; do
goreman -f $PROCFILE run restart $a || echo "could not restart $a" goreman -f $PROCFILE run restart $a || echo "could not restart $a"
done done
} }
function rand_fp { function rand_fp {
echo "$FAILPOINTS" | sed `expr $RANDOM % $NUMFPS + 1`"q;d" echo "$FAILPOINTS" | sed `expr $RANDOM % $NUMFPS + 1`"q;d"
} }
# fp_activate <http> <fppath> <value> # fp_activate <http> <fppath> <value>
function 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 { function fp_rand_single {
fp=`rand_fp` fp=`rand_fp`
fp_activate ${HTTPFAIL[`expr $RANDOM % ${#HTTPFAIL[@]}`]} $fp 'panic("'$fp'")' fp_activate ${HTTPFAIL[`expr $RANDOM % ${#HTTPFAIL[@]}`]} $fp 'panic("'$fp'")'
sleep `wait_time`s sleep `wait_time`s
} }
function fp_rand_all { function fp_rand_all {
fp=`rand_fp` fp=`rand_fp`
for a in `seq ${#HTTPFAIL[@]}`; do fp_activate ${HTTPFAIL[$a]} "$fp" 'panic("'$fp'")'; done for a in `seq ${#HTTPFAIL[@]}`; do fp_activate ${HTTPFAIL[$a]} "$fp" 'panic("'$fp'")'; done
sleep `wait_time`s sleep `wait_time`s
} }
function fp_all_rand_fire { function fp_all_rand_fire {
for fp in $FAILPOINTS; do for fp in $FAILPOINTS; do
for url in "${HTTPFAIL[@]}"; do for url in "${HTTPFAIL[@]}"; do
fp_activate "$url" "$fp" '0.5%panic("0.5%'$fp'")' fp_activate "$url" "$fp" '0.5%panic("0.5%'$fp'")'
done done
done done
} }
function choose { function choose {
fault=${FAULTS[`expr $RANDOM % ${#FAULTS[@]}`]} fault=${FAULTS[`expr $RANDOM % ${#FAULTS[@]}`]}
echo $fault echo $fault
$fault || echo "failed: $fault" $fault || echo "failed: $fault"
} }
sleep 2s 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 "^$"` FAILPOINTS=`curl http://"${HTTPFAIL[0]}" 2>/dev/null | cut -f1 -d'=' | grep -v "^$"`
NUMFPS=`echo $(echo "$FAILPOINTS" | wc -l)` NUMFPS=`echo $(echo "$FAILPOINTS" | wc -l)`
if [ "$NUMFPS" != "0" ]; then if [ "$NUMFPS" != "0" ]; then
FAULTS+=(fp_rand_single) FAULTS+=(fp_rand_single)
FAULTS+=(fp_rand_all) FAULTS+=(fp_rand_all)
fi fi
while [ 1 ]; do while [ 1 ]; do
choose choose
# start any nodes that have been killed by failpoints # start any nodes that have been killed by failpoints
for a in etcd1 etcd2 etcd3; do goreman -f $PROCFILE run start $a; done for a in etcd1 etcd2 etcd3; do goreman -f $PROCFILE run start $a; done
fp_all_rand_fire fp_all_rand_fire
done done