github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/buildscripts/verify-build.sh (about) 1 #!/bin/bash 2 # 3 4 set -e 5 set -E 6 set -o pipefail 7 8 if [ ! -x "$PWD/minio" ]; then 9 echo "minio executable binary not found in current directory" 10 exit 1 11 fi 12 13 WORK_DIR="$PWD/.verify-$RANDOM" 14 15 export MINT_MODE=core 16 export MINT_DATA_DIR="$WORK_DIR/data" 17 export SERVER_ENDPOINT="127.0.0.1:9000" 18 export ACCESS_KEY="minio" 19 export SECRET_KEY="minio123" 20 export ENABLE_HTTPS=0 21 export GO111MODULE=on 22 export GOGC=25 23 export ENABLE_ADMIN=1 24 25 export MINIO_CI_CD=1 26 27 MINIO_CONFIG_DIR="$WORK_DIR/.minio" 28 MINIO=("$PWD/minio" --config-dir "$MINIO_CONFIG_DIR") 29 30 FILE_1_MB="$MINT_DATA_DIR/datafile-1-MB" 31 FILE_65_MB="$MINT_DATA_DIR/datafile-65-MB" 32 33 FUNCTIONAL_TESTS="$WORK_DIR/functional-tests.sh" 34 35 function start_minio_fs() { 36 export MINIO_ROOT_USER=$ACCESS_KEY 37 export MINIO_ROOT_PASSWORD=$SECRET_KEY 38 "${MINIO[@]}" server "${WORK_DIR}/fs-disk" >"$WORK_DIR/fs-minio.log" 2>&1 & 39 sleep 10 40 } 41 42 function start_minio_erasure() { 43 "${MINIO[@]}" server "${WORK_DIR}/erasure-disk1" "${WORK_DIR}/erasure-disk2" "${WORK_DIR}/erasure-disk3" "${WORK_DIR}/erasure-disk4" >"$WORK_DIR/erasure-minio.log" 2>&1 & 44 sleep 15 45 } 46 47 function start_minio_erasure_sets() { 48 export MINIO_ENDPOINTS="${WORK_DIR}/erasure-disk-sets{1...32}" 49 "${MINIO[@]}" server >"$WORK_DIR/erasure-minio-sets.log" 2>&1 & 50 sleep 15 51 } 52 53 function start_minio_pool_erasure_sets() { 54 export MINIO_ROOT_USER=$ACCESS_KEY 55 export MINIO_ROOT_PASSWORD=$SECRET_KEY 56 export MINIO_ENDPOINTS="http://127.0.0.1:9000${WORK_DIR}/pool-disk-sets{1...4} http://127.0.0.1:9001${WORK_DIR}/pool-disk-sets{5...8}" 57 "${MINIO[@]}" server --address ":9000" >"$WORK_DIR/pool-minio-9000.log" 2>&1 & 58 "${MINIO[@]}" server --address ":9001" >"$WORK_DIR/pool-minio-9001.log" 2>&1 & 59 60 sleep 40 61 } 62 63 function start_minio_pool_erasure_sets_ipv6() { 64 export MINIO_ROOT_USER=$ACCESS_KEY 65 export MINIO_ROOT_PASSWORD=$SECRET_KEY 66 export MINIO_ENDPOINTS="http://[::1]:9000${WORK_DIR}/pool-disk-sets-ipv6{1...4} http://[::1]:9001${WORK_DIR}/pool-disk-sets-ipv6{5...8}" 67 "${MINIO[@]}" server --address="[::1]:9000" >"$WORK_DIR/pool-minio-ipv6-9000.log" 2>&1 & 68 "${MINIO[@]}" server --address="[::1]:9001" >"$WORK_DIR/pool-minio-ipv6-9001.log" 2>&1 & 69 70 sleep 40 71 } 72 73 function start_minio_dist_erasure() { 74 export MINIO_ROOT_USER=$ACCESS_KEY 75 export MINIO_ROOT_PASSWORD=$SECRET_KEY 76 export MINIO_ENDPOINTS="http://127.0.0.1:9000${WORK_DIR}/dist-disk1 http://127.0.0.1:9001${WORK_DIR}/dist-disk2 http://127.0.0.1:9002${WORK_DIR}/dist-disk3 http://127.0.0.1:9003${WORK_DIR}/dist-disk4" 77 for i in $(seq 0 3); do 78 "${MINIO[@]}" server --address ":900${i}" >"$WORK_DIR/dist-minio-900${i}.log" 2>&1 & 79 done 80 81 sleep 40 82 } 83 84 function run_test_fs() { 85 start_minio_fs 86 87 (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS") 88 rv=$? 89 90 pkill minio 91 sleep 3 92 93 if [ "$rv" -ne 0 ]; then 94 cat "$WORK_DIR/fs-minio.log" 95 fi 96 rm -f "$WORK_DIR/fs-minio.log" 97 98 return "$rv" 99 } 100 101 function run_test_erasure_sets() { 102 start_minio_erasure_sets 103 104 (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS") 105 rv=$? 106 107 pkill minio 108 sleep 3 109 110 if [ "$rv" -ne 0 ]; then 111 cat "$WORK_DIR/erasure-minio-sets.log" 112 fi 113 rm -f "$WORK_DIR/erasure-minio-sets.log" 114 115 return "$rv" 116 } 117 118 function run_test_pool_erasure_sets() { 119 start_minio_pool_erasure_sets 120 121 (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS") 122 rv=$? 123 124 pkill minio 125 sleep 3 126 127 if [ "$rv" -ne 0 ]; then 128 for i in $(seq 0 1); do 129 echo "server$i log:" 130 cat "$WORK_DIR/pool-minio-900$i.log" 131 done 132 fi 133 134 for i in $(seq 0 1); do 135 rm -f "$WORK_DIR/pool-minio-900$i.log" 136 done 137 138 return "$rv" 139 } 140 141 function run_test_pool_erasure_sets_ipv6() { 142 start_minio_pool_erasure_sets_ipv6 143 144 export SERVER_ENDPOINT="[::1]:9000" 145 146 (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS") 147 rv=$? 148 149 pkill minio 150 sleep 3 151 152 if [ "$rv" -ne 0 ]; then 153 for i in $(seq 0 1); do 154 echo "server$i log:" 155 cat "$WORK_DIR/pool-minio-ipv6-900$i.log" 156 done 157 fi 158 159 for i in $(seq 0 1); do 160 rm -f "$WORK_DIR/pool-minio-ipv6-900$i.log" 161 done 162 163 return "$rv" 164 } 165 166 function run_test_erasure() { 167 start_minio_erasure 168 169 (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS") 170 rv=$? 171 172 pkill minio 173 sleep 3 174 175 if [ "$rv" -ne 0 ]; then 176 cat "$WORK_DIR/erasure-minio.log" 177 fi 178 rm -f "$WORK_DIR/erasure-minio.log" 179 180 return "$rv" 181 } 182 183 function run_test_dist_erasure() { 184 start_minio_dist_erasure 185 186 (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS") 187 rv=$? 188 189 pkill minio 190 sleep 3 191 192 if [ "$rv" -ne 0 ]; then 193 echo "server1 log:" 194 cat "$WORK_DIR/dist-minio-9000.log" 195 echo "server2 log:" 196 cat "$WORK_DIR/dist-minio-9001.log" 197 echo "server3 log:" 198 cat "$WORK_DIR/dist-minio-9002.log" 199 echo "server4 log:" 200 cat "$WORK_DIR/dist-minio-9003.log" 201 fi 202 203 rm -f "$WORK_DIR/dist-minio-9000.log" "$WORK_DIR/dist-minio-9001.log" "$WORK_DIR/dist-minio-9002.log" "$WORK_DIR/dist-minio-9003.log" 204 205 return "$rv" 206 } 207 208 function purge() { 209 rm -rf "$1" 210 } 211 212 function __init__() { 213 echo "Initializing environment" 214 mkdir -p "$WORK_DIR" 215 mkdir -p "$MINIO_CONFIG_DIR" 216 mkdir -p "$MINT_DATA_DIR" 217 218 MC_BUILD_DIR="mc-$RANDOM" 219 if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then 220 echo "failed to download https://github.com/minio/mc" 221 purge "${MC_BUILD_DIR}" 222 exit 1 223 fi 224 225 (cd "${MC_BUILD_DIR}" && go build -o "$WORK_DIR/mc") 226 227 # remove mc source. 228 purge "${MC_BUILD_DIR}" 229 230 shred -n 1 -s 1M - 1>"$FILE_1_MB" 2>/dev/null 231 shred -n 1 -s 65M - 1>"$FILE_65_MB" 2>/dev/null 232 233 ## version is purposefully set to '3' for minio to migrate configuration file 234 echo '{"version": "3", "credential": {"accessKey": "minio", "secretKey": "minio123"}, "region": "us-east-1"}' >"$MINIO_CONFIG_DIR/config.json" 235 236 if ! wget -q -O "$FUNCTIONAL_TESTS" https://raw.githubusercontent.com/minio/mc/master/functional-tests.sh; then 237 echo "failed to download https://raw.githubusercontent.com/minio/mc/master/functional-tests.sh" 238 exit 1 239 fi 240 241 sed -i 's|-sS|-sSg|g' "$FUNCTIONAL_TESTS" 242 chmod a+x "$FUNCTIONAL_TESTS" 243 } 244 245 function main() { 246 echo "Testing in FS setup" 247 if ! run_test_fs; then 248 echo "FAILED" 249 purge "$WORK_DIR" 250 exit 1 251 fi 252 253 echo "Testing in Erasure setup" 254 if ! run_test_erasure; then 255 echo "FAILED" 256 purge "$WORK_DIR" 257 exit 1 258 fi 259 260 echo "Testing in Distributed Erasure setup" 261 if ! run_test_dist_erasure; then 262 echo "FAILED" 263 purge "$WORK_DIR" 264 exit 1 265 fi 266 267 echo "Testing in Erasure setup as sets" 268 if ! run_test_erasure_sets; then 269 echo "FAILED" 270 purge "$WORK_DIR" 271 exit 1 272 fi 273 274 echo "Testing in Distributed Eraure expanded setup" 275 if ! run_test_pool_erasure_sets; then 276 echo "FAILED" 277 purge "$WORK_DIR" 278 exit 1 279 fi 280 281 echo "Testing in Distributed Erasure expanded setup with ipv6" 282 if ! run_test_pool_erasure_sets_ipv6; then 283 echo "FAILED" 284 purge "$WORK_DIR" 285 exit 1 286 fi 287 288 purge "$WORK_DIR" 289 } 290 291 (__init__ "$@" && main "$@") 292 rv=$? 293 purge "$WORK_DIR" 294 exit "$rv"