github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/buildscripts/rewrite-old-new.sh (about) 1 #!/bin/bash -e 2 3 set -E 4 set -o pipefail 5 set -x 6 7 WORK_DIR="$PWD/.verify-$RANDOM" 8 MINIO_CONFIG_DIR="$WORK_DIR/.minio" 9 MINIO_OLD=("$PWD/minio.RELEASE.2020-10-28T08-16-50Z" --config-dir "$MINIO_CONFIG_DIR" server) 10 MINIO=("$PWD/minio" --config-dir "$MINIO_CONFIG_DIR" server) 11 12 if [ ! -x "$PWD/minio" ]; then 13 echo "minio executable binary not found in current directory" 14 exit 1 15 fi 16 17 function download_old_release() { 18 if [ ! -f minio.RELEASE.2020-10-28T08-16-50Z ]; then 19 curl --silent -O https://dl.minio.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2020-10-28T08-16-50Z 20 chmod a+x minio.RELEASE.2020-10-28T08-16-50Z 21 fi 22 } 23 24 function verify_rewrite() { 25 start_port=$1 26 27 export MINIO_ACCESS_KEY=minio 28 export MINIO_SECRET_KEY=minio123 29 export MC_HOST_minio="http://minio:minio123@127.0.0.1:${start_port}/" 30 unset MINIO_KMS_AUTO_ENCRYPTION # do not auto-encrypt objects 31 export MINIO_CI_CD=1 32 33 MC_BUILD_DIR="mc-$RANDOM" 34 if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then 35 echo "failed to download https://github.com/minio/mc" 36 purge "${MC_BUILD_DIR}" 37 exit 1 38 fi 39 40 (cd "${MC_BUILD_DIR}" && go build -o "$WORK_DIR/mc") 41 42 # remove mc source. 43 purge "${MC_BUILD_DIR}" 44 45 "${MINIO_OLD[@]}" --address ":$start_port" "${WORK_DIR}/xl{1...16}" >"${WORK_DIR}/server1.log" 2>&1 & 46 pid=$! 47 disown $pid 48 sleep 10 49 50 if ! ps -p ${pid} 1>&2 >/dev/null; then 51 echo "server1 log:" 52 cat "${WORK_DIR}/server1.log" 53 echo "FAILED" 54 purge "$WORK_DIR" 55 exit 1 56 fi 57 58 "${WORK_DIR}/mc" mb minio/healing-rewrite-bucket --quiet --with-lock 59 "${WORK_DIR}/mc" cp \ 60 buildscripts/verify-build.sh \ 61 minio/healing-rewrite-bucket/ \ 62 --disable-multipart --quiet 63 64 "${WORK_DIR}/mc" cp \ 65 buildscripts/verify-build.sh \ 66 minio/healing-rewrite-bucket/ \ 67 --disable-multipart --quiet 68 69 "${WORK_DIR}/mc" cp \ 70 buildscripts/verify-build.sh \ 71 minio/healing-rewrite-bucket/ \ 72 --disable-multipart --quiet 73 74 kill ${pid} 75 sleep 3 76 77 "${MINIO[@]}" --address ":$start_port" "${WORK_DIR}/xl{1...16}" >"${WORK_DIR}/server1.log" 2>&1 & 78 pid=$! 79 disown $pid 80 sleep 10 81 82 if ! ps -p ${pid} 1>&2 >/dev/null; then 83 echo "server1 log:" 84 cat "${WORK_DIR}/server1.log" 85 echo "FAILED" 86 purge "$WORK_DIR" 87 exit 1 88 fi 89 90 ( 91 cd ./docs/debugging/s3-check-md5 92 go install -v 93 ) 94 95 if ! s3-check-md5 \ 96 -debug \ 97 -versions \ 98 -access-key minio \ 99 -secret-key minio123 \ 100 -endpoint http://127.0.0.1:${start_port}/ 2>&1 | grep INTACT; then 101 echo "server1 log:" 102 cat "${WORK_DIR}/server1.log" 103 echo "FAILED" 104 mkdir -p inspects 105 ( 106 cd inspects 107 "${WORK_DIR}/mc" admin inspect minio/healing-rewrite-bucket/verify-build.sh/** 108 ) 109 110 "${WORK_DIR}/mc" mb play/inspects 111 "${WORK_DIR}/mc" mirror inspects play/inspects 112 113 purge "$WORK_DIR" 114 exit 1 115 fi 116 117 go run ./buildscripts/heal-manual.go "127.0.0.1:${start_port}" "minio" "minio123" 118 sleep 1 119 120 if ! s3-check-md5 \ 121 -debug \ 122 -versions \ 123 -access-key minio \ 124 -secret-key minio123 \ 125 -endpoint http://127.0.0.1:${start_port}/ 2>&1 | grep INTACT; then 126 echo "server1 log:" 127 cat "${WORK_DIR}/server1.log" 128 echo "FAILED" 129 mkdir -p inspects 130 ( 131 cd inspects 132 "${WORK_DIR}/mc" admin inspect minio/healing-rewrite-bucket/verify-build.sh/** 133 ) 134 135 "${WORK_DIR}/mc" mb play/inspects 136 "${WORK_DIR}/mc" mirror inspects play/inspects 137 138 purge "$WORK_DIR" 139 exit 1 140 fi 141 142 kill ${pid} 143 } 144 145 function main() { 146 download_old_release 147 148 start_port=$(shuf -i 10000-65000 -n 1) 149 150 verify_rewrite ${start_port} 151 } 152 153 function purge() { 154 rm -rf "$1" 155 } 156 157 (main "$@") 158 rv=$? 159 purge "$WORK_DIR" 160 exit "$rv"