Skip to content

[release-3.4] add test release makefile target #19855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: release-3.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ test-e2e:
test-e2e-release:
PASSES="build release e2e" ./test $(GO_TEST_FLAGS)

.PHONY: test-release
test-release:
PASSES="release_tests" VERSION="3.4.99" ./test $(GO_TEST_FLAGS)

docker-test:
$(info GO_VERSION: $(GO_VERSION))
$(info ETCD_VERSION: $(ETCD_VERSION))
Expand Down
10 changes: 5 additions & 5 deletions scripts/test_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ source ./scripts/test_lib.sh

function startContainer {
# run docker in the background
docker run -d --rm --name "${RUN_NAME}" "${IMAGE}"
docker run -d --rm --name "${RUN_NAME}" "${TEST_IMAGE}"

# wait for etcd daemon to bootstrap
sleep 5
}

function runVersionCheck {
Out=$(docker run --rm "${IMAGE}" "${@}")
Out=$(docker run --rm "${TEST_IMAGE}" "${@}")
foundVersion=$(echo "$Out" | head -1 | rev | cut -d" " -f 1 | rev )
if [[ "${foundVersion}" != "${VERSION}" ]]; then
echo "error: Invalid Version. Got $foundVersion, expected $VERSION. Error: $Out"
Expand Down Expand Up @@ -50,15 +50,15 @@ else
echo "Terminating test, VERSION not supplied"
exit 1
fi
IMAGE=${IMAGE:-"${REPOSITARY}:${TAG}"}
TEST_IMAGE=${TEST_IMAGE:-"${REPOSITARY}:${TAG}"}

# ETCD related values
RUN_NAME="test_etcd"
KEY="foo"
VALUE="bar"

if [[ "$(docker images -q "${IMAGE}" 2> /dev/null)" == "" ]]; then
echo "${IMAGE} not present locally"
if [[ "$(docker images -q "${TEST_IMAGE}" 2> /dev/null)" == "" ]]; then
echo "${TEST_IMAGE} not present locally"
exit 1
fi

Expand Down
24 changes: 24 additions & 0 deletions scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,27 @@ function log_info {
>&2 echo "$@"
>&2 echo -n -e "${COLOR_NONE}"
}

# The version present in the .go-verion is the default version that test and build scripts will use.
# However, it is possible to control the version that should be used with the help of env vars:
# - FORCE_HOST_GO: if set to a non-empty value, use the version of go installed in system's $PATH.
# - GO_VERSION: desired version of go to be used, might differ from what is present in .go-version.
# If empty, the value defaults to the version in .go-version.
function determine_go_version {
# Borrowing from how Kubernetes does this:
# https://github.com/kubernetes/kubernetes/blob/17854f0e0a153b06f9d0db096e2cd8ab2fa89c11/hack/lib/golang.sh#L510-L520
#
# default GO_VERSION to content of .go-version
GO_VERSION="${GO_VERSION:-"$(cat "./.go-version")"}"
if [ "${GOTOOLCHAIN:-auto}" != 'auto' ]; then
# no-op, just respect GOTOOLCHAIN
:
elif [ -n "${FORCE_HOST_GO:-}" ]; then
export GOTOOLCHAIN='local'
else
GOTOOLCHAIN="go${GO_VERSION}"
export GOTOOLCHAIN
fi
}

determine_go_version
Comment on lines +61 to +78
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do a clean cherry pick of this commit (it's missing the documentation before the function definition)?

And the same note about the co-author trailer :)

28 changes: 28 additions & 0 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,34 @@ function release_pass {
mv /tmp/etcd ./bin/etcd-last-release
}

function release_tests_pass {
if [ -z "${VERSION:-}" ]; then
VERSION=$(go list -m go.etcd.io/etcd/api/v3 2>/dev/null | \
awk '{split(substr($2,2), a, "."); print a[1]"."a[2]".99"}')
fi

if [ -n "${CI:-}" ]; then
git config user.email "[email protected]"
git config user.name "Prow"

gpg --batch --gen-key <<EOF
%no-protection
Key-Type: 1
Key-Length: 2048
Subkey-Type: 1
Subkey-Length: 2048
Name-Real: Prow
Name-Email: [email protected]
Expire-Date: 0
EOF

git remote add origin https://github.com/etcd-io/etcd.git
fi

DRY_RUN=true "./scripts/release.sh" --no-upload --no-docker-push --no-gh-release --in-place "${VERSION}"
VERSION="${VERSION}" "./scripts/test_images.sh"
}

function shellcheck_pass {
SHELLCHECK=shellcheck

Expand Down
Loading