2022-12-29 01:48:33 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-03-04 13:05:56 -05:00
|
|
|
echo "Running $0"
|
|
|
|
|
2022-12-29 01:48:33 -05:00
|
|
|
if [ -n "$TEST_DEBUG" ]; then
|
2023-05-26 01:07:25 -04:00
|
|
|
set -x
|
2022-12-29 01:48:33 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
trap 'catch $LINENO' ERR
|
|
|
|
|
|
|
|
# shellcheck disable=SC2120
|
|
|
|
catch() {
|
2023-05-26 01:07:25 -04:00
|
|
|
if [ $# -ne 0 ]; then
|
|
|
|
echo "error on line $1"
|
|
|
|
echo "dc1 server logs ========="
|
|
|
|
cat /tmp/dc1.log
|
|
|
|
echo "dc2 server logs ========="
|
|
|
|
cat /tmp/dc2.log
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Cleaning up instances of MinIO"
|
|
|
|
set +e
|
|
|
|
pkill minio
|
|
|
|
pkill mc
|
|
|
|
rm -rf /tmp/xl/
|
2022-12-29 01:48:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
catch
|
|
|
|
|
|
|
|
set -e
|
|
|
|
export MINIO_CI_CD=1
|
|
|
|
export MINIO_BROWSER=off
|
|
|
|
export MINIO_ROOT_USER="minio"
|
|
|
|
export MINIO_ROOT_PASSWORD="minio123"
|
|
|
|
export MINIO_KMS_AUTO_ENCRYPTION=off
|
|
|
|
export MINIO_PROMETHEUS_AUTH_TYPE=public
|
|
|
|
export MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw=
|
|
|
|
unset MINIO_KMS_KES_CERT_FILE
|
|
|
|
unset MINIO_KMS_KES_KEY_FILE
|
|
|
|
unset MINIO_KMS_KES_ENDPOINT
|
|
|
|
unset MINIO_KMS_KES_KEY_NAME
|
|
|
|
|
|
|
|
if [ ! -f ./mc ]; then
|
2023-05-26 01:07:25 -04:00
|
|
|
wget --quiet -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc &&
|
|
|
|
chmod +x mc
|
2022-12-29 01:48:33 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p /tmp/xl/1/ /tmp/xl/2/
|
|
|
|
|
|
|
|
export MINIO_KMS_SECRET_KEY="my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
|
|
|
|
export MINIO_ROOT_USER="minioadmin"
|
|
|
|
export MINIO_ROOT_PASSWORD="minioadmin"
|
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
./minio server --address ":9001" /tmp/xl/1/{1...4}/ 2>&1 >/tmp/dc1.log &
|
|
|
|
./minio server --address ":9002" /tmp/xl/2/{1...4}/ 2>&1 >/tmp/dc2.log &
|
2022-12-29 01:48:33 -05:00
|
|
|
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
export MC_HOST_myminio1=http://minioadmin:minioadmin@localhost:9001
|
|
|
|
export MC_HOST_myminio2=http://minioadmin:minioadmin@localhost:9002
|
|
|
|
|
|
|
|
./mc mb myminio1/testbucket/
|
|
|
|
./mc version enable myminio1/testbucket/
|
|
|
|
./mc mb myminio2/testbucket/
|
|
|
|
./mc version enable myminio2/testbucket/
|
|
|
|
|
2023-01-04 01:54:39 -05:00
|
|
|
./mc replicate add myminio1/testbucket --remote-bucket http://minioadmin:minioadmin@localhost:9002/testbucket/ --priority 1
|
2022-12-29 01:48:33 -05:00
|
|
|
|
|
|
|
./mc cp README.md myminio1/testbucket/dir/file
|
|
|
|
./mc cp README.md myminio1/testbucket/dir/file
|
|
|
|
|
|
|
|
sleep 1s
|
|
|
|
|
|
|
|
echo "=== myminio1"
|
|
|
|
./mc ls --versions myminio1/testbucket/dir/file
|
|
|
|
|
|
|
|
echo "=== myminio2"
|
|
|
|
./mc ls --versions myminio2/testbucket/dir/file
|
|
|
|
|
2024-02-16 20:15:57 -05:00
|
|
|
versionId="$(./mc ls --json --versions myminio1/testbucket/dir/ | tail -n1 | jq -r .versionId)"
|
2022-12-29 01:48:33 -05:00
|
|
|
|
2024-02-16 20:15:57 -05:00
|
|
|
aws configure set aws_access_key_id minioadmin --profile minioadmin
|
|
|
|
aws configure set aws_secret_access_key minioadmin --profile minioadmin
|
|
|
|
aws configure set default.region us-east-1 --profile minioadmin
|
|
|
|
|
|
|
|
aws s3api --endpoint-url http://localhost:9001 --profile minioadmin delete-object --bucket testbucket --key dir/file --version-id "$versionId"
|
2022-12-29 01:48:33 -05:00
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
./mc ls -r --versions myminio1/testbucket >/tmp/myminio1.txt
|
|
|
|
./mc ls -r --versions myminio2/testbucket >/tmp/myminio2.txt
|
2022-12-29 01:48:33 -05:00
|
|
|
|
|
|
|
out=$(diff -qpruN /tmp/myminio1.txt /tmp/myminio2.txt)
|
|
|
|
ret=$?
|
|
|
|
if [ $ret -ne 0 ]; then
|
2023-05-26 01:07:25 -04:00
|
|
|
echo "BUG: expected no missing entries after replication: $out"
|
|
|
|
exit 1
|
2022-12-29 01:48:33 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
./mc rm myminio1/testbucket/dir/file
|
|
|
|
sleep 1s
|
|
|
|
|
2023-05-26 01:07:25 -04:00
|
|
|
./mc ls -r --versions myminio1/testbucket >/tmp/myminio1.txt
|
|
|
|
./mc ls -r --versions myminio2/testbucket >/tmp/myminio2.txt
|
2022-12-29 01:48:33 -05:00
|
|
|
|
|
|
|
out=$(diff -qpruN /tmp/myminio1.txt /tmp/myminio2.txt)
|
|
|
|
ret=$?
|
|
|
|
if [ $ret -ne 0 ]; then
|
2023-05-26 01:07:25 -04:00
|
|
|
echo "BUG: expected no missing entries after replication: $out"
|
|
|
|
exit 1
|
2022-12-29 01:48:33 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Success"
|
|
|
|
catch
|