2021-11-21 13:41:30 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
trap 'cleanup $LINENO' ERR
|
|
|
|
|
|
|
|
# shellcheck disable=SC2120
|
|
|
|
cleanup() {
|
2024-06-13 01:08:11 -04:00
|
|
|
MINIO_VERSION=dev /tmp/gopath/bin/docker-compose \
|
2023-05-26 01:07:25 -04:00
|
|
|
-f "buildscripts/upgrade-tests/compose.yml" \
|
2024-06-13 01:08:11 -04:00
|
|
|
down || true
|
|
|
|
|
|
|
|
MINIO_VERSION=dev /tmp/gopath/bin/docker-compose \
|
|
|
|
-f "buildscripts/upgrade-tests/compose.yml" \
|
|
|
|
rm || true
|
|
|
|
|
|
|
|
for volume in $(docker volume ls -q | grep upgrade); do
|
|
|
|
docker volume rm ${volume} || true
|
|
|
|
done
|
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
docker volume prune -f
|
2024-06-13 01:08:11 -04:00
|
|
|
docker system prune -f || true
|
|
|
|
docker volume prune -f || true
|
|
|
|
docker volume rm $(docker volume ls -q -f dangling=true) || true
|
2021-11-21 13:41:30 -05:00
|
|
|
}
|
|
|
|
|
2021-11-22 12:36:29 -05:00
|
|
|
verify_checksum_after_heal() {
|
2023-05-26 01:07:25 -04:00
|
|
|
local sum1
|
|
|
|
sum1=$(curl -s "$2" | sha256sum)
|
|
|
|
mc admin heal --json -r "$1" >/dev/null # test after healing
|
|
|
|
local sum1_heal
|
|
|
|
sum1_heal=$(curl -s "$2" | sha256sum)
|
|
|
|
|
|
|
|
if [ "${sum1_heal}" != "${sum1}" ]; then
|
|
|
|
echo "mismatch expected ${sum1_heal}, got ${sum1}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-11-22 12:36:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
verify_checksum_mc() {
|
2023-05-26 01:07:25 -04:00
|
|
|
local expected
|
|
|
|
expected=$(mc cat "$1" | sha256sum)
|
|
|
|
local got
|
|
|
|
got=$(mc cat "$2" | sha256sum)
|
|
|
|
|
|
|
|
if [ "${expected}" != "${got}" ]; then
|
|
|
|
echo "mismatch - expected ${expected}, got ${got}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "matches - ${expected}, got ${got}"
|
2021-11-22 12:36:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
add_alias() {
|
2023-05-26 01:07:25 -04:00
|
|
|
for i in $(seq 1 4); do
|
|
|
|
echo "... attempting to add alias $i"
|
|
|
|
until (mc alias set minio http://127.0.0.1:9000 minioadmin minioadmin); do
|
|
|
|
echo "...waiting... for 5secs" && sleep 5
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Sleeping for nginx"
|
|
|
|
sleep 20
|
2021-11-22 12:36:29 -05:00
|
|
|
}
|
|
|
|
|
2021-11-21 13:41:30 -05:00
|
|
|
__init__() {
|
2023-05-26 01:07:25 -04:00
|
|
|
sudo apt install curl -y
|
|
|
|
export GOPATH=/tmp/gopath
|
|
|
|
export PATH=${PATH}:${GOPATH}/bin
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
go install github.com/minio/mc@latest
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2024-04-05 07:39:55 -04:00
|
|
|
## this is needed because github actions don't have
|
|
|
|
## docker-compose on all runners
|
|
|
|
go install github.com/docker/compose/v2/cmd@latest
|
|
|
|
mv -v /tmp/gopath/bin/cmd /tmp/gopath/bin/docker-compose
|
|
|
|
|
2024-06-13 01:08:11 -04:00
|
|
|
cleanup
|
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
TAG=minio/minio:dev make docker
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
MINIO_VERSION=RELEASE.2019-12-19T22-52-26Z docker-compose \
|
|
|
|
-f "buildscripts/upgrade-tests/compose.yml" \
|
|
|
|
up -d --build
|
2021-11-22 12:36:29 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
add_alias
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
mc mb minio/minio-test/
|
|
|
|
mc cp ./minio minio/minio-test/to-read/
|
|
|
|
mc cp /etc/hosts minio/minio-test/to-read/hosts
|
|
|
|
mc anonymous set download minio/minio-test
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
verify_checksum_mc ./minio minio/minio-test/to-read/minio
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
curl -s http://127.0.0.1:9000/minio-test/to-read/hosts | sha256sum
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2024-06-13 01:08:11 -04:00
|
|
|
MINIO_VERSION=dev /tmp/gopath/bin/docker-compose -f "buildscripts/upgrade-tests/compose.yml" stop
|
2021-11-21 13:41:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2024-06-13 01:08:11 -04:00
|
|
|
MINIO_VERSION=dev /tmp/gopath/bin/docker-compose -f "buildscripts/upgrade-tests/compose.yml" up -d --build
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
add_alias
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
verify_checksum_after_heal minio/minio-test http://127.0.0.1:9000/minio-test/to-read/hosts
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
verify_checksum_mc ./minio minio/minio-test/to-read/minio
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
verify_checksum_mc /etc/hosts minio/minio-test/to-read/hosts
|
2021-11-21 13:41:30 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
cleanup
|
2021-11-21 13:41:30 -05:00
|
|
|
}
|
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
(__init__ "$@" && main "$@")
|