@@ -296,6 +296,17 @@ tests_need_alpha_cluster () {
296296 tests_enabled " parallel-alpha" " serial-alpha"
297297}
298298
299+ # Enabling mock tests adds the "CSI mock volume" tests from https://github.com/kubernetes/kubernetes/blob/master/test/e2e/storage/csi_mock_volume.go
300+ # to the e2e.test invocations (serial, parallel, and the corresponding alpha variants).
301+ # When testing canary images, those get used instead of the images specified
302+ # in the e2e.test's normal YAML files.
303+ #
304+ # The default is to enable this for all jobs which use canary images
305+ # because we want to know whether our release candidates will pass all
306+ # existing tests (the storage testsuites and mock testing in
307+ # Kubernetes).
308+ configvar CSI_PROW_E2E_MOCK " $( if [ " ${CSI_PROW_DRIVER_CANARY} " = " canary" ]; then echo true ; else echo false ; fi) " " enable CSI mock volume tests"
309+
299310# Regex for non-alpha, feature-tagged tests that should be run.
300311#
301312configvar CSI_PROW_E2E_FOCUS_LATEST ' \[Feature:VolumeSnapshotDataSource\]' " non-alpha, feature-tagged tests for latest Kubernetes version"
@@ -873,6 +884,29 @@ start_loggers () {
873884 done
874885}
875886
887+ # Patches the image versions of test/e2e/testing-manifests/storage-csi/mock in the k/k
888+ # source code, if needed.
889+ patch_kubernetes () {
890+ local source=" $1 " target=" $2 "
891+
892+ if [ " ${CSI_PROW_DRIVER_CANARY} " = " canary" ]; then
893+ # We cannot replace k8s.gcr.io/sig-storage with gcr.io/k8s-staging-sig-storage because
894+ # e2e.test does not support it (see test/utils/image/manifest.go). Instead we
895+ # invoke the e2e.test binary with KUBE_TEST_REPO_LIST set to a file that
896+ # overrides that registry.
897+ find " $source /test/e2e/testing-manifests/storage-csi/mock" -name ' *.yaml' -print0 | xargs -0 sed -i -e ' s;k8s.gcr.io/sig-storage/\(.*\):v.*;k8s.gcr.io/sig-storage/\1:canary;'
898+ cat > " $target /e2e-repo-list" << EOF
899+ sigStorageRegistry: gcr.io/k8s-staging-sig-storage
900+ EOF
901+ cat >&2 << EOF
902+
903+ Using a modified version of k/k/test/e2e:
904+ $( cd " $source " && git diff 2>&1 )
905+
906+ EOF
907+ fi
908+ }
909+
876910# Makes the E2E test suite binary available as "${CSI_PROW_WORK}/e2e.test".
877911install_e2e () {
878912 if [ -e " ${CSI_PROW_WORK} /e2e.test" ]; then
@@ -881,6 +915,7 @@ install_e2e () {
881915
882916 git_checkout " ${CSI_PROW_E2E_REPO} " " ${GOPATH} /src/${CSI_PROW_E2E_IMPORT_PATH} " " ${CSI_PROW_E2E_VERSION} " --depth=1 &&
883917 if [ " ${CSI_PROW_E2E_IMPORT_PATH} " = " k8s.io/kubernetes" ]; then
918+ patch_kubernetes " ${GOPATH} /src/${CSI_PROW_E2E_IMPORT_PATH} " " ${CSI_PROW_WORK} " &&
884919 go_version=" ${CSI_PROW_GO_VERSION_E2E:- $(go_version_for_kubernetes " ${GOPATH} /src/${CSI_PROW_E2E_IMPORT_PATH} " " ${CSI_PROW_E2E_VERSION} " )} " &&
885920 run_with_go " $go_version " make WHAT=test/e2e/e2e.test " -C${GOPATH} /src/${CSI_PROW_E2E_IMPORT_PATH} " &&
886921 ln -s " ${GOPATH} /src/${CSI_PROW_E2E_IMPORT_PATH} /_output/bin/e2e.test" " ${CSI_PROW_WORK} "
@@ -932,7 +967,7 @@ run_e2e () (
932967 trap move_junit EXIT
933968
934969 cd " ${GOPATH} /src/${CSI_PROW_E2E_IMPORT_PATH} " &&
935- run_with_loggers ginkgo -v " $@ " " ${CSI_PROW_WORK} /e2e.test" -- -report-dir " ${ARTIFACTS} " -storage.testdriver=" ${CSI_PROW_WORK} /test-driver.yaml"
970+ 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 -v " $@ " " ${CSI_PROW_WORK} /e2e.test" -- -report-dir " ${ARTIFACTS} " -storage.testdriver=" ${CSI_PROW_WORK} /test-driver.yaml"
936971)
937972
938973# Run csi-sanity against installed CSI driver.
@@ -1163,13 +1198,20 @@ main () {
11631198 done
11641199 fi
11651200
1201+ # Run the external driver tests and optionally also mock tests.
1202+ local focus=" External.Storage"
1203+ if " $CSI_PROW_E2E_MOCK " ; then
1204+ focus=" ($focus |CSI.mock.volume)"
1205+ fi
1206+
11661207 if tests_need_non_alpha_cluster; then
11671208 start_cluster || die " starting the non-alpha cluster failed"
11681209
11691210 # Install necessary snapshot CRDs and snapshot controller
11701211 install_snapshot_crds
11711212 install_snapshot_controller
11721213
1214+
11731215 # Installing the driver might be disabled.
11741216 if ${CSI_PROW_DRIVER_INSTALL} " $images " ; then
11751217 collect_cluster_info
@@ -1184,7 +1226,7 @@ main () {
11841226 # Ignore: Double quote to prevent globbing and word splitting.
11851227 # shellcheck disable=SC2086
11861228 if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
1187- -focus=" External.Storage " \
1229+ -focus=" $focus " \
11881230 -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
11891231 warn " E2E parallel failed"
11901232 ret=1
@@ -1194,7 +1236,7 @@ main () {
11941236 # Ignore: Double quote to prevent globbing and word splitting.
11951237 # shellcheck disable=SC2086
11961238 if ! run_e2e parallel-features ${CSI_PROW_GINKO_PARALLEL} \
1197- -focus=" External.Storage .*($( regex_join " ${CSI_PROW_E2E_FOCUS} " ) )" \
1239+ -focus=" $focus .*($( regex_join " ${CSI_PROW_E2E_FOCUS} " ) )" \
11981240 -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " ) " ; then
11991241 warn " E2E parallel features failed"
12001242 ret=1
@@ -1203,7 +1245,7 @@ main () {
12031245
12041246 if tests_enabled " serial" ; then
12051247 if ! run_e2e serial \
1206- -focus=" External.Storage .*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) )" \
1248+ -focus=" $focus .*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) )" \
12071249 -skip=" $( regex_join " ${CSI_PROW_E2E_ALPHA} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
12081250 warn " E2E serial failed"
12091251 ret=1
@@ -1229,7 +1271,7 @@ main () {
12291271 # Ignore: Double quote to prevent globbing and word splitting.
12301272 # shellcheck disable=SC2086
12311273 if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
1232- -focus=" External.Storage .*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )" \
1274+ -focus=" $focus .*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )" \
12331275 -skip=" $( regex_join " ${CSI_PROW_E2E_SERIAL} " " ${CSI_PROW_E2E_SKIP} " ) " ; then
12341276 warn " E2E parallel alpha failed"
12351277 ret=1
@@ -1238,7 +1280,7 @@ main () {
12381280
12391281 if tests_enabled " serial-alpha" ; then
12401282 if ! run_e2e serial-alpha \
1241- -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} " ) ))" \
1283+ -focus=" $focus .*(($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) ).*($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) )|($( regex_join " ${CSI_PROW_E2E_ALPHA} " ) ).*($( regex_join " ${CSI_PROW_E2E_SERIAL} " ) ))" \
12421284 -skip=" $( regex_join " ${CSI_PROW_E2E_SKIP} " ) " ; then
12431285 warn " E2E serial alpha failed"
12441286 ret=1
0 commit comments