Skip to content
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

test: improve pod failover test #145

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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