mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #15608 from pchan/automated-cherry-pick-of-#15505-upstream-release-3.5
[3.5] Add testing of etcd in local image in release workflow
This commit is contained in:
commit
1259884695
8
.github/workflows/release.yaml
vendored
8
.github/workflows/release.yaml
vendored
@ -8,7 +8,10 @@ jobs:
|
|||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "1.19.7"
|
go-version: "1.19.7"
|
||||||
- run: |
|
- name: release
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
git config --global user.email "github-action@etcd.io"
|
git config --global user.email "github-action@etcd.io"
|
||||||
git config --global user.name "Github Action"
|
git config --global user.name "Github Action"
|
||||||
gpg --batch --gen-key <<EOF
|
gpg --batch --gen-key <<EOF
|
||||||
@ -22,3 +25,6 @@ jobs:
|
|||||||
Expire-Date: 0
|
Expire-Date: 0
|
||||||
EOF
|
EOF
|
||||||
DRY_RUN=true ./scripts/release --no-upload --no-docker-push --in-place 3.5.99
|
DRY_RUN=true ./scripts/release --no-upload --no-docker-push --in-place 3.5.99
|
||||||
|
- name: test-image
|
||||||
|
run: |
|
||||||
|
VERSION=3.5.99 ./scripts/test_images.sh
|
||||||
|
84
scripts/test_images.sh
Executable file
84
scripts/test_images.sh
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
source ./scripts/test_lib.sh
|
||||||
|
|
||||||
|
function startContainer {
|
||||||
|
# run docker in the background
|
||||||
|
docker run -d --rm --name "${RUN_NAME}" "${IMAGE}"
|
||||||
|
|
||||||
|
# wait for etcd daemon to bootstrap
|
||||||
|
sleep 5
|
||||||
|
}
|
||||||
|
|
||||||
|
function runVersionCheck {
|
||||||
|
Out=$(docker run --rm "${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"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Can't proceed without docker
|
||||||
|
if ! command -v docker >/dev/null; then
|
||||||
|
log_error "cannot find docker"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# You can't run darwin binaries in linux containers
|
||||||
|
if [[ $(go env GOOS) == "darwin" ]]; then
|
||||||
|
echo "Please use linux machine for release builds."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Pick defaults based on release workflow
|
||||||
|
ARCH=$(go env GOARCH)
|
||||||
|
REPOSITARY=${REPOSITARY:-"gcr.io/etcd-development/etcd"}
|
||||||
|
if [ -n "$VERSION" ]; then
|
||||||
|
# Expected Format: v3.6.99-amd64
|
||||||
|
TAG=v"${VERSION}"-"${ARCH}"
|
||||||
|
else
|
||||||
|
echo "Terminating test, VERSION not supplied"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
IMAGE=${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"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Version check
|
||||||
|
runVersionCheck "/usr/local/bin/etcd" "--version"
|
||||||
|
runVersionCheck "/usr/local/bin/etcdctl" "version"
|
||||||
|
runVersionCheck "/usr/local/bin/etcdutl" "version"
|
||||||
|
|
||||||
|
startContainer
|
||||||
|
# stop container
|
||||||
|
trap 'docker stop "${RUN_NAME}"' EXIT
|
||||||
|
|
||||||
|
|
||||||
|
# Put/Get check
|
||||||
|
PUT=$(docker exec "${RUN_NAME}" /usr/local/bin/etcdctl put "${KEY}" "${VALUE}")
|
||||||
|
if [ "${PUT}" != "OK" ]; then
|
||||||
|
echo "Problem with Putting in etcd"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
GET=$(docker exec "${RUN_NAME}" /usr/local/bin/etcdctl get "$KEY" --print-value-only)
|
||||||
|
if [ "${GET}" != "${VALUE}" ]; then
|
||||||
|
echo "Problem with getting foo bar in etcd. Got ${GET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Succesfully tested etcd local image ${TAG}"
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user