Skip to content

Commit b1c4636

Browse files
committed
test: refine verify-examples.sh
fix test failure
1 parent 053d606 commit b1c4636

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

hack/verify-examples.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,33 @@
1515

1616
set -euo pipefail
1717

18+
rollout_and_wait() {
19+
echo "Applying config \"$1\""
20+
trap "echo \"Failed to apply config \\\"$1\\\"\" >&2" err
21+
22+
APPNAME=$(kubectl apply -f $1 | grep -E "^(:?daemonset|deployment|statefulset|pod)" | awk '{printf $1}')
23+
if [[ -n $(expr "${APPNAME}" : "\(daemonset\|deployment\|statefulset\)" || true) ]]; then
24+
kubectl rollout status $APPNAME --watch --timeout=5m
25+
else
26+
kubectl wait "${APPNAME}" --for condition=ready --timeout=5m
27+
fi
28+
}
29+
1830
echo "begin to create deployment examples ..."
1931
kubectl apply -f deploy/example/storageclass-blobfuse.yaml
2032
kubectl apply -f deploy/example/storageclass-blob-nfs.yaml
21-
kubectl apply -f deploy/example/deployment.yaml
22-
kubectl apply -f deploy/example/statefulset.yaml
23-
kubectl apply -f deploy/example/statefulset-nonroot.yaml
24-
kubectl apply -f deploy/example/deployment-nfs.yaml
25-
kubectl apply -f deploy/example/statefulset-nfs.yaml
26-
kubectl apply -f deploy/example/statefulset-nonroot-nfs.yaml
2733

28-
echo "sleep 90s ..."
29-
sleep 90
34+
EXAMPLES=(\
35+
deploy/example/deployment.yaml \
36+
deploy/example/statefulset.yaml \
37+
deploy/example/statefulset-nonroot.yaml \
38+
deploy/example/deployment-nfs.yaml \
39+
deploy/example/statefulset-nfs.yaml \
40+
deploy/example/statefulset-nonroot-nfs.yaml \
41+
)
3042

31-
kubectl get pods --field-selector status.phase=Running | grep deployment-blob
32-
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-0
33-
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nonroot-0
34-
kubectl get pods --field-selector status.phase=Running | grep deployment-blob-nfs
35-
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nfs-0
36-
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nonroot-nfs-0
43+
for EXAMPLE in "${EXAMPLES[@]}"; do
44+
rollout_and_wait $EXAMPLE
45+
done
3746

3847
echo "deployment examples running completed."

test/external-e2e/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ setup_e2e_binaries() {
4646
print_logs() {
4747
bash ./hack/verify-examples.sh
4848
echo "print out driver logs ..."
49-
bash ./test/utils/blob_log.sh
49+
bash ./test/utils/blob_log.sh $DRIVER
5050
}
5151

5252
install_ginkgo

test/utils/blob_log.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -e
1818

1919
NS=kube-system
2020
CONTAINER=blob
21+
DRIVER=blob
22+
if [[ "$#" -gt 0 ]]; then
23+
DRIVER=$1
24+
fi
2125

2226
echo "print out all nodes status ..."
2327
kubectl get nodes -o wide
@@ -31,23 +35,23 @@ echo "print out all $NS namespace pods status ..."
3135
kubectl get pods -n${NS} -o wide
3236
echo "======================================================================================"
3337

34-
echo "print out csi-blob-controller logs ..."
38+
echo "print out csi-$DRIVER-controller logs ..."
3539
echo "======================================================================================"
36-
LABEL='app=csi-blob-controller'
40+
LABEL="app=csi-$DRIVER-controller"
3741
kubectl get pods -n${NS} -l${LABEL} \
3842
| awk 'NR>1 {print $1}' \
3943
| xargs -I {} kubectl logs {} --prefix -c${CONTAINER} -n${NS}
4044

41-
echo "print out csi-blob-node logs ..."
45+
echo "print out csi-$DRIVER-node logs ..."
4246
echo "======================================================================================"
43-
LABEL='app=csi-blob-node'
47+
LABEL="app=csi-$DRIVER-node"
4448
kubectl get pods -n${NS} -l${LABEL} \
4549
| awk 'NR>1 {print $1}' \
4650
| xargs -I {} kubectl logs {} --prefix -c${CONTAINER} -n${NS}
4751

4852
echo "print out cloudprovider_azure metrics ..."
4953
echo "======================================================================================"
50-
ip=`kubectl get svc csi-blob-controller -n kube-system | grep blob | awk '{print $4}'`
54+
ip=`kubectl get svc csi-$DRIVER-controller -n kube-system | awk '{print $4}'`
5155
curl http://$ip:29634/metrics
5256

5357

0 commit comments

Comments
 (0)