Skip to content

Commit 9907dd3

Browse files
committed
Enable the VolumeGroupSnapshot tests
Signed-off-by: Penghao <pewang@redhat.com>
1 parent 32db64f commit 9907dd3

File tree

1 file changed

+59
-5
lines changed

1 file changed

+59
-5
lines changed

release-tools/prow.sh

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
# - kind (https://github.com/kubernetes-sigs/kind) installed
3838
# - optional: Go already installed
3939

40+
set -x
41+
4042
RELEASE_TOOLS_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
4143
REPO_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:volumegroupsnapshot\]' "non-alpha, feature-tagged tests for latest Kubernetes version"
327329
configvar 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"
382385
configvar 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
553559
list_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
@@ -621,7 +636,6 @@ start_cluster () {
621636
version=master
622637
fi
623638
git_clone https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$(version_to_git "$version")" || die "checking out Kubernetes $version failed"
624-
625639
go_version="$(go_version_for_kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$version")" || die "cannot proceed without knowing Go version for Kubernetes"
626640
# Changing into the Kubernetes source code directory is a workaround for https://github.com/kubernetes-sigs/kind/issues/1910
627641
# shellcheck disable=SC2046
@@ -772,7 +786,7 @@ install_csi_driver () {
772786
# Installs all necessary snapshotter CRDs
773787
install_snapshot_crds() {
774788
# 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"
789+
CRD_BASE_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION}/client/config/crd"
776790
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
777791
CRD_BASE_DIR="${REPO_DIR}/client/config/crd"
778792
fi
@@ -792,11 +806,32 @@ install_snapshot_crds() {
792806
cnt=$((cnt + 1))
793807
sleep 2
794808
done
809+
810+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
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+
echo "VolumeGroupSnapshot CRDs installed and ready"
829+
fi
795830
}
796831

797832
# Install snapshot controller and associated RBAC, retrying until the pod is running.
798833
install_snapshot_controller() {
799-
CONTROLLER_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}"
834+
CONTROLLER_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION}"
800835
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
801836
CONTROLLER_DIR="${REPO_DIR}"
802837
fi
@@ -859,6 +894,14 @@ install_snapshot_controller() {
859894
line="$(echo "$nocomments" | sed -e "s;$image;${name}:${NEW_TAG};")"
860895
echo " using $line" >&2
861896
fi
897+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
898+
# inject feature gate after leader election arg
899+
if echo "$nocomments" | grep -q '^[[:space:]]*- "--leader-election=true"'; then
900+
echo "$line"
901+
echo " - \"--feature-gates=CSIVolumeGroupSnapshot=true\""
902+
continue
903+
fi
904+
fi
862905
echo "$line"
863906
done)"
864907
if ! echo "$modified" | kubectl apply -f -; then
@@ -969,6 +1012,13 @@ $(cd "$source" && git diff 2>&1)
9691012
9701013
EOF
9711014
fi
1015+
1016+
if [ "${CSI_PROW_ENABLE_GROUP_SNAPSHOT}" = "true" ]; then
1017+
echo "Enabling VolumeGroupSnapshot: replacing hostpath csi-hostpath-plugin.yaml"
1018+
cp "${source}/test/e2e/testing-manifests/storage-csi/external-snapshotter/volume-group-snapshots/csi-hostpath-plugin.yaml" \
1019+
"${source}/test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-plugin.yaml"
1020+
fi
1021+
9721022
}
9731023
9741024
# Makes the E2E test suite binary available as "${CSI_PROW_WORK}/e2e.test".
@@ -1028,6 +1078,7 @@ run_e2e () (
10281078
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
10291079
# and to avoid the large number of "skipped" tests that we get from using
10301080
# the full Kubernetes E2E testsuite while only running a few tests.
1081+
# shellcheck disable=SC2329
10311082
move_junit () {
10321083
if ls "${ARTIFACTS}"/junit_[0-9]*.xml 2>/dev/null >/dev/null; then
10331084
mkdir -p "${ARTIFACTS}/junit/${name}" &&
@@ -1041,6 +1092,9 @@ run_e2e () (
10411092
if [ "${name}" == "local" ]; then
10421093
cd "${GOPATH}/src/${CSI_PROW_SIDECAR_E2E_PATH}" &&
10431094
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
1095+
elif [ "${CSI_PROW_ENABLE_GROUP_SNAPSHOT}" = "true" ]; then
1096+
cd "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
1097+
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.test" -- -report-dir "${ARTIFACTS}"
10441098
else
10451099
cd "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
10461100
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.test" -- -report-dir "${ARTIFACTS}" -storage.testdriver="${CSI_PROW_WORK}/test-driver.yaml"
@@ -1343,7 +1397,7 @@ main () {
13431397
# Ignore: Double quote to prevent globbing and word splitting.
13441398
# shellcheck disable=SC2086
13451399
if ! run_e2e parallel-features ${CSI_PROW_GINKGO_PARALLEL} \
1346-
-focus="$focus.*($(regex_join "${CSI_PROW_E2E_FOCUS}"))" \
1400+
-focus="${CSI_PROW_E2E_FOCUS}" \
13471401
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}")"; then
13481402
warn "E2E parallel features failed"
13491403
ret=1

0 commit comments

Comments
 (0)