github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/demand-backup/run (about)

     1  #!/bin/bash
     2  
     3  set -o errexit
     4  
     5  test_dir=$(realpath $(dirname $0))
     6  . ${test_dir}/../functions
     7  
     8  set_debug
     9  
    10  main() {
    11  	create_infra $namespace
    12  
    13  	cluster="demand-backup"
    14  	spinup_pxc "$cluster" "$test_dir/conf/$cluster.yml"
    15  
    16  	# We are using minio with tls enabled to check if `verifyTLS: false` works fine
    17  	start_minio "demand-backup-ssl"
    18  
    19  	run_backup "$cluster" "on-demand-backup-pvc"
    20  	run_recovery_check "$cluster" "on-demand-backup-pvc"
    21  	check_pvc_md5
    22  
    23  	run_backup "$cluster" "on-demand-backup-pvc-bsource"
    24  	run_recovery_check "$cluster" "on-demand-backup-pvc-bsource"
    25  
    26  	run_backup "$cluster" "on-demand-backup-minio"
    27  	compare_kubectl job/xb-on-demand-backup-minio
    28  	backup_job_name=$(kubectl get pod -l job-name=xb-on-demand-backup-minio -o jsonpath='{.items[].metadata.name}')
    29  	kubectl logs "$backup_job_name" | egrep "xbcloud put --storage=s3 --parallel=[0-9]+ --md5 --insecure (--curl-retriable-errors=7 )?--parallel=2 --curl-retriable-errors=8"
    30  	kubectl logs "$backup_job_name" | grep "xbstream -x -C /tmp --parallel=2"
    31  
    32  	new_pass=$(echo -n "newpass" | base64)
    33  	kubectl_bin patch secret my-cluster-secrets -p="{\"data\":{\"xtrabackup\": \"${new_pass}\", \"monitor\": \"${new_pass}\"}}"
    34  	wait_cluster_consistency ${cluster} 3 2
    35  
    36  	compare_kubectl secret/${cluster}-mysql-init
    37  
    38  	run_recovery_check "$cluster" "on-demand-backup-minio"
    39  	compare_kubectl job/restore-job-on-demand-backup-minio-demand-backup
    40  	restore_job_name=$(kubectl get pod -l job-name=restore-job-on-demand-backup-minio-demand-backup -o jsonpath='{.items[].metadata.name}')
    41  	kubectl logs "$restore_job_name" | grep "xtrabackup --defaults-group=mysqld --datadir=/datadir --move-back --parallel=3"
    42  	kubectl logs "$restore_job_name" | grep "xtrabackup --use-memory=1500000000 --prepare --parallel=3"
    43  	kubectl logs "$restore_job_name" | egrep "xbcloud get --parallel=[0-9]+ --insecure (--curl-retriable-errors=7 )?--parallel=3"
    44  	kubectl logs "$restore_job_name" | egrep "xbstream -x -C .* --parallel=[0-9]+ --parallel=3"
    45  	kubectl logs "$restore_job_name" | egrep "(xbstream --decompress -x -C .* --parallel=[0-9]+ --parallel=3|xbstream -x -C .* --parallel=4 --parallel=3)"
    46  
    47  	desc "Check backup deletion"
    48  	kubectl_bin delete pxc-backup --all
    49  	backup_exists=$(
    50  		kubectl_bin run -n "${NAMESPACE}" -i --rm aws-cli --image=perconalab/awscli --restart=Never -- \
    51  			/usr/bin/env AWS_ACCESS_KEY_ID=some-access-key AWS_SECRET_ACCESS_KEY=some-secret-key AWS_DEFAULT_REGION=us-east-1 \
    52  			/usr/bin/aws --endpoint-url https://minio-service:9000 --no-verify-ssl s3 ls operator-testing/ | grep -c "demand-backup" | cat
    53  		exit "${PIPESTATUS[0]}"
    54  	)
    55  	if [[ $backup_exists -ne 0 ]]; then
    56  		echo "Backup was not removed from bucket -- minio"
    57  		exit 1
    58  	fi
    59  
    60  	destroy $namespace
    61  	desc "test passed"
    62  
    63  }
    64  
    65  main