github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/init-deploy/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 create_infra $namespace 11 deploy_cert_manager 12 13 desc 'create first PXC cluster' 14 cluster="some-name" 15 spinup_pxc "$cluster" "$conf_dir/$cluster.yml" "3" "10" "${conf_dir}/secrets_without_tls.yml" 16 17 desc 'check if cert-manager issued ssl certificates' 18 if [ "$(kubectl get secrets ${cluster}-ssl -o jsonpath='{.metadata.annotations.cert-manager\.io/issuer-kind}')" != "Issuer" ]; then 19 echo "Cert manager didn't create the ssl certificates! Something went wrong." 20 exit 1 21 fi 22 23 desc 'check if service and statefulset created with expected config' 24 compare_kubectl statefulset/$cluster-pxc 25 compare_kubectl statefulset/$cluster-proxysql 26 compare_kubectl service/$cluster-pxc 27 compare_kubectl service/$cluster-proxysql 28 compare_kubectl service/$cluster-proxysql-unready 29 30 desc 'check PodDisruptionBudget' 31 compare_kubectl pdb/$cluster-pxc 32 compare_kubectl pdb/$cluster-proxysql 33 34 desc 'check if MySQL users created' 35 compare_mysql_user "-h $cluster-pxc -uroot -proot_password" 36 compare_mysql_user "-h $cluster-pxc -umonitor -pmonitor_password" 37 compare_mysql_user "-h $cluster-pxc -uproxyuser -ps3cret" 38 compare_mysql_user_local "-uxtrabackup -pbackup_password" "$cluster-pxc-0" "" "pxc" 39 desc "check that pmm server user don't have access" 40 compare_mysql_user "-h $cluster-pxc -upmmserver -ppmmserver_password" 41 42 desc 'check if ProxySQL users created' 43 compare_mysql_user "-h $cluster-proxysql -uroot -proot_password" 44 compare_mysql_user "-h $cluster-proxysql -umonitor -pmonitor_password" 45 desc "check that pmm server user don't have access" 46 compare_mysql_user "-h $cluster-proxysql -uproxyuser -ps3cret" "-proxysql" 47 compare_mysql_user "-h $cluster-proxysql -upmmserver -ppmmserver_password" "-proxysql" 48 49 desc 'write data directly, read from all' 50 run_mysql \ 51 'INSERT myApp.myApp (id) VALUES (100501)' \ 52 "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password" 53 compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password" 54 compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password" 55 compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password" 56 57 desc 'kill Primary Pod, check reelection, check data' 58 initial_primary=$(get_proxy_primary "-h127.0.0.1 -P6032 -uproxyadmin -padmin_password" "$cluster-proxysql-0") 59 kubectl_bin delete pods --grace-period=0 --force $initial_primary 60 sleep 10 61 changed_primary=$(get_proxy_primary "-h127.0.0.1 -P6032 -uproxyadmin -padmin_password" "$cluster-proxysql-0") 62 [ -n "$changed_primary" ] && [ "$initial_primary" != "$changed_primary" ] 63 run_mysql \ 64 'INSERT myApp.myApp (id) VALUES (100502)' \ 65 "-h $cluster-proxysql -uroot -proot_password" 66 wait_for_running "$cluster-pxc" 3 67 compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password" 68 compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password" 69 compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password" 70 71 compare_mysql_cmd "max_allowed_packet-1" "SELECT @@max_allowed_packet;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password" 72 73 desc 'check if possible to create no-proxysql cluster' 74 cluster3="no-proxysql" 75 apply_config "$test_dir/conf/$cluster3.yml" 76 wait_for_running "$cluster3-pxc" 3 77 desc 'check if service and statefulset created' 78 compare_kubectl service/$cluster3-pxc 79 compare_kubectl service/$cluster3-proxysql 80 compare_kubectl configmap/$cluster3-pxc 81 desc 'check if storageClass changed' 82 compare_kubectl statefulset/$cluster3-pxc 83 compare_kubectl statefulset/$cluster3-proxysql 84 compare_kubectl issuer/$cluster3-pxc-issuer 85 compare_kubectl certificate/$cluster3-ssl 86 compare_kubectl certificate/$cluster3-ssl-internal 87 88 desc 'write data, read from all' 89 run_mysql \ 90 'CREATE DATABASE IF NOT EXISTS myApp; use myApp; CREATE TABLE IF NOT EXISTS myApp (id int PRIMARY KEY);' \ 91 "-h $cluster3-pxc -uroot -proot_password" 92 run_mysql \ 93 'INSERT myApp.myApp (id) VALUES (100500)' \ 94 "-h $cluster3-pxc -uroot -proot_password" 95 sleep 10 96 compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-0.$cluster3-pxc -uroot -proot_password" 97 compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-1.$cluster3-pxc -uroot -proot_password" 98 compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-2.$cluster3-pxc -uroot -proot_password" 99 compare_mysql_cmd "max_allowed_packet-2" "SELECT @@max_allowed_packet;" "-h $cluster3-pxc-0.$cluster3-pxc -uroot -proot_password" 100 101 desc 'check for passwords leak' 102 check_passwords_leak 103 104 kubectl_bin delete -f $test_dir/conf/$cluster3.yml 105 destroy $namespace 106 desc "test passed"