Skip to content

Commit

Permalink
Wait for resync to finish after physical restore in tests (#1709)
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes authored Nov 8, 2024
1 parent 2746755 commit 4e0b70e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions e2e-tests/demand-backup-physical-sharded/run
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ run_recovery_check() {
exit 1
fi
echo

wait_cluster_consistency ${cluster} 42
wait_for_pbm_operations ${cluster}

compare_mongos_cmd "find" "myApp:myPass@${cluster}-mongos.${namespace}" "-sharded"
echo
set -o xtrace
}

check_exported_mongos_service_endpoint() {
Expand Down
5 changes: 1 addition & 4 deletions e2e-tests/demand-backup-physical/run
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,18 @@ run_recovery_check() {
# we don't wait for cluster readiness here because the annotation gets removed then
wait_restore "${backup_name}" "${cluster}" "ready" "0" "1800"

kubectl_bin get psmdb ${cluster} -o yaml
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
echo "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a physical restore"
exit 1
fi
echo

wait_cluster_consistency ${cluster}
wait_for_pbm_operations ${cluster}

compare_mongo_cmd "find" "myApp:myPass@${cluster}-rs0-0.${cluster}-rs0.${namespace}"
compare_mongo_cmd "find" "myApp:myPass@${cluster}-rs0-1.${cluster}-rs0.${namespace}"
compare_mongo_cmd "find" "myApp:myPass@${cluster}-rs0-2.${cluster}-rs0.${namespace}"

echo
set -o xtrace
}

create_infra "${namespace}"
Expand Down
19 changes: 19 additions & 0 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,25 @@ wait_backup() {
set_debug
}

wait_for_pbm_operations() {
local cluster=$1

set +o xtrace
echo -n "waiting for PBM operation to finish"
retry=0
until [[ $(kubectl_bin exec ${cluster}-rs0-0 -c backup-agent -- pbm status -o json -s running | jq -r .running.opID) == null ]]; do
if [ $retry -ge 540 ]; then
echo max retry count $retry reached. something went wrong with PBM operations
exit 1
fi
echo -n .
sleep 5
done
echo
set_debug
}


run_restore() {
local backup_name=$1

Expand Down

0 comments on commit 4e0b70e

Please sign in to comment.