From 4cd91b16200f3b091e83c9f5279137932fcdeb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20G=C3=BCne=C5=9F?= Date: Thu, 21 Nov 2024 19:21:34 +0300 Subject: [PATCH] K8SPXC-1420: Add test case to check if proxy stopped during PiTR --- e2e-tests/functions | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/e2e-tests/functions b/e2e-tests/functions index 72bf29c79..df2b17863 100755 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -251,20 +251,23 @@ wait_backup() { wait_backup_restore() { local backup_name=$1 - local status=${2:-'Succeeded'} + local target_state=${2:-'Succeeded'} local wait_time=${3:-720} - desc "wait backup restore" set +o xtrace retry=0 - echo -n $backup_name - until kubectl_bin get pxc-restore/$backup_name -o jsonpath='{.status.state}' 2>/dev/null | grep $status; do + echo -n "waiting for pxc-restore/${backup_name} to reach ${target_state} state" + local current_state= + until [[ ${current_state} == ${target_state} ]]; do sleep 1 echo -n . let retry+=1 - if [ $retry -ge $wait_time ]; then + current_state=$(kubectl_bin get pxc-restore $backup_name -o jsonpath='{.status.state}') + if [[ $retry -ge $wait_time || ${current_state} == 'error' ]]; then kubectl_bin logs ${OPERATOR_NS:+-n $OPERATOR_NS} $(get_operator_pod) - echo max retry count $retry reached. something went wrong with operator or kubernetes cluster + kubectl_bin get pxc-restore ${backup_name} -o yaml + echo "Restore object pxc-restore/${backup_name} is in ${current_state} state." + echo something went wrong with operator or kubernetes cluster exit 1 fi done @@ -1655,6 +1658,15 @@ run_recovery_check_pitr() { | $sed -e "s//${gtid}/g" \ | $sed -e "s~minio-service.#namespace~minio-service.$namespace~" \ | kubectl_bin apply -f - + + echo "Checking if cluster is stopped properly..." + wait_backup_restore ${backup} "Stopping Cluster" + wait_for_delete pod/${cluster}-proxysql-0 + wait_for_delete pod/${cluster}-proxysql-1 + wait_for_delete pod/${cluster}-pxc-0 + wait_for_delete pod/${cluster}-pxc-1 + wait_for_delete pod/${cluster}-pxc-2 + wait_backup_restore ${backup} kubectl_bin logs job/restore-job-${backup}-${cluster} wait_for_running "$cluster-proxysql" 2