37
37
# - kind (https://github.com/kubernetes-sigs/kind) installed
38
38
# - optional: Go already installed
39
39
40
+ set -x
41
+
40
42
RELEASE_TOOLS_ROOT=" $( realpath " $( dirname " ${BASH_SOURCE[0]} " ) " ) "
41
43
REPO_DIR=" $( pwd) "
42
44
@@ -323,7 +325,7 @@ configvar CSI_PROW_E2E_MOCK "$(if [ "${CSI_PROW_DRIVER_CANARY}" = "canary" ] &&
323
325
324
326
# Regex for non-alpha, feature-tagged tests that should be run.
325
327
#
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"
327
329
configvar CSI_PROW_E2E_FOCUS " $( get_versioned_variable CSI_PROW_E2E_FOCUS " ${csi_prow_kubernetes_version_suffix} " ) " " non-alpha, feature-tagged tests"
328
330
329
331
# Serial vs. parallel is always determined by these regular expressions.
@@ -379,8 +381,12 @@ default_csi_snapshotter_version () {
379
381
echo " v4.0.0"
380
382
fi
381
383
}
384
+ export CSI_SNAPSHOTTER_HACK_VERSION=" master"
382
385
configvar CSI_SNAPSHOTTER_VERSION " $( default_csi_snapshotter_version) " " external-snapshotter version tag"
383
386
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
+
384
390
# Some tests are known to be unusable in a KinD cluster. For example,
385
391
# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
386
392
# doesn't work. Such tests should be written in a way that they verify
@@ -552,6 +558,15 @@ list_gates () (
552
558
# with https://kind.sigs.k8s.io/docs/user/configuration/#runtime-config
553
559
list_api_groups () (
554
560
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
+
555
570
# Ignore: Double quote to prevent globbing and word splitting.
556
571
# shellcheck disable=SC2086
557
572
set -- $1
@@ -772,7 +787,7 @@ install_csi_driver () {
772
787
# Installs all necessary snapshotter CRDs
773
788
install_snapshot_crds () {
774
789
# Wait until volumesnapshot CRDs are in place.
775
- CRD_BASE_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION } /client/config/crd"
790
+ CRD_BASE_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION } /client/config/crd"
776
791
if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
777
792
CRD_BASE_DIR=" ${REPO_DIR} /client/config/crd"
778
793
fi
@@ -792,11 +807,32 @@ install_snapshot_crds() {
792
807
cnt=$(( cnt + 1 ))
793
808
sleep 2
794
809
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
795
831
}
796
832
797
833
# Install snapshot controller and associated RBAC, retrying until the pod is running.
798
834
install_snapshot_controller () {
799
- CONTROLLER_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION } "
835
+ CONTROLLER_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION } "
800
836
if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
801
837
CONTROLLER_DIR=" ${REPO_DIR} "
802
838
fi
@@ -859,6 +895,14 @@ install_snapshot_controller() {
859
895
line=" $( echo " $nocomments " | sed -e " s;$image ;${name} :${NEW_TAG} ;" ) "
860
896
echo " using $line " >&2
861
897
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
862
906
echo " $line "
863
907
done)"
864
908
if ! echo " $modified " | kubectl apply -f -; then
@@ -880,8 +924,15 @@ install_snapshot_controller() {
880
924
exit 1
881
925
fi
882
926
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
885
936
fi
886
937
887
938
cnt=0
@@ -1028,6 +1079,7 @@ run_e2e () (
1028
1079
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
1029
1080
# and to avoid the large number of "skipped" tests that we get from using
1030
1081
# the full Kubernetes E2E testsuite while only running a few tests.
1082
+ # shellcheck disable=SC2329
1031
1083
move_junit () {
1032
1084
if ls " ${ARTIFACTS} " /junit_[0-9]* .xml 2> /dev/null > /dev/null; then
1033
1085
mkdir -p " ${ARTIFACTS} /junit/${name} " &&
@@ -1038,6 +1090,11 @@ run_e2e () (
1038
1090
}
1039
1091
trap move_junit EXIT
1040
1092
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
+
1041
1098
if [ " ${name} " == " local" ]; then
1042
1099
cd " ${GOPATH} /src/${CSI_PROW_SIDECAR_E2E_PATH} " &&
1043
1100
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 () {
1323
1380
if ${CSI_PROW_DRIVER_INSTALL} " $images " ; then
1324
1381
collect_cluster_info
1325
1382
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
+
1326
1394
if sanity_enabled; then
1327
1395
if ! run_sanity; then
1328
1396
ret=1
0 commit comments