-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathrun
More file actions
executable file
·93 lines (72 loc) · 3.37 KB
/
run
File metadata and controls
executable file
·93 lines (72 loc) · 3.37 KB
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
#!/bin/bash
set -o errexit
set -o xtrace
test_dir=$(realpath $(dirname $0))
. ${test_dir}/../functions
run_recovery_check() {
local cluster=$1
local backup1=$2
desc 'write data after backup'
run_mongo 'use myApp\n db.test.insert({ x: 100501 })' "myApp:myPass@${cluster}.${namespace}"
desc 'recover backup'
compare_mongo_cmd "find" "myApp:myPass@$cluster.$namespace" "-2nd" ".svc.cluster.local" "myApp" "test"
run_restore "${backup1}"
wait_restore "${backup1}" "${cluster/-rs0/}"
compare_mongo_cmd "find" "myApp:myPass@$cluster.$namespace" "" ".svc.cluster.local" "myApp" "test"
kubectl_bin delete -f "$test_dir/conf/${backup1}.yml"
wait_for_running "${cluster}" 1
wait_cluster_consistency "${cluster/-rs0/}"
}
main() {
create_infra $namespace
desc 'create secrets and start client'
kubectl_bin apply -f "${conf_dir}/client.yml" \
-f "${conf_dir}/secrets.yml" \
-f "${conf_dir}/minio-secret.yml"
deploy_minio
cluster='one-pod-rs0'
spinup_psmdb "$cluster" "$test_dir/conf/$cluster.yml" "1"
wait_cluster_consistency "${cluster/-rs0/}"
desc 'check if service and pvc created with expected config'
compare_kubectl service/$cluster
compare_kubectl "pvc/mongod-data-one-pod-rs0-0"
desc 'check system log'
run_mongo \
'db.serverCmdLineOpts()' \
"clusterAdmin:clusterAdmin123456@$cluster.$namespace" \
| grep -E -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|bye' \
| $sed -re 's/((Timestamp|BinData|NumberLong)\((.+?\)))/{}/g' \
| jq '.parsed.systemLog' \
>$tmp_dir/parsed_systemLog.json
diff $test_dir/compare/serverCmdLineOpts_parsed_systemLog.json $tmp_dir/parsed_systemLog.json
desc 'create secret and check custom config'
kubectl_bin apply -f "$test_dir/conf/mongod-secret.yml"
wait_cluster_consistency "${cluster/-rs0/}"
desc 'check if statefulset created with expected config'
compare_kubectl "statefulset/$cluster" "-secret"
run_mongo \
'db.serverCmdLineOpts()' \
"clusterAdmin:clusterAdmin123456@$cluster.$namespace" \
| grep -E -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|bye' \
| $sed -re 's/((Timestamp|BinData|NumberLong)\((.+?\)))/{}/g' \
| jq '.parsed.systemLog' \
>$tmp_dir/parsed_systemLog_secret.json
diff $test_dir/compare/serverCmdLineOpts_parsed_systemLog_secret.json $tmp_dir/parsed_systemLog_secret.json
desc 'create secret and check custom config'
kubectl_bin apply -f "$test_dir/conf/mongod-secret-2.yml"
wait_cluster_consistency "${cluster/-rs0/}"
run_mongo \
'db.serverCmdLineOpts()' \
"clusterAdmin:clusterAdmin123456@$cluster.$namespace" \
| grep -E -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|bye' \
| $sed -re 's/((Timestamp|BinData|NumberLong)\((.+?\)))/{}/g' \
| jq '.parsed.systemLog' \
>$tmp_dir/parsed_systemLog_secret-2.json
diff $test_dir/compare/serverCmdLineOpts_parsed_systemLog_secret-2.json $tmp_dir/parsed_systemLog_secret-2.json
run_backup "minio"
wait_backup "backup-minio"
run_recovery_check "$cluster" "backup-minio"
destroy $namespace
desc 'test passed'
}
main