Skip to content

Commit 8f95cf2

Browse files
authored
Merge pull request #19855 from joshjms/release-3.4-add-test-release-makefile-target
[release-3.4] add test release makefile target
2 parents acb0926 + 013d5b4 commit 8f95cf2

File tree

4 files changed

+61
-5
lines changed

4 files changed

+61
-5
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ test-e2e:
166166
test-e2e-release:
167167
PASSES="build release e2e" ./test $(GO_TEST_FLAGS)
168168

169+
.PHONY: test-release
170+
test-release:
171+
PASSES="release_tests" VERSION="3.4.99" ./test $(GO_TEST_FLAGS)
172+
169173
docker-test:
170174
$(info GO_VERSION: $(GO_VERSION))
171175
$(info ETCD_VERSION: $(ETCD_VERSION))

scripts/test_images.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ source ./scripts/test_lib.sh
88

99
function startContainer {
1010
# run docker in the background
11-
docker run -d --rm --name "${RUN_NAME}" "${IMAGE}"
11+
docker run -d --rm --name "${RUN_NAME}" "${TEST_IMAGE}"
1212

1313
# wait for etcd daemon to bootstrap
1414
sleep 5
1515
}
1616

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

5555
# ETCD related values
5656
RUN_NAME="test_etcd"
5757
KEY="foo"
5858
VALUE="bar"
5959

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

scripts/test_lib.sh

+24
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,27 @@ function log_info {
5252
>&2 echo "$@"
5353
>&2 echo -n -e "${COLOR_NONE}"
5454
}
55+
56+
# The version present in the .go-verion is the default version that test and build scripts will use.
57+
# However, it is possible to control the version that should be used with the help of env vars:
58+
# - FORCE_HOST_GO: if set to a non-empty value, use the version of go installed in system's $PATH.
59+
# - GO_VERSION: desired version of go to be used, might differ from what is present in .go-version.
60+
# If empty, the value defaults to the version in .go-version.
61+
function determine_go_version {
62+
# Borrowing from how Kubernetes does this:
63+
# https://github.com/kubernetes/kubernetes/blob/17854f0e0a153b06f9d0db096e2cd8ab2fa89c11/hack/lib/golang.sh#L510-L520
64+
#
65+
# default GO_VERSION to content of .go-version
66+
GO_VERSION="${GO_VERSION:-"$(cat "./.go-version")"}"
67+
if [ "${GOTOOLCHAIN:-auto}" != 'auto' ]; then
68+
# no-op, just respect GOTOOLCHAIN
69+
:
70+
elif [ -n "${FORCE_HOST_GO:-}" ]; then
71+
export GOTOOLCHAIN='local'
72+
else
73+
GOTOOLCHAIN="go${GO_VERSION}"
74+
export GOTOOLCHAIN
75+
fi
76+
}
77+
78+
determine_go_version

test

+28
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,34 @@ function release_pass {
398398
mv /tmp/etcd ./bin/etcd-last-release
399399
}
400400

401+
function release_tests_pass {
402+
if [ -z "${VERSION:-}" ]; then
403+
VERSION=$(go list -m go.etcd.io/etcd/api/v3 2>/dev/null | \
404+
awk '{split(substr($2,2), a, "."); print a[1]"."a[2]".99"}')
405+
fi
406+
407+
if [ -n "${CI:-}" ]; then
408+
git config user.email "[email protected]"
409+
git config user.name "Prow"
410+
411+
gpg --batch --gen-key <<EOF
412+
%no-protection
413+
Key-Type: 1
414+
Key-Length: 2048
415+
Subkey-Type: 1
416+
Subkey-Length: 2048
417+
Name-Real: Prow
418+
Name-Email: [email protected]
419+
Expire-Date: 0
420+
EOF
421+
422+
git remote add origin https://github.com/etcd-io/etcd.git
423+
fi
424+
425+
DRY_RUN=true "./scripts/release.sh" --no-upload --no-docker-push --no-gh-release --in-place "${VERSION}"
426+
VERSION="${VERSION}" "./scripts/test_images.sh"
427+
}
428+
401429
function shellcheck_pass {
402430
SHELLCHECK=shellcheck
403431

0 commit comments

Comments
 (0)