You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.8 KiB

  1. #!/bin/bash
  2. trap 'cleanup $LINENO' ERR
  3. # shellcheck disable=SC2120
  4. cleanup() {
  5. MINIO_VERSION=dev /tmp/gopath/bin/docker-compose \
  6. -f "buildscripts/upgrade-tests/compose.yml" \
  7. down || true
  8. MINIO_VERSION=dev /tmp/gopath/bin/docker-compose \
  9. -f "buildscripts/upgrade-tests/compose.yml" \
  10. rm || true
  11. for volume in $(docker volume ls -q | grep upgrade); do
  12. docker volume rm ${volume} || true
  13. done
  14. docker volume prune -f
  15. docker system prune -f || true
  16. docker volume prune -f || true
  17. docker volume rm $(docker volume ls -q -f dangling=true) || true
  18. }
  19. verify_checksum_after_heal() {
  20. local sum1
  21. sum1=$(curl -s "$2" | sha256sum)
  22. mc admin heal --json -r "$1" >/dev/null # test after healing
  23. local sum1_heal
  24. sum1_heal=$(curl -s "$2" | sha256sum)
  25. if [ "${sum1_heal}" != "${sum1}" ]; then
  26. echo "mismatch expected ${sum1_heal}, got ${sum1}"
  27. exit 1
  28. fi
  29. }
  30. verify_checksum_mc() {
  31. local expected
  32. expected=$(mc cat "$1" | sha256sum)
  33. local got
  34. got=$(mc cat "$2" | sha256sum)
  35. if [ "${expected}" != "${got}" ]; then
  36. echo "mismatch - expected ${expected}, got ${got}"
  37. exit 1
  38. fi
  39. echo "matches - ${expected}, got ${got}"
  40. }
  41. add_alias() {
  42. for i in $(seq 1 4); do
  43. echo "... attempting to add alias $i"
  44. until (mc alias set minio http://127.0.0.1:9000 minioadmin minioadmin); do
  45. echo "...waiting... for 5secs" && sleep 5
  46. done
  47. done
  48. echo "Sleeping for nginx"
  49. sleep 20
  50. }
  51. __init__() {
  52. sudo apt install curl -y
  53. export GOPATH=/tmp/gopath
  54. export PATH=${PATH}:${GOPATH}/bin
  55. go install github.com/minio/mc@latest
  56. ## this is needed because github actions don't have
  57. ## docker-compose on all runners
  58. COMPOSE_VERSION=v2.35.1
  59. mkdir -p /tmp/gopath/bin/
  60. wget -O /tmp/gopath/bin/docker-compose https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-linux-x86_64
  61. chmod +x /tmp/gopath/bin/docker-compose
  62. cleanup
  63. TAG=minio/minio:dev make docker
  64. MINIO_VERSION=RELEASE.2019-12-19T22-52-26Z docker-compose \
  65. -f "buildscripts/upgrade-tests/compose.yml" \
  66. up -d --build
  67. add_alias
  68. mc mb minio/minio-test/
  69. mc cp ./minio minio/minio-test/to-read/
  70. mc cp /etc/hosts minio/minio-test/to-read/hosts
  71. mc anonymous set download minio/minio-test
  72. verify_checksum_mc ./minio minio/minio-test/to-read/minio
  73. curl -s http://127.0.0.1:9000/minio-test/to-read/hosts | sha256sum
  74. MINIO_VERSION=dev /tmp/gopath/bin/docker-compose -f "buildscripts/upgrade-tests/compose.yml" stop
  75. }
  76. main() {
  77. MINIO_VERSION=dev /tmp/gopath/bin/docker-compose -f "buildscripts/upgrade-tests/compose.yml" up -d --build
  78. add_alias
  79. verify_checksum_after_heal minio/minio-test http://127.0.0.1:9000/minio-test/to-read/hosts
  80. verify_checksum_mc ./minio minio/minio-test/to-read/minio
  81. verify_checksum_mc /etc/hosts minio/minio-test/to-read/hosts
  82. cleanup
  83. }
  84. (__init__ "$@" && main "$@")