@@ -151,7 +151,7 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
151151#
152152# When no deploy script is found (nothing in `deploy` directory,
153153# CSI_PROW_HOSTPATH_REPO=none), nothing gets deployed.
154- configvar CSI_PROW_HOSTPATH_VERSION 486074dc3beef59955faf7bb5210418d9844e0a7 " hostpath driver" # pre-1.1.0
154+ configvar CSI_PROW_HOSTPATH_VERSION fc52d13ba07922c80555a24616a5b16480350c3f " hostpath driver" # pre-1.1.0
155155configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path " hostpath repo"
156156configvar CSI_PROW_DEPLOYMENT " " " deployment"
157157
@@ -198,13 +198,42 @@ configvar CSI_PROW_SANITY_CONTAINER "hostpath" "Kubernetes container with CSI dr
198198# - serial, only alpha features
199199# - sanity
200200#
201- # Sanity testing with csi-sanity only covers the CSI driver itself and thus
202- # is off by default. A CSI driver can change that default in its .prow.sh
203- # by setting CSI_PROW_TESTS_SANITY.
204- configvar CSI_PROW_TESTS " unit parallel serial parallel-alpha serial-alpha ${CSI_PROW_TESTS_SANITY} " " tests to run"
205- test_enabled () {
206- echo " ${CSI_PROW_TESTS} " | grep -q -w -e " $1 "
201+ # Unknown or unsupported entries are ignored.
202+ #
203+ # Sanity testing with csi-sanity only covers the CSI driver itself and
204+ # thus only makes sense in repos which provide their own CSI
205+ # driver. Repos can enable sanity testing by setting
206+ # CSI_PROW_TESTS_SANITY=sanity.
207+ configvar CSI_PROW_TESTS " unit parallel serial parallel-alpha serial-alpha sanity" " tests to run"
208+ tests_enabled () {
209+ local t1 t2
210+ # We want word-splitting here, so ignore: Quote to prevent word splitting, or split robustly with mapfile or read -a.
211+ # shellcheck disable=SC2206
212+ local tests=(${CSI_PROW_TESTS} )
213+ for t1 in " $@ " ; do
214+ for t2 in " ${tests[@]} " ; do
215+ if [ " $t1 " = " $t2 " ]; then
216+ return
217+ fi
218+ done
219+ done
220+ return 1
221+ }
222+ sanity_enabled () {
223+ [ " ${CSI_PROW_TESTS_SANITY} " = " sanity" ] && tests_enabled " sanity"
224+ }
225+ tests_need_kind () {
226+ tests_enabled " parallel" " serial" " serial-alpha" " parallel-alpha" ||
227+ sanity_enabled
207228}
229+ tests_need_non_alpha_cluster () {
230+ tests_enabled " parallel" " serial" ||
231+ sanity_enabled
232+ }
233+ tests_need_alpha_cluster () {
234+ tests_enabled " parallel-alpha" " serial-alpha"
235+ }
236+
208237
209238# Serial vs. parallel is always determined by these regular expressions.
210239# Individual regular expressions are seperated by spaces for readability
@@ -246,8 +275,10 @@ configvar CSI_PROW_E2E_ALPHA "$(get_versioned_variable CSI_PROW_E2E_ALPHA "${csi
246275# the failing test for "latest" or by updating the test and not running
247276# it anymore for older releases.
248277configvar CSI_PROW_E2E_ALPHA_GATES_1_13 ' VolumeSnapshotDataSource=true,BlockVolume=true,CSIBlockVolume=true' " alpha feature gates for Kubernetes 1.13"
249- # TODO: add new CSI_PROW_ALPHA_GATES entry for future Kubernetes releases
250- configvar CSI_PROW_E2E_ALPHA_GATES_LATEST ' VolumeSnapshotDataSource=true' " alpha feature gates for latest Kubernetes"
278+ configvar CSI_PROW_E2E_ALPHA_GATES_1_14 ' VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' " alpha feature gates for Kubernetes 1.14"
279+ # TODO: add new CSI_PROW_ALPHA_GATES_xxx entry for future Kubernetes releases and
280+ # add new gates to CSI_PROW_E2E_ALPHA_GATES_LATEST.
281+ configvar CSI_PROW_E2E_ALPHA_GATES_LATEST ' VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' " alpha feature gates for latest Kubernetes"
251282configvar CSI_PROW_E2E_ALPHA_GATES " $( get_versioned_variable CSI_PROW_E2E_ALPHA_GATES " ${csi_prow_kubernetes_version_suffix} " ) " " alpha E2E feature gates"
252283
253284# Some tests are known to be unusable in a KinD cluster. For example,
@@ -466,7 +497,17 @@ $(list_gates "$gates")
466497 featureGates:
467498$( list_gates " $gates " )
468499EOF
469- run kind create cluster --name csi-prow --config " ${CSI_PROW_WORK} /kind-config.yaml" --wait 5m --image " $image " || die " 'kind create cluster' failed"
500+ info " kind-config.yaml:"
501+ cat " ${CSI_PROW_WORK} /kind-config.yaml"
502+ if ! run kind create cluster --name csi-prow --config " ${CSI_PROW_WORK} /kind-config.yaml" --wait 5m --image " $image " ; then
503+ warn " Cluster creation failed. Will try again with higher verbosity."
504+ info " Available Docker images:"
505+ docker image ls
506+ if ! run kind --loglevel debug create cluster --retain --name csi-prow --config " ${CSI_PROW_WORK} /kind-config.yaml" --wait 5m --image " $image " ; then
507+ run kind export logs --name csi-prow " $ARTIFACTS /kind-cluster"
508+ die " Cluster creation failed again, giving up. See the 'kind-cluster' artifact directory for additional logs."
509+ fi
510+ fi
470511 KUBECONFIG=" $( kind get kubeconfig-path --name=csi-prow) "
471512 export KUBECONFIG
472513}
@@ -511,6 +552,15 @@ install_hostpath () {
511552 return 1
512553 fi
513554
555+ if ${CSI_PROW_BUILD_JOB} ; then
556+ # Ignore: Double quote to prevent globbing and word splitting.
557+ # Ignore: To read lines rather than words, pipe/redirect to a 'while read' loop.
558+ # shellcheck disable=SC2086 disable=SC2013
559+ for i in $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) ; do
560+ kind load docker-image --name csi-prow $i :csiprow || die " could not load the $i :latest image into the kind cluster"
561+ done
562+ fi
563+
514564 if deploy_hostpath=" $( find_deployment " $( pwd) /deploy" ) " ; then
515565 :
516566 elif [ " ${CSI_PROW_HOSTPATH_REPO} " = " none" ]; then
@@ -609,18 +659,18 @@ install_sanity () (
609659
610660# Whether the hostpath driver supports raw block devices depends on which version
611661# we are testing. It would be much nicer if we could determine that by querying the
612- # installed driver.
662+ # installed driver's capabilities instead of having to do a version check .
613663hostpath_supports_block () {
614- if [ -e " cmd/hostpathplugin " ] && ${CSI_PROW_BUILD_JOB} ; then
615- # The assumption is that if we build the hostpath driver, then it is
616- # a current version with support.
617- echo true
618- return
619- fi
620-
621- case " ${CSI_PROW_DEPLOYMENT} " in kubernetes-1.13) echo false ;; # wasn't supported and probably won't be backported
622- * ) echo true ;; # probably all other deployments have a recent driver
623- esac
664+ local result
665+ result= " $( docker exec csi-prow-control-plane docker image ls --format= ' {{.Repository}} {{.Tag}} {{.ID}} ' | grep hostpath | while read -r repo tag id ; do
666+ if [ " $tag " == " v1.0.1 " ] ; then
667+ # Old version because the revision label is missing: didn't have support yet.
668+ echo " false "
669+ return
670+ fi
671+ done) "
672+ # If not set, then it must be a newer driver with support.
673+ echo " ${result :- true} "
624674}
625675
626676# Captures pod output while running some other command.
@@ -826,7 +876,7 @@ main () {
826876 # might have been minor or unavoidable, for example when experimenting with
827877 # changes in "release-tools" in a PR (that fails the "is release-tools unmodified"
828878 # test).
829- if test_enabled " unit" ; then
879+ if tests_enabled " unit" ; then
830880 if ! run_with_go " ${CSI_PROW_GO_VERSION_BUILD} " make -k test 2>&1 | make_test_to_junit; then
831881 warn " 'make test' failed, proceeding anyway"
832882 ret=1
@@ -836,102 +886,99 @@ main () {
836886 run_with_go " ${CSI_PROW_GO_VERSION_BUILD} " make container || die " 'make container' failed"
837887 fi
838888
839- install_kind || die " installing kind failed "
840- start_cluster || die " starting the cluster failed"
889+ if tests_need_kind ; then
890+ install_kind || die " installing kind failed"
841891
842- if ${CSI_PROW_BUILD_JOB} ; then
843- cmds=" $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) "
844- # Get the image that was just built (if any) from the
845- # top-level Makefile CMDS variable and set the
846- # deploy-hostpath.sh env variables for it. We also need to
847- # side-load those images into the cluster.
848- for i in $cmds ; do
849- e=$( echo " $i " | tr ' [:lower:]' ' [:upper:]' | tr - _)
850- images=" $images ${e} _REGISTRY=none ${e} _TAG=csiprow"
851-
852- # We must avoid the tag "latest" because that implies
853- # always pulling the image
854- # (https://github.com/kubernetes-sigs/kind/issues/328).
855- docker tag " $i :latest" " $i :csiprow" || die " tagging the locally built container image for $i failed"
856- kind load docker-image --name csi-prow " $i :csiprow" || die " could not load the $i :latest image into the kind cluster"
857- done
892+ if ${CSI_PROW_BUILD_JOB} ; then
893+ cmds=" $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) "
894+ # Get the image that was just built (if any) from the
895+ # top-level Makefile CMDS variable and set the
896+ # deploy-hostpath.sh env variables for it. We also need to
897+ # side-load those images into the cluster.
898+ for i in $cmds ; do
899+ e=$( echo " $i " | tr ' [:lower:]' ' [:upper:]' | tr - _)
900+ images=" $images ${e} _REGISTRY=none ${e} _TAG=csiprow"
901+
902+ # We must avoid the tag "latest" because that implies
903+ # always pulling the image
904+ # (https://github.com/kubernetes-sigs/kind/issues/328).
905+ docker tag " $i :latest" " $i :csiprow" || die " tagging the locally built container image for $i failed"
906+ done
858907
859- if [ -e deploy/kubernetes/rbac.yaml ]; then
860- # This is one of those components which has its own RBAC rules (like external-provisioner).
861- # We are testing a locally built image and also want to test with the the current,
862- # potentially modified RBAC rules.
863- if [ " $( echo " $cmds " | wc -w) " != 1 ]; then
864- die " ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds "
908+ if [ -e deploy/kubernetes/rbac.yaml ]; then
909+ # This is one of those components which has its own RBAC rules (like external-provisioner).
910+ # We are testing a locally built image and also want to test with the the current,
911+ # potentially modified RBAC rules.
912+ if [ " $( echo " $cmds " | wc -w) " != 1 ]; then
913+ die " ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds "
914+ fi
915+ e=$( echo " $cmds " | tr ' [:lower:]' ' [:upper:]' | tr - _)
916+ images=" $images ${e} _RBAC=$( pwd) /deploy/kubernetes/rbac.yaml"
865917 fi
866- e=$( echo " $cmds " | tr ' [:lower:]' ' [:upper:]' | tr - _)
867- images=" $images ${e} _RBAC=$( pwd) /deploy/kubernetes/rbac.yaml"
868- fi
869- fi
870-
871- # Installing the driver might be disabled, in which case we bail out early.
872- if ! install_hostpath " $images " ; then
873- info " hostpath driver installation disabled, skipping E2E testing"
874- return " $ret "
875- fi
876-
877- collect_cluster_info
878-
879- if test_enabled " sanity" ; then
880- if ! run_sanity; then
881- ret=1
882918 fi
883- fi
884919
885- if test_enabled " parallel" ; then
886- # Ignore: Double quote to prevent globbing and word splitting.
887- # shellcheck disable=SC2086
888- if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
889- -focus=" External.Storage" \
890- -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
891- warn " E2E parallel failed"
892- ret=1
893- fi
894- fi
895-
896- if test_enabled " serial" ; then
897- if ! run_e2e serial \
898- -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) )" \
899- -skip=" $( regex_join " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
900- warn " E2E serial failed"
901- ret=1
902- fi
903- fi
904-
905- if (test_enabled " parallel-alpha" || test_enabled " serial-alpha" ) && [ " ${CSI_PROW_E2E_ALPHA_GATES} " ]; then
906- # Need to (re)create the cluster.
907- start_cluster " ${CSI_PROW_E2E_ALPHA_GATES} " || die " starting alpha cluster failed"
908- if ${CSI_PROW_BUILD_JOB} ; then
909- # Ignore: Double quote to prevent globbing and word splitting.
910- # Ignore: To read lines rather than words, pipe/redirect to a 'while read' loop.
911- # shellcheck disable=SC2086 disable=SC2013
912- for i in $( grep ' ^\s*CMDS\s*=' Makefile | sed -e ' s/\s*CMDS\s*=//' ) ; do
913- kind load docker-image --name csi-prow $i :csiprow || die " could not load the $i :latest image into the kind cluster"
914- done
915- fi
916- install_hostpath " $images " || die " hostpath driver installation failed unexpectedly on alpha cluster"
917-
918- if test_enabled " parallel-alpha" ; then
919- # Ignore: Double quote to prevent globbing and word splitting.
920- # shellcheck disable=SC2086
921- if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
922- -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )" \
923- -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
924- warn " E2E parallel alpha failed"
925- ret=1
920+ if tests_need_non_alpha_cluster; then
921+ start_cluster || die " starting the non-alpha cluster failed"
922+
923+ # Installing the driver might be disabled.
924+ if install_hostpath " $images " ; then
925+ collect_cluster_info
926+
927+ if sanity_enabled; then
928+ if ! run_sanity; then
929+ ret=1
930+ fi
931+ fi
932+
933+ if tests_enabled " parallel" ; then
934+ # Ignore: Double quote to prevent globbing and word splitting.
935+ # shellcheck disable=SC2086
936+ if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
937+ -focus=" External.Storage" \
938+ -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
939+ warn " E2E parallel failed"
940+ ret=1
941+ fi
942+ fi
943+
944+ if tests_enabled " serial" ; then
945+ if ! run_e2e serial \
946+ -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) )" \
947+ -skip=" $( regex_join " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
948+ warn " E2E serial failed"
949+ ret=1
950+ fi
951+ fi
926952 fi
927953 fi
928954
929- if test_enabled " serial-alpha" ; then
930- if ! run_e2e serial-alpha \
931- -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} " ) ))" \
932- -skip=" $( regex_join " ${CSI_PROW_E2E_SKIP} " ) " ; then
933- warn " E2E serial alpha failed"
934- ret=1
955+ if tests_need_alpha_cluster && [ " ${CSI_PROW_E2E_ALPHA_GATES} " ]; then
956+ # Need to (re)create the cluster.
957+ start_cluster " ${CSI_PROW_E2E_ALPHA_GATES} " || die " starting alpha cluster failed"
958+
959+ # Installing the driver might be disabled.
960+ if install_hostpath " $images " ; then
961+ collect_cluster_info
962+
963+ if tests_enabled " parallel-alpha" ; then
964+ # Ignore: Double quote to prevent globbing and word splitting.
965+ # shellcheck disable=SC2086
966+ if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
967+ -focus=" External.Storage.*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )" \
968+ -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
969+ warn " E2E parallel alpha failed"
970+ ret=1
971+ fi
972+ fi
973+
974+ if tests_enabled " serial-alpha" ; then
975+ if ! run_e2e serial-alpha \
976+ -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} " ) ))" \
977+ -skip=" $( regex_join " ${CSI_PROW_E2E_SKIP} " ) " ; then
978+ warn " E2E serial alpha failed"
979+ ret=1
980+ fi
981+ fi
935982 fi
936983 fi
937984 fi
0 commit comments