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