github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/docs/distributed/decom-encrypted.sh (about) 1 #!/bin/bash 2 3 if [ -n "$TEST_DEBUG" ]; then 4 set -x 5 fi 6 7 pkill minio 8 rm -rf /tmp/xl 9 10 if [ ! -f ./mc ]; then 11 wget --quiet -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc && 12 chmod +x mc 13 fi 14 15 export CI=true 16 export MINIO_KMS_AUTO_ENCRYPTION=on 17 export MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= 18 19 (minio server http://localhost:9000/tmp/xl/{1...10}/disk{0...1} 2>&1 >/dev/null) & 20 pid=$! 21 22 sleep 30 23 24 export MC_HOST_myminio="http://minioadmin:minioadmin@localhost:9000/" 25 26 ./mc admin user add myminio/ minio123 minio123 27 ./mc admin user add myminio/ minio12345 minio12345 28 29 ./mc admin policy create myminio/ rw ./docs/distributed/rw.json 30 ./mc admin policy create myminio/ lake ./docs/distributed/rw.json 31 32 ./mc admin policy attach myminio/ rw --user=minio123 33 ./mc admin policy attach myminio/ lake --user=minio12345 34 35 ./mc mb -l myminio/versioned 36 37 ./mc mirror internal myminio/versioned/ --quiet >/dev/null 38 39 ## Soft delete (creates delete markers) 40 ./mc rm -r --force myminio/versioned >/dev/null 41 42 ## mirror again to create another set of version on top 43 ./mc mirror internal myminio/versioned/ --quiet >/dev/null 44 45 expected_checksum=$(./mc cat internal/dsync/drwmutex.go | md5sum) 46 47 user_count=$(./mc admin user list myminio/ | wc -l) 48 policy_count=$(./mc admin policy list myminio/ | wc -l) 49 50 kill $pid 51 52 (minio server http://localhost:9000/tmp/xl/{1...10}/disk{0...1} http://localhost:9001/tmp/xl/{11...30}/disk{0...3} 2>&1 >/tmp/expanded_1.log) & 53 pid_1=$! 54 55 (minio server --address ":9001" http://localhost:9000/tmp/xl/{1...10}/disk{0...1} http://localhost:9001/tmp/xl/{11...30}/disk{0...3} 2>&1 >/tmp/expanded_2.log) & 56 pid_2=$! 57 58 sleep 30 59 60 expanded_user_count=$(./mc admin user list myminio/ | wc -l) 61 expanded_policy_count=$(./mc admin policy list myminio/ | wc -l) 62 63 if [ $user_count -ne $expanded_user_count ]; then 64 echo "BUG: original user count differs from expanded setup" 65 exit 1 66 fi 67 68 if [ $policy_count -ne $expanded_policy_count ]; then 69 echo "BUG: original policy count differs from expanded setup" 70 exit 1 71 fi 72 73 ./mc version info myminio/versioned | grep -q "versioning is enabled" 74 ret=$? 75 if [ $ret -ne 0 ]; then 76 echo "expected versioning enabled after expansion" 77 exit 1 78 fi 79 80 ./mc mirror cmd myminio/versioned/ --quiet >/dev/null 81 82 ./mc ls -r myminio/versioned/ >expanded_ns.txt 83 ./mc ls -r --versions myminio/versioned/ >expanded_ns_versions.txt 84 85 ./mc admin decom start myminio/ http://localhost:9000/tmp/xl/{1...10}/disk{0...1} 86 87 until $(./mc admin decom status myminio/ | grep -q Complete); do 88 echo "waiting for decom to finish..." 89 sleep 1 90 done 91 92 kill $pid_1 93 kill $pid_2 94 95 sleep 5 96 97 (minio server --address ":9001" http://localhost:9001/tmp/xl/{11...30}/disk{0...3} 2>&1 >/tmp/removed.log) & 98 pid=$! 99 100 sleep 30 101 102 export MC_HOST_myminio="http://minioadmin:minioadmin@localhost:9001/" 103 104 decom_user_count=$(./mc admin user list myminio/ | wc -l) 105 decom_policy_count=$(./mc admin policy list myminio/ | wc -l) 106 107 if [ $user_count -ne $decom_user_count ]; then 108 echo "BUG: original user count differs after decommission" 109 exit 1 110 fi 111 112 if [ $policy_count -ne $decom_policy_count ]; then 113 echo "BUG: original policy count differs after decommission" 114 exit 1 115 fi 116 117 ./mc version info myminio/versioned | grep -q "versioning is enabled" 118 ret=$? 119 if [ $ret -ne 0 ]; then 120 echo "BUG: expected versioning enabled after decommission" 121 exit 1 122 fi 123 124 ./mc ls -r myminio/versioned >decommissioned_ns.txt 125 ./mc ls -r --versions myminio/versioned >decommissioned_ns_versions.txt 126 127 out=$(diff -qpruN expanded_ns.txt decommissioned_ns.txt) 128 ret=$? 129 if [ $ret -ne 0 ]; then 130 echo "BUG: expected no missing entries after decommission: $out" 131 exit 1 132 fi 133 134 out=$(diff -qpruN expanded_ns_versions.txt decommissioned_ns_versions.txt) 135 ret=$? 136 if [ $ret -ne 0 ]; then 137 echo "BUG: expected no missing entries after decommission: $out" 138 exit 1 139 fi 140 141 got_checksum=$(./mc cat myminio/versioned/dsync/drwmutex.go | md5sum) 142 if [ "${expected_checksum}" != "${got_checksum}" ]; then 143 echo "BUG: decommission failed on encrypted objects: expected ${expected_checksum} got ${got_checksum}" 144 exit 1 145 fi 146 147 ( 148 cd ./docs/debugging/s3-check-md5 149 go install -v 150 ) 151 152 s3-check-md5 -versions -access-key minioadmin -secret-key minioadmin -endpoint http://127.0.0.1:9001/ -bucket versioned 153 154 kill $pid