Merge pull request #13649 from serathius/scripts

Cleanup scripts in root directory
This commit is contained in:
Sahdev Zala 2022-02-11 15:40:53 -05:00 committed by GitHub
commit bba3937f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 58 additions and 63 deletions

View File

@ -27,31 +27,31 @@ jobs:
echo "${TARGET}"
case "${TARGET}" in
linux-amd64)
ARCH=amd64 PASSES='build' ./test.sh
ARCH=amd64 PASSES='build' ./scripts/test.sh
;;
linux-386)
ARCH=386 PASSES='build' ./test.sh
ARCH=386 PASSES='build' ./scripts/test.sh
;;
darwin-amd64)
ARCH=amd64 GOOS=darwin GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=amd64 GOOS=darwin GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
darwin-arm64)
ARCH=arm64 GOOS=darwin GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=arm64 GOOS=darwin GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
windows-amd64)
ARCH=amd64 GOOS=windows GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=amd64 GOOS=windows GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
linux-arm)
ARCH=arm GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=arm GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
linux-arm64)
ARCH=arm64 GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=arm64 GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
linux-ppc64le)
ARCH=ppc64le GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=ppc64le GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
linux-s390x)
ARCH=s390x GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh
ARCH=s390x GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh
;;
*)
echo "Failed to find target"

View File

@ -21,11 +21,11 @@ jobs:
echo "${TARGET}"
case "${TARGET}" in
linux-amd64-e2e)
PASSES='build release e2e' MANUAL_VER=v3.5.0 CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
PASSES='build release e2e' MANUAL_VER=v3.5.0 CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./scripts/test.sh 2>&1 | tee test.log
! egrep "(--- FAIL:|FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
;;
linux-386-e2e)
GOARCH=386 PASSES='build e2e' CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
GOARCH=386 PASSES='build e2e' CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./scripts/test.sh 2>&1 | tee test.log
! egrep "(--- FAIL:|FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
;;
*)

View File

@ -20,7 +20,7 @@ jobs:
echo "${TARGET}"
case "${TARGET}" in
linux-amd64-functional)
GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh && GOARCH=amd64 PASSES='functional' ./test.sh
GO_BUILD_FLAGS='-v -mod=readonly' ./scripts/build.sh && GOARCH=amd64 PASSES='functional' ./scripts/test.sh
;;
*)
echo "Failed to find target"

View File

@ -21,11 +21,11 @@ jobs:
echo "${TARGET}"
case "${TARGET}" in
linux-amd64-grpcproxy-integration)
PASSES='build grpcproxy_integration' CPU='4' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
PASSES='build grpcproxy_integration' CPU='4' COVER='false' RACE='true' ./scripts/test.sh 2>&1 | tee test.log
! egrep "(--- FAIL:|FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
;;
linux-amd64-grpcproxy-e2e)
PASSES='build grpcproxy_e2e' CPU='4' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
PASSES='build grpcproxy_e2e' CPU='4' COVER='false' RACE='true' ./scripts/test.sh 2>&1 | tee test.log
! egrep "(--- FAIL:|FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
;;
*)

View File

@ -20,7 +20,7 @@ jobs:
echo "${TARGET}"
case "${TARGET}" in
linux-amd64-fmt)
GOARCH=amd64 PASSES='fmt bom dep' ./test.sh
GOARCH=amd64 PASSES='fmt bom dep' ./scripts/test.sh
;;
*)
echo "Failed to find target"

View File

@ -25,19 +25,19 @@ jobs:
export JUNIT_REPORT_DIR=$(realpath ${TARGET})
case "${TARGET}" in
linux-amd64-integration-1-cpu)
GOARCH=amd64 CPU=1 PASSES='integration' RACE='false' ./test.sh
GOARCH=amd64 CPU=1 PASSES='integration' RACE='false' ./scripts/test.sh
;;
linux-amd64-integration-2-cpu)
GOARCH=amd64 CPU=2 PASSES='integration' RACE='false' ./test.sh
GOARCH=amd64 CPU=2 PASSES='integration' RACE='false' ./scripts/test.sh
;;
linux-amd64-integration-4-cpu)
GOARCH=amd64 CPU=4 PASSES='integration' RACE='false' ./test.sh
GOARCH=amd64 CPU=4 PASSES='integration' RACE='false' ./scripts/test.sh
;;
linux-amd64-unit-4-cpu-race)
GOARCH=amd64 PASSES='unit' RACE='true' CPU='4' ./test.sh -p=2
GOARCH=amd64 PASSES='unit' RACE='true' CPU='4' ./scripts/test.sh -p=2
;;
linux-386-unit-1-cpu)
GOARCH=386 PASSES='unit' RACE='false' CPU='1' ./test.sh -p=4
GOARCH=386 PASSES='unit' RACE='false' CPU='1' ./scripts/test.sh -p=4
;;
*)
echo "Failed to find target"

View File

@ -22,7 +22,7 @@ XARGS += rm -r
.PHONY: build
build:
GO_BUILD_FLAGS="-v" ./build.sh
GO_BUILD_FLAGS="-v" ./scripts/build.sh
./bin/etcd --version
./bin/etcdctl version
./bin/etcdutl version
@ -96,16 +96,16 @@ pull-docker-test:
test:
$(info TEST_OPTS: $(TEST_OPTS))
$(info log-file: test-$(TEST_SUFFIX).log)
$(TEST_OPTS) ./test.sh 2>&1 | tee test-$(TEST_SUFFIX).log
$(TEST_OPTS) ./scripts/test.sh 2>&1 | tee test-$(TEST_SUFFIX).log
! egrep "(--- FAIL:|FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test-$(TEST_SUFFIX).log
test-smoke:
$(info log-file: test-$(TEST_SUFFIX).log)
PASSES="fmt build unit" ./test.sh 2<&1 | tee test-$(TEST_SUFFIX).log
PASSES="fmt build unit" ./scripts/test.sh 2<&1 | tee test-$(TEST_SUFFIX).log
test-full:
$(info log-file: test-$(TEST_SUFFIX).log)
PASSES="fmt build release unit integration functional e2e grpcproxy" ./test.sh 2<&1 | tee test-$(TEST_SUFFIX).log
PASSES="fmt build release unit integration functional e2e grpcproxy" ./scripts/test.sh 2<&1 | tee test-$(TEST_SUFFIX).log
ensure-docker-test-image-exists:
make push-docker-test || echo "WARNING: Container Image not found in registry, building locally"; make build-docker-test
@ -122,7 +122,7 @@ docker-test: ensure-docker-test-image-exists
$(TMP_DIR_MOUNT_FLAG) \
--mount type=bind,source=`pwd`,destination=/go/src/go.etcd.io/etcd \
gcr.io/etcd-development/etcd-test:go$(GO_VERSION) \
/bin/bash -c "$(TEST_OPTS) ./test.sh 2>&1 | tee test-$(TEST_SUFFIX).log"
/bin/bash -c "$(TEST_OPTS) ./scripts/test.sh 2>&1 | tee test-$(TEST_SUFFIX).log"
! egrep "(--- FAIL:|FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test-$(TEST_SUFFIX).log
docker-test-coverage:

6
build
View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
echo -e "\\e[91mDEPRECATED!!! Use build.sh script instead.\\e[0m\\n"
sleep 1
source ./build.sh

View File

@ -87,7 +87,7 @@ function main {
export GOARCH=${TARGET_ARCH}
pushd etcd >/dev/null
GO_LDFLAGS="-s" ./build.sh
GO_LDFLAGS="-s" ./scripts/build.sh
popd >/dev/null
TARGET="etcd-${VER}-${GOOS}-${GOARCH}"

View File

@ -22,7 +22,7 @@ ETCD_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
pushd "${ETCD_ROOT}" >/dev/null
log_callout "Building etcd binary..."
./scripts/build-binary "${VERSION}"
./scripts/build-binary.sh "${VERSION}"
for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do
log_callout "Building ${TARGET_ARCH} docker image..."

View File

@ -8,7 +8,7 @@ set -o pipefail
LOG_FILE=${1:-test-coverage.log}
# We collect the coverage
COVERDIR=covdir PASSES='build build_cov cov' ./test.sh 2>&1 | tee "${LOG_FILE}"
COVERDIR=covdir PASSES='build build_cov cov' ./scripts/test.sh 2>&1 | tee "${LOG_FILE}"
test_success="$?"
# We try to upload whatever we have:

View File

@ -140,7 +140,8 @@ main() {
if [[ -n $(git status -s) ]]; then
log_callout "Committing mods & api/version/version.go update."
run git add api/version/version.go
run git add $(find -name go.mod ! -path './release/*'| xargs)
# shellcheck disable=SC2038,SC2046
run git add $(find . -name go.mod ! -path './release/*'| xargs)
run git diff --staged | cat
run git commit -m "version: bump up to ${VERSION}"
run git diff --staged | cat
@ -162,6 +163,7 @@ main() {
fi
# Verify the latest commit has the version tag
# shellcheck disable=SC2155
local tag="$(git describe --exact-match HEAD)"
if [ "${tag}" != "${RELEASE_VERSION}" ]; then
log_error "Error: Expected HEAD to be tagged with ${RELEASE_VERSION}, but 'git describe --exact-match HEAD' reported: ${tag}"
@ -169,6 +171,7 @@ main() {
fi
# Verify the version tag is on the right branch
# shellcheck disable=SC2155
local branch=$(git for-each-ref --contains "${RELEASE_VERSION}" --format="%(refname)" 'refs/heads' | cut -d '/' -f 3)
if [ "${branch}" != "${BRANCH}" ]; then
log_error "Error: Git tag ${RELEASE_VERSION} should be on branch '${BRANCH}' but is on '${branch}'"
@ -198,6 +201,7 @@ main() {
# Generate SHA256SUMS
log_callout "Generating sha256sums of release artifacts."
pushd ./release
# shellcheck disable=SC2010
ls . | grep -E '\.tar.gz$|\.zip$' | xargs shasum -a 256 > ./SHA256SUMS
popd
if [ -s ./release/SHA256SUMS ]; then
@ -263,6 +267,7 @@ main() {
# Check image versions
for IMAGE in "quay.io/coreos/etcd:${RELEASE_VERSION}" "gcr.io/etcd-development/etcd:${RELEASE_VERSION}"; do
# shellcheck disable=SC2155
local image_version=$(docker run --rm "${IMAGE}" etcd --version | grep "etcd Version" | awk -F: '{print $2}' | tr -d '[:space:]')
if [ "${image_version}" != "${VERSION}" ]; then
log_error "Check failed: etcd --version output for ${IMAGE} is incorrect: ${image_version}"
@ -271,9 +276,11 @@ main() {
done
# Check gsutil binary versions
# shellcheck disable=SC2155
local BINARY_TGZ="etcd-${RELEASE_VERSION}-$(go env GOOS)-amd64.tar.gz"
gsutil cp "gs://etcd/${RELEASE_VERSION}/${BINARY_TGZ}" downloads
tar -zx -C downloads -f "downloads/${BINARY_TGZ}"
# shellcheck disable=SC2155
local binary_version=$("./downloads/etcd-${RELEASE_VERSION}-$(go env GOOS)-amd64/etcd" --version | grep "etcd Version" | awk -F: '{print $2}' | tr -d '[:space:]')
if [ "${binary_version}" != "${VERSION}" ]; then
log_error "Check failed: etcd --version output for ${BINARY_TGZ} from gs://etcd/${RELEASE_VERSION} is incorrect: ${binary_version}"

View File

@ -1,35 +1,35 @@
#!/usr/bin/env bash
#
# Run all etcd tests
# ./test.sh
# ./test.sh -v
# ./scripts/test.sh
# ./scripts/test.sh -v
#
#
# Run specified test pass
#
# $ PASSES=unit ./test.sh
# $ PASSES=integration ./test.sh
# $ PASSES=unit ./scripts/test.sh
# $ PASSES=integration ./scripts/test.sh
#
#
# Run tests for one package
# Each pass has different default timeout, if you just run tests in one package or 1 test case then you can set TIMEOUT
# flag for different expectation
#
# $ PASSES=unit PKG=./wal TIMEOUT=1m ./test.sh
# $ PASSES=integration PKG=./clientv3 TIMEOUT=1m ./test.sh
# $ PASSES=unit PKG=./wal TIMEOUT=1m ./scripts/test.sh
# $ PASSES=integration PKG=./clientv3 TIMEOUT=1m ./scripts/test.sh
#
# Run specified unit tests in one package
# To run all the tests with prefix of "TestNew", set "TESTCASE=TestNew ";
# to run only "TestNew", set "TESTCASE="\bTestNew\b""
#
# $ PASSES=unit PKG=./wal TESTCASE=TestNew TIMEOUT=1m ./test.sh
# $ PASSES=unit PKG=./wal TESTCASE="\bTestNew\b" TIMEOUT=1m ./test.sh
# $ PASSES=integration PKG=./client/integration TESTCASE="\bTestV2NoRetryEOF\b" TIMEOUT=1m ./test.sh
# $ PASSES=unit PKG=./wal TESTCASE=TestNew TIMEOUT=1m ./scripts/test.sh
# $ PASSES=unit PKG=./wal TESTCASE="\bTestNew\b" TIMEOUT=1m ./scripts/test.sh
# $ PASSES=integration PKG=./client/integration TESTCASE="\bTestV2NoRetryEOF\b" TIMEOUT=1m ./scripts/test.sh
#
#
# Run code coverage
# COVERDIR must either be a absolute path or a relative path to the etcd root
# $ COVERDIR=coverage PASSES="build build_cov cov" ./test.sh
# $ COVERDIR=coverage PASSES="build build_cov cov" ./scripts/test.sh
# $ go tool cover -html ./coverage/cover.out
set -e
@ -43,7 +43,7 @@ set -o pipefail
export GOFLAGS=-mod=readonly
source ./scripts/test_lib.sh
source ./build.sh
source ./scripts/build.sh
PASSES=${PASSES:-"fmt bom dep build unit"}
PKG=${PKG:-}
@ -299,7 +299,7 @@ function cov_pass {
fi
if [ ! -f "bin/etcd_test" ]; then
log_error "etcd_test binary not found. Call: PASSES='build_cov' ./test.sh"
log_error "etcd_test binary not found. Call: PASSES='build_cov' ./scripts/test.sh"
return 255
fi
@ -400,7 +400,7 @@ function fmt_pass {
function shellcheck_pass {
if tool_exists "shellcheck" "https://github.com/koalaman/shellcheck#installing"; then
generic_checker run shellcheck -fgcc build test scripts/*.sh ./*.sh
generic_checker run shellcheck -fgcc scripts/*.sh
fi
}
@ -410,7 +410,7 @@ function shellws_pass {
local files
files=$(find ./ -name '*.sh' -print0 | xargs -0 )
# shellcheck disable=SC2206
files=( ${files[@]} "./scripts/build-binary" "./scripts/build-docker" "./scripts/release" )
files=( ${files[@]} "./scripts/build-binary.sh" "./scripts/build-docker.sh" "./scripts/release.sh" )
log_cmd "grep -E -n $'^ *${TAB}' ${files[*]}"
# shellcheck disable=SC2086
if grep -E -n $'^ *${TAB}' "${files[@]}" | sed $'s|${TAB}|[\\\\tab]|g'; then

View File

@ -71,7 +71,7 @@ function relativePath {
local commonPart=$source
local result=""
while [[ "${target#$commonPart}" == "${target}" ]]; do
while [[ "${target#"$commonPart"}" == "${target}" ]]; do
# no match, means that candidate common part is not correct
# go up one level (reduce common part)
commonPart="$(dirname "$commonPart")"
@ -90,7 +90,7 @@ function relativePath {
# since we now have identified the common part,
# compute the non-common part
local forwardPart="${target#$commonPart}"
local forwardPart="${target#"$commonPart"}"
# and now stick all parts together
if [[ -n $result ]] && [[ -n $forwardPart ]]; then

6
test
View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
echo -e "\\e[91mDEPRECATED!!! Use test.sh script instead.\\e[0m\\n"
sleep 1
source ./test.sh

View File

@ -26,11 +26,11 @@ ADD ./tests/functional/functional.yaml /functional.yaml
RUN go get -v go.etcd.io/gofail \
&& pushd ${GOPATH}/src/go.etcd.io/etcd \
&& GO_BUILD_FLAGS="-v" ./build.sh \
&& GO_BUILD_FLAGS="-v" ./scripts/build.sh \
&& mkdir -p /bin \
&& cp ./bin/etcd /bin/etcd \
&& cp ./bin/etcdctl /bin/etcdctl \
&& GO_BUILD_FLAGS="-v" FAILPOINTS=1 ./build.sh \
&& GO_BUILD_FLAGS="-v" FAILPOINTS=1 ./scripts/build.sh \
&& cp ./bin/etcd /bin/etcd-failpoints \
&& ./tests/functional/build \
&& cp ./bin/etcd-agent /bin/etcd-agent \

View File

@ -39,7 +39,7 @@ Proxy layer that simulates various network conditions.
Test locally
```bash
$ ./build.sh
$ ./scripts/build.sh
$ ./bin/etcd
$ make build-functional
@ -201,7 +201,7 @@ $ curl -L http://localhost:2378/blackhole-tx -X DELETE
Trigger leader election
```bash
$ ./build.sh
$ ./scripts/build.sh
$ make build-functional
$ rm -rf /tmp/etcd-proxy-data.s*

View File

@ -54,7 +54,7 @@ See README.md for more examples.
Example:
# build etcd
$ ./build.sh
$ ./scripts/build.sh
$ ./bin/etcd
# build etcd-proxy

View File

@ -11,7 +11,7 @@ local-tester depends on `goreman` to manage its processes and `bash` to run faul
local-tester needs `etcd`, `benchmark`, and `bridge` binaries. To build these binaries, run the following from the etcd repository root:
```sh
./build.sh
./scripts/build.sh
pushd tools/benchmark/ && go build && popd
pushd tools/local-tester/bridge && go build && popd
```