From 5f100f8800678ff93d08dd620cd1f6adef7a409b Mon Sep 17 00:00:00 2001 From: umagnus Date: Thu, 23 May 2024 08:22:31 +0000 Subject: [PATCH] improve pod failover test --- test/pod_failover_test_aws.sh | 18 +++++------------- test/pod_failover_test_azure.sh | 16 +++------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/test/pod_failover_test_aws.sh b/test/pod_failover_test_aws.sh index 99472c6..0db748b 100644 --- a/test/pod_failover_test_aws.sh +++ b/test/pod_failover_test_aws.sh @@ -1,11 +1,13 @@ # use sh pod_failover_test_aws.sh 100 file.txt to test 1 pod 3 pvc pod failover test on aws for 100 times and write results in file.txt. kubectl create ns ebs-pod-failover-1pod3pvc +deletion_due_time=$(date -u -d "+3 hour" +'%Y-%m-%dT%H:%M:%SZ') cat <> $2 +echo "`echo $(date -u +"%Y-%m-%dT%H:%M:%SZ")` test $i: $(( $(date -d "$date" "+%s") - $(date -d "$predate" "+%s") ))" >> $2 kubectl uncordon $nodename done kubectl delete ns ebs-pod-failover-1pod3pvc diff --git a/test/pod_failover_test_azure.sh b/test/pod_failover_test_azure.sh index 42b2f77..82e9d44 100644 --- a/test/pod_failover_test_azure.sh +++ b/test/pod_failover_test_azure.sh @@ -136,26 +136,16 @@ status: updateRevision: pod-failover-statefulset-8565df4b89 updatedReplicas: 1 EOF -readynum=$(kubectl get pod -n azdisk-pod-failover-1pod3pvc --field-selector=status.phase==Running | awk 'END{print NR}') -while [ $readynum -le 1 ] -do -sleep 1 -readynum=$(kubectl get pod -n azdisk-pod-failover-1pod3pvc --field-selector=status.phase==Running | awk 'END{print NR}') -done +kubectl wait --for=condition=Ready pod/pod-failover-statefulset-0 -n azdisk-pod-failover-1pod3pvc --timeout=600s for i in $(seq $1) do nodename=$(kubectl get po pod-failover-statefulset-0 -n azdisk-pod-failover-1pod3pvc -o custom-columns=NODE:.spec.nodeName --no-headers) kubectl cordon $nodename kubectl delete pod pod-failover-statefulset-0 -n azdisk-pod-failover-1pod3pvc predate=$(date +"%Y-%m-%d %H:%M:%S") -readynum=$(kubectl get pod -n azdisk-pod-failover-1pod3pvc --field-selector=status.phase==Running | awk 'END{print NR}') -while [ $readynum -le 1 ] -do -sleep 1 +kubectl wait --for=condition=Ready pod/pod-failover-statefulset-0 -n azdisk-pod-failover-1pod3pvc --timeout=600s date=$(date +"%Y-%m-%d %H:%M:%S") -readynum=$(kubectl get pod -n azdisk-pod-failover-1pod3pvc --field-selector=status.phase==Running | awk 'END{print NR}') -done -echo "`date` test $i: $(( $(date -d "$date" "+%s") - $(date -d "$predate" "+%s") ))" >> $2 +echo "`echo $(date -u +"%Y-%m-%dT%H:%M:%SZ")` test $i: $(( $(date -d "$date" "+%s") - $(date -d "$predate" "+%s") ))" >> $2 kubectl uncordon $nodename done kubectl delete ns azdisk-pod-failover-1pod3pvc