github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/docs/bucket/replication/delete-replication.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  echo "Running $0"
     4  
     5  if [ -n "$TEST_DEBUG" ]; then
     6  	set -x
     7  fi
     8  
     9  trap 'catch $LINENO' ERR
    10  
    11  # shellcheck disable=SC2120
    12  catch() {
    13  	if [ $# -ne 0 ]; then
    14  		echo "error on line $1"
    15  		echo "dc1 server logs ========="
    16  		cat /tmp/dc1.log
    17  		echo "dc2 server logs ========="
    18  		cat /tmp/dc2.log
    19  	fi
    20  
    21  	echo "Cleaning up instances of MinIO"
    22  	set +e
    23  	pkill minio
    24  	pkill mc
    25  	rm -rf /tmp/xl/
    26  }
    27  
    28  catch
    29  
    30  set -e
    31  export MINIO_CI_CD=1
    32  export MINIO_BROWSER=off
    33  export MINIO_ROOT_USER="minio"
    34  export MINIO_ROOT_PASSWORD="minio123"
    35  export MINIO_KMS_AUTO_ENCRYPTION=off
    36  export MINIO_PROMETHEUS_AUTH_TYPE=public
    37  export MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw=
    38  unset MINIO_KMS_KES_CERT_FILE
    39  unset MINIO_KMS_KES_KEY_FILE
    40  unset MINIO_KMS_KES_ENDPOINT
    41  unset MINIO_KMS_KES_KEY_NAME
    42  
    43  if [ ! -f ./mc ]; then
    44  	wget --quiet -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc &&
    45  		chmod +x mc
    46  fi
    47  
    48  mkdir -p /tmp/xl/1/ /tmp/xl/2/
    49  
    50  export MINIO_KMS_SECRET_KEY="my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
    51  export MINIO_ROOT_USER="minioadmin"
    52  export MINIO_ROOT_PASSWORD="minioadmin"
    53  
    54  ./minio server --address ":9001" /tmp/xl/1/{1...4}/ 2>&1 >/tmp/dc1.log &
    55  ./minio server --address ":9002" /tmp/xl/2/{1...4}/ 2>&1 >/tmp/dc2.log &
    56  
    57  sleep 3
    58  
    59  export MC_HOST_myminio1=http://minioadmin:minioadmin@localhost:9001
    60  export MC_HOST_myminio2=http://minioadmin:minioadmin@localhost:9002
    61  
    62  ./mc mb myminio1/testbucket/
    63  ./mc version enable myminio1/testbucket/
    64  ./mc mb myminio2/testbucket/
    65  ./mc version enable myminio2/testbucket/
    66  
    67  ./mc replicate add myminio1/testbucket --remote-bucket http://minioadmin:minioadmin@localhost:9002/testbucket/ --priority 1
    68  
    69  ./mc cp README.md myminio1/testbucket/dir/file
    70  ./mc cp README.md myminio1/testbucket/dir/file
    71  
    72  sleep 1s
    73  
    74  echo "=== myminio1"
    75  ./mc ls --versions myminio1/testbucket/dir/file
    76  
    77  echo "=== myminio2"
    78  ./mc ls --versions myminio2/testbucket/dir/file
    79  
    80  versionId="$(./mc ls --json --versions myminio1/testbucket/dir/ | tail -n1 | jq -r .versionId)"
    81  
    82  aws configure set aws_access_key_id minioadmin --profile minioadmin
    83  aws configure set aws_secret_access_key minioadmin --profile minioadmin
    84  aws configure set default.region us-east-1 --profile minioadmin
    85  
    86  aws s3api --endpoint-url http://localhost:9001 --profile minioadmin delete-object --bucket testbucket --key dir/file --version-id "$versionId"
    87  
    88  ./mc ls -r --versions myminio1/testbucket >/tmp/myminio1.txt
    89  ./mc ls -r --versions myminio2/testbucket >/tmp/myminio2.txt
    90  
    91  out=$(diff -qpruN /tmp/myminio1.txt /tmp/myminio2.txt)
    92  ret=$?
    93  if [ $ret -ne 0 ]; then
    94  	echo "BUG: expected no missing entries after replication: $out"
    95  	exit 1
    96  fi
    97  
    98  ./mc rm myminio1/testbucket/dir/file
    99  sleep 1s
   100  
   101  ./mc ls -r --versions myminio1/testbucket >/tmp/myminio1.txt
   102  ./mc ls -r --versions myminio2/testbucket >/tmp/myminio2.txt
   103  
   104  out=$(diff -qpruN /tmp/myminio1.txt /tmp/myminio2.txt)
   105  ret=$?
   106  if [ $ret -ne 0 ]; then
   107  	echo "BUG: expected no missing entries after replication: $out"
   108  	exit 1
   109  fi
   110  
   111  echo "Success"
   112  catch