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
@@ -381,6 +383,9 @@ default_csi_snapshotter_version () {
381383}
382384configvar CSI_SNAPSHOTTER_VERSION " $( default_csi_snapshotter_version) " " external-snapshotter version tag"
383385
386+ # Enable installing VolumeGroupSnapshot CRDs (off by default, can be set to true in prow jobs)
387+ configvar CSI_PROW_ENABLE_GROUP_SNAPSHOT " true" " Enable the VolumeGroupSnapshot tests"
388+
384389# Some tests are known to be unusable in a KinD cluster. For example,
385390# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
386391# doesn't work. Such tests should be written in a way that they verify
@@ -794,6 +799,37 @@ install_snapshot_crds() {
794799 done
795800}
796801
802+ # Installs VolumeGroupSnapshot CRDs (VolumeGroupSnapshot, VolumeGroupSnapshotContent, VolumeGroupSnapshotClass)
803+ install_volumegroupsnapshot_crds () {
804+ local crd_base_dir=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /client/config/crd"
805+
806+ # If we are running inside the external-snapshotter repo, use local files instead of GitHub
807+ if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
808+ crd_base_dir=" ${REPO_DIR} /client/config/crd"
809+ fi
810+
811+ echo " Installing VolumeGroupSnapshot CRDs from ${crd_base_dir} "
812+ kubectl apply -f " ${crd_base_dir} /groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml" --validate=false
813+ kubectl apply -f " ${crd_base_dir} /groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml" --validate=false
814+ kubectl apply -f " ${crd_base_dir} /groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml" --validate=false
815+
816+ local cnt=0
817+ until kubectl get volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io \
818+ && kubectl get volumegroupsnapshots.groupsnapshot.storage.k8s.io \
819+ && kubectl get volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io; do
820+ if [ $cnt -gt 30 ]; then
821+ echo >&2 " ERROR: VolumeGroupSnapshot CRDs not ready after 60s"
822+ exit 1
823+ fi
824+ echo " $( date +%H:%M:%S) " " waiting for VolumeGroupSnapshot CRDs, attempt #$cnt "
825+ cnt=$(( cnt + 1 ))
826+ sleep 2
827+ done
828+
829+ echo " VolumeGroupSnapshot CRDs installed and ready"
830+ }
831+
832+
797833# Install snapshot controller and associated RBAC, retrying until the pod is running.
798834install_snapshot_controller () {
799835 CONTROLLER_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} "
@@ -880,8 +916,15 @@ install_snapshot_controller() {
880916 exit 1
881917 fi
882918 else
883- echo " kubectl apply -f $SNAPSHOT_CONTROLLER_YAML "
884- kubectl apply -f " $SNAPSHOT_CONTROLLER_YAML "
919+ if [ " ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} " = " true" ]; then
920+ echo " Deploying snapshot-controller with CSIVolumeGroupSnapshot feature gate enabled"
921+ curl -s " $SNAPSHOT_CONTROLLER_YAML " | \
922+ awk '/--leader-election=true/ {print; print " - \" --feature-gates=CSIVolumeGroupSnapshot=true\" " ; next}1' | \
923+ kubectl apply -f - || die " failed to deploy snapshot-controller with feature gate"
924+ else
925+ echo " kubectl apply -f $SNAPSHOT_CONTROLLER_YAML "
926+ kubectl apply -f " $SNAPSHOT_CONTROLLER_YAML "
927+ fi
885928 fi
886929
887930 cnt=0
@@ -1028,6 +1071,7 @@ run_e2e () (
10281071 # Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
10291072 # and to avoid the large number of "skipped" tests that we get from using
10301073 # the full Kubernetes E2E testsuite while only running a few tests.
1074+ # shellcheck disable=SC2329
10311075 move_junit () {
10321076 if ls " ${ARTIFACTS} " /junit_[0-9]* .xml 2> /dev/null > /dev/null; then
10331077 mkdir -p " ${ARTIFACTS} /junit/${name} " &&
@@ -1038,6 +1082,11 @@ run_e2e () (
10381082 }
10391083 trap move_junit EXIT
10401084
1085+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
1086+ yq -i ' .DriverInfo.Capabilities.groupSnapshot = true' " ${CSI_PROW_WORK} " /test-driver.yaml
1087+ cat " ${CSI_PROW_WORK} " /test-driver.yaml
1088+ fi
1089+
10411090 if [ " ${name} " == " local" ]; then
10421091 cd " ${GOPATH} /src/${CSI_PROW_SIDECAR_E2E_PATH} " &&
10431092 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
@@ -1383,6 +1432,12 @@ main () {
13831432 install_snapshot_crds
13841433 install_snapshot_controller
13851434
1435+ # TODO: Remove the condition after the vgs GA
1436+ if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT} ; then
1437+ install_volumegroupsnapshot_crds
1438+ fi
1439+
1440+
13861441 # Installing the driver might be disabled.
13871442 if ${CSI_PROW_DRIVER_INSTALL} " $images " ; then
13881443 collect_cluster_info
0 commit comments