From d7a63a5f6f097e7169e77f41fa4cd073a9984504 Mon Sep 17 00:00:00 2001 From: umagnus Date: Wed, 28 Dec 2022 08:06:01 +0000 Subject: [PATCH 1/2] add a test for attach/detach --- test/attach_detach_test.sh | 180 +++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 test/attach_detach_test.sh diff --git a/test/attach_detach_test.sh b/test/attach_detach_test.sh new file mode 100644 index 0000000..d4e6873 --- /dev/null +++ b/test/attach_detach_test.sh @@ -0,0 +1,180 @@ +# use sh attach_detach_test.sh 500 default to test 500 pods. +kubectl create ns test +predate=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag=0 +pvcflag2=0 +pvcflag3=0 +p50=$(($1/2)) +p90=$(($1/10*9)) +p99=$(($1/100*99)) +p100=$1 +cat <> /mnt/local/outfile; sleep 1; done + volumeMounts: + - name: persistent-storage + mountPath: /mnt/local + updateStrategy: + type: RollingUpdate + selector: + matchLabels: + app: nginx + volumeClaimTemplates: + - metadata: + name: persistent-storage + annotations: + volume.beta.kubernetes.io/storage-class: $2 + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi +EOF +readynum=$(kubectl get pod -n test --field-selector=status.phase==Running | awk 'END{print NR}') +while [ $readynum -le $((p50+1)) ] +do +pvcnum=$(kubectl get pvc -n test | grep Bound | awk 'END{print NR}') +if [ $pvcnum -ge $p50 ] && [ $pvcflag -eq 0 ]; then +date2=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag=1 +echo "pv creation p50: $(( $(date -d "$date2" "+%s") - $(date -d "$predate" "+%s") ))" +fi +if [ $pvcnum -ge $p90 ] && [ $pvcflag2 -eq 0 ]; then +date2=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag2=1 +echo "pv creation p90: $(( $(date -d "$date2" "+%s") - $(date -d "$predate" "+%s") ))" +fi +if [ $pvcnum -ge $p99 ] && [ $pvcflag3 -eq 0 ]; then +date2=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag3=1 +echo "pv creation p99: $(( $(date -d "$date2" "+%s") - $(date -d "$predate" "+%s") ))" +fi +sleep 1 +date1=$(date +"%Y-%m-%d %H:%M:%S") +readynum=$(kubectl get pod -n test --field-selector=status.phase==Running | awk 'END{print NR}') +done +echo "attach p50: $(( $(date -d "$date1" "+%s") - $(date -d "$predate" "+%s") ))" +while [ $readynum -le $((p90+1)) ] +do +pvcnum=$(kubectl get pvc -n test | grep Bound | awk 'END{print NR}') +if [ $pvcnum -ge $p90 ] && [ $pvcflag2 -eq 0 ]; then +date2=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag2=1 +echo "pv creation p90: $(( $(date -d "$date2" "+%s") - $(date -d "$predate" "+%s") ))" +fi +if [ $pvcnum -ge $p99 ] && [ $pvcflag3 -eq 0 ]; then +date2=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag3=1 +echo "pv creation p99: $(( $(date -d "$date2" "+%s") - $(date -d "$predate" "+%s") ))" +fi +sleep 1 +date1=$(date +"%Y-%m-%d %H:%M:%S") +readynum=$(kubectl get pod -n test --field-selector=status.phase==Running | awk 'END{print NR}') +done +echo "attach p90: $(( $(date -d "$date1" "+%s") - $(date -d "$predate" "+%s") ))" +while [ $readynum -le $((p99+1)) ] +do +pvcnum=$(kubectl get pvc -n test | grep Bound | awk 'END{print NR}') +if [ $pvcnum -ge $p99 ] && [ $pvcflag3 -eq 0 ]; then +date2=$(date +"%Y-%m-%d %H:%M:%S") +pvcflag3=1 +echo "pv creation p99: $(( $(date -d "$date2" "+%s") - $(date -d "$predate" "+%s") ))" +fi +sleep 1 +date1=$(date +"%Y-%m-%d %H:%M:%S") +readynum=$(kubectl get pod -n test --field-selector=status.phase==Running | awk 'END{print NR}') +done +echo "attach p99: $(( $(date -d "$date1" "+%s") - $(date -d "$predate" "+%s") ))" + +predate=$(date +"%Y-%m-%d %H:%M:%S") +cat <> /mnt/local/outfile; sleep 1; done + volumeMounts: + - name: persistent-storage + mountPath: /mnt/local + updateStrategy: + type: RollingUpdate + selector: + matchLabels: + app: nginx + volumeClaimTemplates: + - metadata: + name: persistent-storage + annotations: + volume.beta.kubernetes.io/storage-class: $2 + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi +EOF +kubectl delete ns test & +detachnum=$(kubectl get pvc -n test | awk 'END{print NR}') +while [ $detachnum -ge $((p100-p50+1)) ] +do +sleep 1 +date1=$(date +"%Y-%m-%d %H:%M:%S") +detachnum=$(kubectl get pv | grep pvc- | awk 'END{print NR}') +done +echo "detach p50: $(( $(date -d "$date1" "+%s") - $(date -d "$predate" "+%s") ))" +while [ $detachnum -ge $((p100-p90+1)) ] +do +sleep 1 +date1=$(date +"%Y-%m-%d %H:%M:%S") +detachnum=$(kubectl get pv | grep pvc- | awk 'END{print NR}') +done +echo "detach p90: $(( $(date -d "$date1" "+%s") - $(date -d "$predate" "+%s") ))" +while [ $detachnum -ge $((p100-p99+1)) ] +do +sleep 1 +date1=$(date +"%Y-%m-%d %H:%M:%S") +detachnum=$(kubectl get pv | grep pvc- | awk 'END{print NR}') +done +echo "detach p99: $(( $(date -d "$date1" "+%s") - $(date -d "$predate" "+%s") ))" From 10730d56b2b997f667b8693115c6fd41edc8767b Mon Sep 17 00:00:00 2001 From: umagnus Date: Wed, 28 Dec 2022 08:51:24 +0000 Subject: [PATCH 2/2] disable spelling verify test --- hack/verify-all.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/hack/verify-all.sh b/hack/verify-all.sh index b186f88..0aeedbd 100755 --- a/hack/verify-all.sh +++ b/hack/verify-all.sh @@ -5,4 +5,3 @@ set -euo pipefail readonly PKG_ROOT=$(git rev-parse --show-toplevel) ${PKG_ROOT}/hack/verify-yamllint.sh -${PKG_ROOT}/hack/verify-spelling.sh