Skip to content

Commit

Permalink
improve pod failover test
Browse files Browse the repository at this point in the history
  • Loading branch information
umagnus committed May 23, 2024
1 parent f6ac19c commit 5f100f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
18 changes: 5 additions & 13 deletions test/pod_failover_test_aws.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-pod-failover-1pod3pvc-sc
parameters:
tagSpecification_1: "deletion_due_time=${deletion_due_time}"
csi.storage.k8s.io/fstype: xfs
type: gp2
provisioner: ebs.csi.aws.com
Expand Down Expand Up @@ -135,26 +137,16 @@ status:
updateRevision: pod-failover-statefulset-8565df4b89
updatedReplicas: 1
EOF
readynum=$(kubectl get pod -n ebs-pod-failover-1pod3pvc --field-selector=status.phase==Running | awk 'END{print NR}')
while [ $readynum -le 1 ]
do
sleep 1
readynum=$(kubectl get pod -n ebs-pod-failover-1pod3pvc --field-selector=status.phase==Running | awk 'END{print NR}')
done
kubectl wait --for=condition=Ready pod/pod-failover-statefulset-0 -n ebs-pod-failover-1pod3pvc --timeout=600s
for i in $(seq $1)
do
nodename=$(kubectl get po pod-failover-statefulset-0 -n ebs-pod-failover-1pod3pvc -o custom-columns=NODE:.spec.nodeName --no-headers)
kubectl cordon $nodename
kubectl delete pod pod-failover-statefulset-0 -n ebs-pod-failover-1pod3pvc
predate=$(date +"%Y-%m-%d %H:%M:%S")
readynum=$(kubectl get pod -n ebs-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 ebs-pod-failover-1pod3pvc --timeout=600s
date=$(date +"%Y-%m-%d %H:%M:%S")
readynum=$(kubectl get pod -n ebs-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 ebs-pod-failover-1pod3pvc
Expand Down
16 changes: 3 additions & 13 deletions test/pod_failover_test_azure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5f100f8

Please sign in to comment.