-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathrun
More file actions
executable file
·107 lines (89 loc) · 2.89 KB
/
run
File metadata and controls
executable file
·107 lines (89 loc) · 2.89 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
set -o errexit
test_dir=$(realpath $(dirname $0))
. ${test_dir}/../functions
set_debug
source_cluster="some-name-source"
target_cluster="some-name-target"
function setup_infra() {
create_infra ${namespace}
kubectl_bin apply \
-f ${conf_dir}/client.yml \
-f ${conf_dir}/secrets_with_tls.yml \
-f ${conf_dir}/minio-secret.yml
deploy_minio
}
function setup_source_cluster() {
desc "setting up source cluster: ${source_cluster}"
log "creating PSMDB cluster: ${source_cluster}"
apply_cluster ${test_dir}/conf/${source_cluster}.yml
wait_for_running ${source_cluster}-rs0 3
wait_cluster_consistency "${source_cluster}"
log "writing some data"
run_mongos \
'use myApp\n db.test.insert({ x: 100500 })' \
"databaseAdmin:databaseAdmin123456@${source_cluster}-mongos.${namespace}"
compare_mongos_cmd \
"find" \
"databaseAdmin:databaseAdmin123456@${source_cluster}-mongos.${namespace}" \
"" \
".svc.cluster.local" \
myApp \
test
run_backup "minio" "backup-minio-physical" "physical"
wait_backup "backup-minio-physical"
run_backup "minio" "backup-minio-logical"
wait_backup "backup-minio-logical"
log "writing more data for PiTR"
run_mongos \
'use myApp\n db.test.insert({ x: 100501 })' \
"databaseAdmin:databaseAdmin123456@${source_cluster}-mongos.${namespace}"
sleep_with_log 70 "wait for oplog chunk upload"
log "deleting PSMDB cluster: ${source_cluster}"
kubectl_bin delete psmdb ${source_cluster}
wait_for_delete psmdb/${source_cluster}
wait_for_delete pod/${source_cluster}-rs0-0
}
function setup_target_cluster() {
desc "setting up target cluster: ${target_cluster}"
log "creating PSMDB cluster: ${target_cluster}"
kubectl_bin apply -f ${conf_dir}/secrets_with_tls.yml
apply_cluster ${test_dir}/conf/${target_cluster}.yml
wait_for_running ${target_cluster}-replset0 3
wait_cluster_consistency "${target_cluster}"
}
function test_restores() {
desc "CASE 1: Physical restore with replset remapping"
run_restore backup-minio-physical
wait_restore backup-minio-physical ${target_cluster}
wait_cluster_consistency "${target_cluster}"
compare_mongos_cmd \
"find" \
"databaseAdmin:databaseAdmin123456@${target_cluster}-mongos.${namespace}" \
"" \
".svc.cluster.local" \
myApp \
test
desc "CASE 1: PASSED"
log "dropping test collection"
run_mongos 'use myApp\n db.test.drop()' \
"databaseAdmin:databaseAdmin123456@${target_cluster}-mongos.${namespace}"
desc "CASE 2: Logical restore with replset remapping"
run_restore backup-minio-logical ${test_dir}/conf/restore-pitr.yml
wait_restore backup-minio-logical ${target_cluster}
wait_cluster_consistency "${target_cluster}"
compare_mongos_cmd \
"find" \
"databaseAdmin:databaseAdmin123456@${target_cluster}-mongos.${namespace}" \
"-2nd" \
".svc.cluster.local" \
myApp \
test
desc "CASE 2: PASSED"
}
setup_infra
setup_source_cluster
setup_target_cluster
test_restores
desc 'test passed'
destroy $namespace