-
Notifications
You must be signed in to change notification settings - Fork 189
/
run
executable file
·117 lines (99 loc) · 5.14 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
set -o errexit
test_dir=$(realpath $(dirname $0))
. ${test_dir}/../functions
set_debug
create_infra $namespace
deploy_cert_manager
desc 'create first PXC cluster'
cluster="some-name"
spinup_pxc "$cluster" "$conf_dir/$cluster.yml" "3" "10" "${conf_dir}/secrets_without_tls.yml"
desc 'check if cert-manager issued ssl certificates'
if [ "$(kubectl get secrets ${cluster}-ssl -o jsonpath='{.metadata.annotations.cert-manager\.io/issuer-kind}')" != "Issuer" ]; then
echo "Cert manager didn't create the ssl certificates! Something went wrong."
exit 1
fi
desc 'check if service and statefulset created with expected config'
compare_kubectl statefulset/$cluster-pxc
compare_kubectl statefulset/$cluster-proxysql
compare_kubectl service/$cluster-pxc
compare_kubectl service/$cluster-proxysql
compare_kubectl service/$cluster-proxysql-unready
if [[ ! $IMAGE_PXC =~ 5\.7 ]]; then
desc 'check if mysql-state-monitor works as expected'
for pod in $(kubectl_bin get pod -l app.kubernetes.io/component=pxc --no-headers | awk '{print $1}'); do
state=$(kubectl_bin exec ${pod} -- cat /var/lib/mysql/mysql.state)
if [[ ${state} != 'ready' ]]; then
echo "/var/lib/mysql/mysql.state says ${state}, it should be ready"
exit 1
fi
done
fi
desc 'check PodDisruptionBudget'
compare_kubectl pdb/$cluster-pxc
compare_kubectl pdb/$cluster-proxysql
desc 'check if MySQL users created'
compare_mysql_user "-h $cluster-pxc -uroot -proot_password"
compare_mysql_user "-h $cluster-pxc -umonitor -pmonitor_password"
compare_mysql_user "-h $cluster-pxc -uproxyuser -ps3cret"
compare_mysql_user_local "-uxtrabackup -pbackup_password" "$cluster-pxc-0" "" "pxc"
desc "check that pmm server user don't have access"
compare_mysql_user "-h $cluster-pxc -upmmserver -ppmmserver_password"
desc 'check if ProxySQL users created'
compare_mysql_user "-h $cluster-proxysql -uroot -proot_password"
compare_mysql_user "-h $cluster-proxysql -umonitor -pmonitor_password"
desc "check that pmm server user don't have access"
compare_mysql_user "-h $cluster-proxysql -uproxyuser -ps3cret" "-proxysql"
compare_mysql_user "-h $cluster-proxysql -upmmserver -ppmmserver_password" "-proxysql"
desc 'write data directly, read from all'
run_mysql \
'INSERT myApp.myApp (id) VALUES (100501)' \
"-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password"
compare_mysql_cmd "select-2" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
desc 'kill Primary Pod, check reelection, check data'
initial_primary=$(get_proxy_primary "-h127.0.0.1 -P6032 -uproxyadmin -padmin_password" "$cluster-proxysql-0")
kubectl_bin delete pods --grace-period=0 --force $initial_primary
sleep 10
changed_primary=$(get_proxy_primary "-h127.0.0.1 -P6032 -uproxyadmin -padmin_password" "$cluster-proxysql-0")
[ -n "$changed_primary" ] && [ "$initial_primary" != "$changed_primary" ]
run_mysql \
'INSERT myApp.myApp (id) VALUES (100502)' \
"-h $cluster-proxysql -uroot -proot_password"
wait_for_running "$cluster-pxc" 3
compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-1.$cluster-pxc -uroot -proot_password"
compare_mysql_cmd "select-3" "SELECT * from myApp.myApp;" "-h $cluster-pxc-2.$cluster-pxc -uroot -proot_password"
compare_mysql_cmd "max_allowed_packet-1" "SELECT @@max_allowed_packet;" "-h $cluster-pxc-0.$cluster-pxc -uroot -proot_password"
desc 'check if possible to create no-proxysql cluster'
cluster3="no-proxysql"
apply_config "$test_dir/conf/$cluster3.yml"
wait_for_running "$cluster3-pxc" 3
desc 'check if service and statefulset created'
compare_kubectl service/$cluster3-pxc
compare_kubectl service/$cluster3-proxysql
compare_kubectl configmap/$cluster3-pxc
desc 'check if storageClass changed'
compare_kubectl statefulset/$cluster3-pxc
compare_kubectl statefulset/$cluster3-proxysql
compare_kubectl issuer/$cluster3-pxc-issuer
compare_kubectl certificate/$cluster3-ssl
compare_kubectl certificate/$cluster3-ssl-internal
desc 'write data, read from all'
run_mysql \
'CREATE DATABASE IF NOT EXISTS myApp; use myApp; CREATE TABLE IF NOT EXISTS myApp (id int PRIMARY KEY);' \
"-h $cluster3-pxc -uroot -proot_password"
run_mysql \
'INSERT myApp.myApp (id) VALUES (100500)' \
"-h $cluster3-pxc -uroot -proot_password"
sleep 10
compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-0.$cluster3-pxc -uroot -proot_password"
compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-1.$cluster3-pxc -uroot -proot_password"
compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-2.$cluster3-pxc -uroot -proot_password"
compare_mysql_cmd "max_allowed_packet-2" "SELECT @@max_allowed_packet;" "-h $cluster3-pxc-0.$cluster3-pxc -uroot -proot_password"
desc 'check for passwords leak'
check_passwords_leak
kubectl_bin delete -f $test_dir/conf/$cluster3.yml
destroy $namespace
desc "test passed"