-
Notifications
You must be signed in to change notification settings - Fork 157
K8SPSMDB-1425: Add pitr-to-new-cluster e2e test #2070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
egegunes
wants to merge
7
commits into
main
Choose a base branch
from
K8SPSMDB-1425-e2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+505
−19
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e5bc64b
K8SPSMDB-1425: Add pitr-to-new-cluster e2e test
egegunes 33a690d
fix test
egegunes 252b9c8
Merge branch 'main' into K8SPSMDB-1425-e2e
hors e61b7da
fix triggering resync after restore
egegunes 8bc026e
increase retries for backup validation
egegunes bcc94f7
improve test
egegunes b7c9eaf
Merge branch 'main' into K8SPSMDB-1425-e2e
egegunes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
switched to db myApp | ||
{ "_id" : , "x" : 100500 } | ||
{ "_id" : , "x" : 100501 } | ||
{ "_id" : , "x" : 100502 } | ||
{ "_id" : , "x" : 100503 } | ||
bye |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
switched to db myApp | ||
{ "_id" : , "x" : 100500 } | ||
bye |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
storage: | ||
type: s3 | ||
s3: | ||
region: us-east-1 | ||
endpointUrl: http://minio-service:9000/ | ||
forcePathStyle: true | ||
bucket: operator-testing | ||
prefix: some-name-target | ||
credentials: | ||
access-key-id: '***' | ||
secret-access-key: '***' | ||
maxUploadParts: 10000 | ||
storageClass: STANDARD | ||
insecureSkipTLSVerify: false | ||
pitr: | ||
enabled: false | ||
compression: s2 | ||
backup: | ||
oplogSpanMin: 0 | ||
compression: s2 | ||
restore: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: psmdb.percona.com/v1 | ||
kind: PerconaServerMongoDBBackup | ||
metadata: | ||
name: | ||
spec: | ||
clusterName: | ||
storageName: minio | ||
type: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: psmdb.percona.com/v1 | ||
kind: PerconaServerMongoDBRestore | ||
metadata: | ||
name: | ||
spec: | ||
clusterName: | ||
pitr: | ||
pitrType: latest | ||
backupSource: | ||
type: | ||
destination: s3://DESTINATION | ||
s3: | ||
credentialsSecret: minio-secret | ||
bucket: operator-testing | ||
prefix: some-name-source | ||
endpointUrl: http://minio-service:9000/ | ||
region: us-east-1 | ||
insecureSkipTLSVerify: false | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
apiVersion: psmdb.percona.com/v1 | ||
kind: PerconaServerMongoDB | ||
metadata: | ||
name: some-name-source | ||
spec: | ||
#platform: openshift | ||
image: | ||
imagePullPolicy: Always | ||
backup: | ||
enabled: true | ||
image: perconalab/percona-server-mongodb-operator:main-backup | ||
storages: | ||
minio: | ||
type: s3 | ||
s3: | ||
credentialsSecret: minio-secret | ||
region: us-east-1 | ||
bucket: operator-testing | ||
prefix: some-name-source | ||
endpointUrl: http://minio-service:9000/ | ||
insecureSkipTLSVerify: false | ||
pitr: | ||
enabled: true | ||
oplogSpanMin: 1 | ||
sharding: | ||
enabled: false | ||
replsets: | ||
- name: rs0 | ||
affinity: | ||
antiAffinityTopologyKey: none | ||
resources: | ||
limits: | ||
memory: 4G | ||
requests: | ||
memory: 1G | ||
volumeSpec: | ||
persistentVolumeClaim: | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
size: 3 | ||
configuration: | | ||
operationProfiling: | ||
mode: slowOp | ||
slowOpThresholdMs: 100 | ||
security: | ||
enableEncryption: false | ||
redactClientLogData: false | ||
setParameter: | ||
ttlMonitorSleepSecs: 60 | ||
wiredTigerConcurrentReadTransactions: 128 | ||
wiredTigerConcurrentWriteTransactions: 128 | ||
storage: | ||
engine: wiredTiger | ||
wiredTiger: | ||
collectionConfig: | ||
blockCompressor: snappy | ||
engineConfig: | ||
directoryForIndexes: false | ||
journalCompressor: snappy | ||
indexConfig: | ||
prefixCompression: true | ||
secrets: | ||
users: some-users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
apiVersion: psmdb.percona.com/v1 | ||
kind: PerconaServerMongoDB | ||
metadata: | ||
name: some-name-target | ||
spec: | ||
#platform: openshift | ||
image: | ||
imagePullPolicy: Always | ||
backup: | ||
enabled: true | ||
image: perconalab/percona-server-mongodb-operator:main-backup | ||
storages: | ||
minio: | ||
type: s3 | ||
s3: | ||
credentialsSecret: minio-secret | ||
region: us-east-1 | ||
bucket: operator-testing | ||
prefix: some-name-target | ||
endpointUrl: http://minio-service:9000/ | ||
insecureSkipTLSVerify: false | ||
pitr: | ||
enabled: false | ||
oplogSpanMin: 1 | ||
sharding: | ||
enabled: false | ||
replsets: | ||
- name: rs0 | ||
affinity: | ||
antiAffinityTopologyKey: none | ||
resources: | ||
limits: | ||
memory: 4G | ||
requests: | ||
memory: 1G | ||
volumeSpec: | ||
persistentVolumeClaim: | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
size: 3 | ||
configuration: | | ||
operationProfiling: | ||
mode: slowOp | ||
slowOpThresholdMs: 100 | ||
security: | ||
enableEncryption: false | ||
redactClientLogData: false | ||
setParameter: | ||
ttlMonitorSleepSecs: 60 | ||
wiredTigerConcurrentReadTransactions: 128 | ||
wiredTigerConcurrentWriteTransactions: 128 | ||
storage: | ||
engine: wiredTiger | ||
wiredTiger: | ||
collectionConfig: | ||
blockCompressor: snappy | ||
engineConfig: | ||
directoryForIndexes: false | ||
journalCompressor: snappy | ||
indexConfig: | ||
prefixCompression: true | ||
secrets: | ||
users: some-users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash | ||
|
||
# Regression test for K8SPSMDB-1425 | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
test_dir=$(realpath $(dirname $0)) | ||
. ${test_dir}/../functions | ||
set_debug | ||
|
||
create_user() { | ||
local cluster=$1 | ||
|
||
log 'create user myApp' | ||
run_mongo \ | ||
'db.createUser({user:"myApp",pwd:"myPass",roles:[{db:"myApp",role:"readWrite"}]})' \ | ||
"userAdmin:userAdmin123456@${cluster}-rs0.${namespace}" \ | ||
"mongodb" | ||
} | ||
|
||
write_document() { | ||
local cluster=$1 | ||
local x=$2 | ||
|
||
log "write document: ${x}" | ||
run_mongo \ | ||
"use myApp\n db.test.insert({ x: ${x} })" \ | ||
"myApp:myPass@${cluster}-rs0.${namespace}" \ | ||
"mongodb" | ||
} | ||
|
||
run_backup() { | ||
local cluster=$1 | ||
local name=$2 | ||
local type=$3 | ||
|
||
desc "run backup ${name}-${type}" | ||
cat ${test_dir}/conf/backup.yml \ | ||
| $sed -e "s/name:/name: ${name}-${type}/" \ | ||
| $sed -e "s/clusterName:/clusterName: ${cluster}/" \ | ||
| $sed -e "s/type:/type: ${type}/" \ | ||
| kubectl_bin apply -f - | ||
|
||
wait_backup "${name}-${type}" | ||
} | ||
|
||
run_restore() { | ||
local cluster=$1 | ||
local backup_name=$2 | ||
local backup_type=$3 | ||
local destination=$(get_backup_dest ${backup_name}-${backup_type}) | ||
|
||
cat ${test_dir}/conf/restore.yml \ | ||
| $sed -e "s/name:/name: restore-${backup_name}-${backup_type}/" \ | ||
| $sed -e "s/clusterName:/clusterName: ${cluster}/" \ | ||
| $sed -e "s/type:/type: ${backup_type}/" \ | ||
| $sed -e "s/pitrType:/type:/" \ | ||
| $sed -e "s|DESTINATION|${destination}|" \ | ||
| kubectl_bin apply -f - | ||
} | ||
|
||
compare_pbm_config() { | ||
local cluster=$1 | ||
|
||
kubectl_bin exec ${cluster}-rs0-0 -c backup-agent -- pbm config > ${tmp_dir}/pbm_config.yml | ||
|
||
diff -u ${test_dir}/compare/pbm_config.yml ${tmp_dir}/pbm_config.yml | ||
} | ||
|
||
source_cluster="some-name-source" | ||
target_cluster="some-name-target" | ||
|
||
create_infra $namespace | ||
deploy_minio | ||
|
||
desc 'create secrets and start client' | ||
kubectl_bin apply \ | ||
-f ${conf_dir}/secrets.yml \ | ||
-f ${conf_dir}/client.yml \ | ||
-f ${conf_dir}/minio-secret.yml | ||
|
||
desc "create PSMDB cluster: ${source_cluster}" | ||
apply_cluster ${test_dir}/conf/${source_cluster}.yml | ||
|
||
wait_for_running ${source_cluster}-rs0 3 | ||
|
||
wait_backup_agent ${source_cluster}-rs0-0 | ||
wait_backup_agent ${source_cluster}-rs0-1 | ||
wait_backup_agent ${source_cluster}-rs0-2 | ||
|
||
create_user ${source_cluster} | ||
write_document ${source_cluster} 100500 | ||
|
||
sleep_with_log 360 "wait for PBM-1265 workaround" | ||
|
||
compare_mongo_cmd "find" "myApp:myPass@${source_cluster}-rs0.${namespace}" | ||
|
||
backup_name_minio="backup-minio" | ||
|
||
run_backup ${source_cluster} ${backup_name_minio} logical | ||
|
||
sleep_with_log 70 "wait for oplog chunks to be uploaded" | ||
|
||
run_backup ${source_cluster} ${backup_name_minio} physical | ||
|
||
write_document ${source_cluster} 100501 | ||
write_document ${source_cluster} 100502 | ||
write_document ${source_cluster} 100503 | ||
|
||
sleep_with_log 70 "wait for oplog chunks to be uploaded" | ||
|
||
compare_mongo_cmd "find" "myApp:myPass@${source_cluster}-rs0.${namespace}" "-2nd" | ||
|
||
desc "create PSMDB cluster: ${target_cluster}" | ||
apply_cluster ${test_dir}/conf/${target_cluster}.yml | ||
|
||
wait_for_running ${target_cluster}-rs0 3 | ||
|
||
wait_backup_agent ${target_cluster}-rs0-0 | ||
wait_backup_agent ${target_cluster}-rs0-1 | ||
wait_backup_agent ${target_cluster}-rs0-2 | ||
|
||
run_restore ${target_cluster} ${backup_name_minio} logical | ||
wait_restore "${backup_name_minio}-logical" "${target_cluster}" "ready" | ||
|
||
compare_mongo_cmd "find" "myApp:myPass@${target_cluster}-rs0.${namespace}" "-2nd" | ||
log "Data is restored from ${backup_name_minio}-logical: OK" | ||
|
||
compare_pbm_config ${target_cluster} | ||
log "Main storage is reverted after ${backup_name_minio}-logical: OK" | ||
|
||
run_restore ${target_cluster} ${backup_name_minio} physical | ||
eleo007 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
wait_restore "${backup_name_minio}-physical" "${target_cluster}" "ready" | ||
|
||
compare_mongo_cmd "find" "myApp:myPass@${target_cluster}-rs0.${namespace}" "-2nd" | ||
log "Data is restored from ${backup_name_minio}-physical: OK" | ||
|
||
compare_pbm_config ${target_cluster} | ||
log "Main storage is reverted after ${backup_name_minio}-physical: OK" | ||
|
||
desc "test passed" | ||
|
||
destroy $namespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.