mirror of
https://github.com/minio/minio.git
synced 2025-11-10 05:59:43 -05:00
cleanup scripts and apply shfmt (#17284)
This commit is contained in:
@@ -2,23 +2,23 @@
|
||||
|
||||
# shellcheck disable=SC2120
|
||||
exit_1() {
|
||||
cleanup
|
||||
cleanup
|
||||
|
||||
echo "minio1 ============"
|
||||
cat /tmp/minio1_1.log
|
||||
echo "minio2 ============"
|
||||
cat /tmp/minio2_1.log
|
||||
echo "minio3 ============"
|
||||
cat /tmp/minio3_1.log
|
||||
echo "minio1 ============"
|
||||
cat /tmp/minio1_1.log
|
||||
echo "minio2 ============"
|
||||
cat /tmp/minio2_1.log
|
||||
echo "minio3 ============"
|
||||
cat /tmp/minio3_1.log
|
||||
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up instances of MinIO"
|
||||
pkill minio
|
||||
pkill -9 minio
|
||||
rm -rf /tmp/minio{1,2,3}
|
||||
echo "Cleaning up instances of MinIO"
|
||||
pkill minio
|
||||
pkill -9 minio
|
||||
rm -rf /tmp/minio{1,2,3}
|
||||
}
|
||||
|
||||
cleanup
|
||||
@@ -53,8 +53,8 @@ minio server --address ":9003" --console-address ":12000" /tmp/minio3/{1...4} >/
|
||||
site3_pid=$!
|
||||
|
||||
if [ ! -f ./mc ]; then
|
||||
wget -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc \
|
||||
&& chmod +x mc
|
||||
wget -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc &&
|
||||
chmod +x mc
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
@@ -70,13 +70,13 @@ sleep 5
|
||||
|
||||
./mc admin policy info minio2 projecta >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting the command to succeed, exiting.."
|
||||
exit_1;
|
||||
echo "expecting the command to succeed, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
./mc admin policy info minio3 projecta >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting the command to succeed, exiting.."
|
||||
exit_1;
|
||||
echo "expecting the command to succeed, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc admin policy remove minio3 projecta
|
||||
@@ -84,14 +84,14 @@ fi
|
||||
sleep 10
|
||||
./mc admin policy info minio1 projecta
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "expecting the command to fail, exiting.."
|
||||
exit_1;
|
||||
echo "expecting the command to fail, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc admin policy info minio2 projecta
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "expecting the command to fail, exiting.."
|
||||
exit_1;
|
||||
echo "expecting the command to fail, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc admin policy create minio1 projecta ./docs/site-replication/rw.json
|
||||
@@ -102,8 +102,8 @@ STS_CRED=$(MINIO_ENDPOINT=http://localhost:9001 go run ./docs/site-replication/g
|
||||
|
||||
MC_HOST_foo=http://${STS_CRED}@localhost:9001 ./mc ls foo
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Expected sts credential to work, exiting.."
|
||||
exit_1;
|
||||
echo "Expected sts credential to work, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
@@ -111,14 +111,14 @@ sleep 2
|
||||
# Check that the STS credential works on minio2 and minio3.
|
||||
MC_HOST_foo=http://${STS_CRED}@localhost:9002 ./mc ls foo
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Expected sts credential to work, exiting.."
|
||||
exit_1;
|
||||
echo "Expected sts credential to work, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
MC_HOST_foo=http://${STS_CRED}@localhost:9003 ./mc ls foo
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Expected sts credential to work, exiting.."
|
||||
exit_1;
|
||||
echo "Expected sts credential to work, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
STS_ACCESS_KEY=$(echo ${STS_CRED} | cut -d ':' -f 1)
|
||||
@@ -126,41 +126,41 @@ STS_ACCESS_KEY=$(echo ${STS_CRED} | cut -d ':' -f 1)
|
||||
# Create service account for STS user
|
||||
./mc admin user svcacct add minio2 $STS_ACCESS_KEY --access-key testsvc --secret-key testsvc123
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "adding svc account failed, exiting.."
|
||||
exit_1;
|
||||
echo "adding svc account failed, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
|
||||
./mc admin user svcacct info minio1 testsvc
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "svc account not mirrored, exiting.."
|
||||
exit_1;
|
||||
echo "svc account not mirrored, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc admin user svcacct info minio2 testsvc
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "svc account not mirrored, exiting.."
|
||||
exit_1;
|
||||
echo "svc account not mirrored, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc admin user svcacct rm minio1 testsvc
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "removing svc account failed, exiting.."
|
||||
exit_1;
|
||||
echo "removing svc account failed, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
./mc admin user svcacct info minio2 testsvc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "svc account found after delete, exiting.."
|
||||
exit_1;
|
||||
echo "svc account found after delete, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc admin user svcacct info minio3 testsvc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "svc account found after delete, exiting.."
|
||||
exit_1;
|
||||
echo "svc account found after delete, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
# create a bucket bucket2 on minio1.
|
||||
@@ -176,14 +176,14 @@ expected_checksum=$(cat ./lrgfile | md5sum)
|
||||
sleep 5
|
||||
./mc stat minio2/newbucket
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting bucket to be present. exiting.."
|
||||
exit_1;
|
||||
echo "expecting bucket to be present. exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc stat minio3/newbucket
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting bucket to be present. exiting.."
|
||||
exit_1;
|
||||
echo "expecting bucket to be present. exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc cp README.md minio2/newbucket/
|
||||
@@ -191,14 +191,14 @@ fi
|
||||
sleep 5
|
||||
./mc stat minio1/newbucket/README.md
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting object to be present. exiting.."
|
||||
exit_1;
|
||||
echo "expecting object to be present. exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc stat minio3/newbucket/README.md
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting object to be present. exiting.."
|
||||
exit_1;
|
||||
echo "expecting object to be present. exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc rm minio3/newbucket/README.md
|
||||
@@ -206,66 +206,66 @@ sleep 5
|
||||
|
||||
./mc stat minio2/newbucket/README.md
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "expected file to be deleted, exiting.."
|
||||
exit_1;
|
||||
echo "expected file to be deleted, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
./mc stat minio1/newbucket/README.md
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "expected file to be deleted, exiting.."
|
||||
exit_1;
|
||||
echo "expected file to be deleted, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
./mc stat minio3/newbucket/lrgfile
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expected object to be present, exiting.."
|
||||
exit_1;
|
||||
echo "expected object to be present, exiting.."
|
||||
exit_1
|
||||
fi
|
||||
actual_checksum=$(./mc cat minio3/newbucket/lrgfile | md5sum)
|
||||
if [ "${expected_checksum}" != "${actual_checksum}" ]; then
|
||||
echo "replication failed on multipart objects expected ${expected_checksum} got ${actual_checksum}"
|
||||
exit
|
||||
echo "replication failed on multipart objects expected ${expected_checksum} got ${actual_checksum}"
|
||||
exit
|
||||
fi
|
||||
rm ./lrgfile
|
||||
|
||||
./mc mb --with-lock minio3/newbucket-olock
|
||||
sleep 5
|
||||
|
||||
enabled_minio2=$(./mc stat --json minio2/newbucket-olock| jq -r .ObjectLock.enabled)
|
||||
enabled_minio2=$(./mc stat --json minio2/newbucket-olock | jq -r .ObjectLock.enabled)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expected bucket to be mirrored with object-lock but not present, exiting..."
|
||||
exit_1;
|
||||
echo "expected bucket to be mirrored with object-lock but not present, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
if [ "${enabled_minio2}" != "Enabled" ]; then
|
||||
echo "expected bucket to be mirrored with object-lock enabled, exiting..."
|
||||
exit_1;
|
||||
echo "expected bucket to be mirrored with object-lock enabled, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
enabled_minio1=$(./mc stat --json minio1/newbucket-olock| jq -r .ObjectLock.enabled)
|
||||
enabled_minio1=$(./mc stat --json minio1/newbucket-olock | jq -r .ObjectLock.enabled)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expected bucket to be mirrored with object-lock but not present, exiting..."
|
||||
exit_1;
|
||||
echo "expected bucket to be mirrored with object-lock but not present, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
if [ "${enabled_minio1}" != "Enabled" ]; then
|
||||
echo "expected bucket to be mirrored with object-lock enabled, exiting..."
|
||||
exit_1;
|
||||
echo "expected bucket to be mirrored with object-lock enabled, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
# "Test if most recent tag update is replicated"
|
||||
./mc tag set minio2/newbucket "key=val1"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expecting tag set to be successful. exiting.."
|
||||
exit_1;
|
||||
echo "expecting tag set to be successful. exiting.."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
val=$(./mc tag list minio1/newbucket --json | jq -r .tagset | jq -r .key)
|
||||
if [ "${val}" != "val1" ]; then
|
||||
echo "expected bucket tag to have replicated, exiting..."
|
||||
exit_1;
|
||||
echo "expected bucket tag to have replicated, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
# stop minio1 instance
|
||||
kill -9 ${site1_pid}
|
||||
@@ -281,15 +281,15 @@ minio server --address ":9001" --console-address ":10000" /tmp/minio1/{1...4} >/
|
||||
sleep 200
|
||||
|
||||
# Test whether most recent tag update on minio2 is replicated to minio1
|
||||
val=$(./mc tag list minio1/newbucket --json | jq -r .tagset | jq -r .key )
|
||||
val=$(./mc tag list minio1/newbucket --json | jq -r .tagset | jq -r .key)
|
||||
if [ "${val}" != "val2" ]; then
|
||||
echo "expected bucket tag to have replicated, exiting..."
|
||||
exit_1;
|
||||
echo "expected bucket tag to have replicated, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
# Test if bucket created/deleted when minio1 is down healed
|
||||
diff -q <(./mc ls minio1) <(./mc ls minio2) 1>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expected 'bucket2' delete and 'newbucket2' creation to have replicated, exiting..."
|
||||
exit_1;
|
||||
diff -q <(./mc ls minio1) <(./mc ls minio2) 1>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "expected 'bucket2' delete and 'newbucket2' creation to have replicated, exiting..."
|
||||
exit_1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user