@@ -202,18 +202,30 @@ configvar CSI_PROW_SANITY_CONTAINER "hostpath" "Kubernetes container with CSI dr
202
202
# is off by default. A CSI driver can change that default in its .prow.sh
203
203
# by setting CSI_PROW_TESTS_SANITY.
204
204
configvar CSI_PROW_TESTS " unit parallel serial parallel-alpha serial-alpha ${CSI_PROW_TESTS_SANITY} " " tests to run"
205
- test_enabled () {
206
- local test=" $1 "
207
- # We want word-splitting here, so ignore: Double quote to prevent globbing and word splitting.
208
- # shellcheck disable=SC2086
209
- set ${CSI_PROW_TESTS}
210
- for t in " $@ " ; do
211
- if [ " $t " = " $test " ]; then
212
- return
213
- fi
205
+ tests_enabled () {
206
+ local t1 t2
207
+ # We want word-splitting here, so ignore: Quote to prevent word splitting, or split robustly with mapfile or read -a.
208
+ # shellcheck disable=SC2206
209
+ local tests=(${CSI_PROW_TESTS} )
210
+ for t1 in " $@ " ; do
211
+ for t2 in " ${tests[@]} " ; do
212
+ if [ " $t1 " = " $t2 " ]; then
213
+ return
214
+ fi
215
+ done
214
216
done
215
217
return 1
216
218
}
219
+ tests_need_kind () {
220
+ tests_enabled " sanity" " parallel" " serial" " serial-alpha" " parallel-alpha"
221
+ }
222
+ tests_need_non_alpha_cluster () {
223
+ tests_enabled " sanity" " parallel" " serial"
224
+ }
225
+ tests_need_alpha_cluster () {
226
+ tests_enabled " parallel-alpha" " serial-alpha"
227
+ }
228
+
217
229
218
230
# Serial vs. parallel is always determined by these regular expressions.
219
231
# Individual regular expressions are seperated by spaces for readability
@@ -521,6 +533,15 @@ install_hostpath () {
521
533
return 1
522
534
fi
523
535
536
+ if ${CSI_PROW_BUILD_JOB} ; then
537
+ # Ignore: Double quote to prevent globbing and word splitting.
538
+ # Ignore: To read lines rather than words, pipe/redirect to a 'while read' loop.
539
+ # shellcheck disable=SC2086 disable=SC2013
540
+ for i in $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) ; do
541
+ kind load docker-image --name csi-prow $i :csiprow || die " could not load the $i :latest image into the kind cluster"
542
+ done
543
+ fi
544
+
524
545
if deploy_hostpath=" $( find_deployment " $( pwd) /deploy" ) " ; then
525
546
:
526
547
elif [ " ${CSI_PROW_HOSTPATH_REPO} " = " none" ]; then
@@ -836,7 +857,7 @@ main () {
836
857
# might have been minor or unavoidable, for example when experimenting with
837
858
# changes in "release-tools" in a PR (that fails the "is release-tools unmodified"
838
859
# test).
839
- if test_enabled " unit" ; then
860
+ if tests_enabled " unit" ; then
840
861
if ! run_with_go " ${CSI_PROW_GO_VERSION_BUILD} " make -k test 2>&1 | make_test_to_junit; then
841
862
warn " 'make test' failed, proceeding anyway"
842
863
ret=1
@@ -846,102 +867,99 @@ main () {
846
867
run_with_go " ${CSI_PROW_GO_VERSION_BUILD} " make container || die " 'make container' failed"
847
868
fi
848
869
849
- install_kind || die " installing kind failed "
850
- start_cluster || die " starting the cluster failed"
870
+ if tests_need_kind ; then
871
+ install_kind || die " installing kind failed"
851
872
852
- if ${CSI_PROW_BUILD_JOB} ; then
853
- cmds=" $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) "
854
- # Get the image that was just built (if any) from the
855
- # top-level Makefile CMDS variable and set the
856
- # deploy-hostpath.sh env variables for it. We also need to
857
- # side-load those images into the cluster.
858
- for i in $cmds ; do
859
- e=$( echo " $i " | tr ' [:lower:]' ' [:upper:]' | tr - _)
860
- images=" $images ${e} _REGISTRY=none ${e} _TAG=csiprow"
861
-
862
- # We must avoid the tag "latest" because that implies
863
- # always pulling the image
864
- # (https://github.com/kubernetes-sigs/kind/issues/328).
865
- docker tag " $i :latest" " $i :csiprow" || die " tagging the locally built container image for $i failed"
866
- kind load docker-image --name csi-prow " $i :csiprow" || die " could not load the $i :latest image into the kind cluster"
867
- done
873
+ if ${CSI_PROW_BUILD_JOB} ; then
874
+ cmds=" $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) "
875
+ # Get the image that was just built (if any) from the
876
+ # top-level Makefile CMDS variable and set the
877
+ # deploy-hostpath.sh env variables for it. We also need to
878
+ # side-load those images into the cluster.
879
+ for i in $cmds ; do
880
+ e=$( echo " $i " | tr ' [:lower:]' ' [:upper:]' | tr - _)
881
+ images=" $images ${e} _REGISTRY=none ${e} _TAG=csiprow"
882
+
883
+ # We must avoid the tag "latest" because that implies
884
+ # always pulling the image
885
+ # (https://github.com/kubernetes-sigs/kind/issues/328).
886
+ docker tag " $i :latest" " $i :csiprow" || die " tagging the locally built container image for $i failed"
887
+ done
868
888
869
- if [ -e deploy/kubernetes/rbac.yaml ]; then
870
- # This is one of those components which has its own RBAC rules (like external-provisioner).
871
- # We are testing a locally built image and also want to test with the the current,
872
- # potentially modified RBAC rules.
873
- if [ " $( echo " $cmds " | wc -w) " != 1 ]; then
874
- die " ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds "
889
+ if [ -e deploy/kubernetes/rbac.yaml ]; then
890
+ # This is one of those components which has its own RBAC rules (like external-provisioner).
891
+ # We are testing a locally built image and also want to test with the the current,
892
+ # potentially modified RBAC rules.
893
+ if [ " $( echo " $cmds " | wc -w) " != 1 ]; then
894
+ die " ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds "
895
+ fi
896
+ e=$( echo " $cmds " | tr ' [:lower:]' ' [:upper:]' | tr - _)
897
+ images=" $images ${e} _RBAC=$( pwd) /deploy/kubernetes/rbac.yaml"
875
898
fi
876
- e=$( echo " $cmds " | tr ' [:lower:]' ' [:upper:]' | tr - _)
877
- images=" $images ${e} _RBAC=$( pwd) /deploy/kubernetes/rbac.yaml"
878
- fi
879
- fi
880
-
881
- # Installing the driver might be disabled, in which case we bail out early.
882
- if ! install_hostpath " $images " ; then
883
- info " hostpath driver installation disabled, skipping E2E testing"
884
- return " $ret "
885
- fi
886
-
887
- collect_cluster_info
888
-
889
- if test_enabled " sanity" ; then
890
- if ! run_sanity; then
891
- ret=1
892
- fi
893
- fi
894
-
895
- if test_enabled " parallel" ; then
896
- # Ignore: Double quote to prevent globbing and word splitting.
897
- # shellcheck disable=SC2086
898
- if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
899
- -focus=" External.Storage" \
900
- -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
901
- warn " E2E parallel failed"
902
- ret=1
903
899
fi
904
- fi
905
-
906
- if test_enabled " serial" ; then
907
- if ! run_e2e serial \
908
- -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) )" \
909
- -skip=" $( regex_join " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
910
- warn " E2E serial failed"
911
- ret=1
912
- fi
913
- fi
914
900
915
- if (test_enabled " parallel-alpha" || test_enabled " serial-alpha" ) && [ " ${CSI_PROW_E2E_ALPHA_GATES} " ]; then
916
- # Need to (re)create the cluster.
917
- start_cluster " ${CSI_PROW_E2E_ALPHA_GATES} " || die " starting alpha cluster failed"
918
- if ${CSI_PROW_BUILD_JOB} ; then
919
- # Ignore: Double quote to prevent globbing and word splitting.
920
- # Ignore: To read lines rather than words, pipe/redirect to a 'while read' loop.
921
- # shellcheck disable=SC2086 disable=SC2013
922
- for i in $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) ; do
923
- kind load docker-image --name csi-prow $i :csiprow || die " could not load the $i :latest image into the kind cluster"
924
- done
925
- fi
926
- install_hostpath " $images " || die " hostpath driver installation failed unexpectedly on alpha cluster"
927
-
928
- if test_enabled " parallel-alpha" ; then
929
- # Ignore: Double quote to prevent globbing and word splitting.
930
- # shellcheck disable=SC2086
931
- if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
932
- -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )" \
933
- -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
934
- warn " E2E parallel alpha failed"
935
- ret=1
901
+ if tests_need_non_alpha_cluster; then
902
+ start_cluster || die " starting the non-alpha cluster failed"
903
+
904
+ # Installing the driver might be disabled.
905
+ if install_hostpath " $images " ; then
906
+ collect_cluster_info
907
+
908
+ if tests_enabled " sanity" ; then
909
+ if ! run_sanity; then
910
+ ret=1
911
+ fi
912
+ fi
913
+
914
+ if tests_enabled " parallel" ; then
915
+ # Ignore: Double quote to prevent globbing and word splitting.
916
+ # shellcheck disable=SC2086
917
+ if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
918
+ -focus=" External.Storage" \
919
+ -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
920
+ warn " E2E parallel failed"
921
+ ret=1
922
+ fi
923
+ fi
924
+
925
+ if tests_enabled " serial" ; then
926
+ if ! run_e2e serial \
927
+ -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) )" \
928
+ -skip=" $( regex_join " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
929
+ warn " E2E serial failed"
930
+ ret=1
931
+ fi
932
+ fi
936
933
fi
937
934
fi
938
935
939
- if test_enabled " serial-alpha" ; then
940
- if ! run_e2e serial-alpha \
941
- -focus=" External.Storage.*(($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) ).*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )|($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) ).*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) ))" \
942
- -skip=" $( regex_join " ${CSI_PROW_E2E_SKIP} " ) " ; then
943
- warn " E2E serial alpha failed"
944
- ret=1
936
+ if tests_need_alpha_cluster && [ " ${CSI_PROW_E2E_ALPHA_GATES} " ]; then
937
+ # Need to (re)create the cluster.
938
+ start_cluster " ${CSI_PROW_E2E_ALPHA_GATES} " || die " starting alpha cluster failed"
939
+
940
+ # Installing the driver might be disabled.
941
+ if install_hostpath " $images " ; then
942
+ collect_cluster_info
943
+
944
+ if tests_enabled " parallel-alpha" ; then
945
+ # Ignore: Double quote to prevent globbing and word splitting.
946
+ # shellcheck disable=SC2086
947
+ if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
948
+ -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )" \
949
+ -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
950
+ warn " E2E parallel alpha failed"
951
+ ret=1
952
+ fi
953
+ fi
954
+
955
+ if tests_enabled " serial-alpha" ; then
956
+ if ! run_e2e serial-alpha \
957
+ -focus=" External.Storage.*(($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) ).*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )|($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) ).*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) ))" \
958
+ -skip=" $( regex_join " ${CSI_PROW_E2E_SKIP} " ) " ; then
959
+ warn " E2E serial alpha failed"
960
+ ret=1
961
+ fi
962
+ fi
945
963
fi
946
964
fi
947
965
fi
0 commit comments