Skip to content

Commit f31e6a0

Browse files
committed
prow.sh: support other drivers
None-hostpath drivers may have deploy scripts under a different name (CSI_PROW_DEPLOY_SCRIPT). A custom E2E test suite might replace run_e2e and then not use the "--storage.testdriver" parameter, which changes the name of the relevant tests (CSI_PROW_E2E_TEST_PREFIX). move_junit can be used in such a custom run_e2e.
1 parent 25dab4b commit f31e6a0

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

release-tools/prow.sh

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
154154
configvar CSI_PROW_HOSTPATH_VERSION fc52d13ba07922c80555a24616a5b16480350c3f "hostpath driver" # pre-1.1.0
155155
configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path "hostpath repo"
156156
configvar CSI_PROW_DEPLOYMENT "" "deployment"
157+
configvar CSI_PROW_DEPLOY_SCRIPT "deploy-hostpath.sh" "deploy script inside the deployment directory"
157158

158159
# If CSI_PROW_HOSTPATH_CANARY is set (typically to "canary", but also
159160
# "1.0-canary"), then all image versions are replaced with that
@@ -176,6 +177,7 @@ configvar CSI_PROW_E2E_IMPORT_PATH_LATEST k8s.io/kubernetes "E2E package for Kub
176177
configvar CSI_PROW_E2E_VERSION "$(get_versioned_variable CSI_PROW_E2E_VERSION "${csi_prow_kubernetes_version_suffix}")" "E2E version"
177178
configvar CSI_PROW_E2E_REPO "$(get_versioned_variable CSI_PROW_E2E_REPO "${csi_prow_kubernetes_version_suffix}")" "E2E repo"
178179
configvar CSI_PROW_E2E_IMPORT_PATH "$(get_versioned_variable CSI_PROW_E2E_IMPORT_PATH "${csi_prow_kubernetes_version_suffix}")" "E2E package"
180+
configvar CSI_PROW_E2E_TEST_PREFIX "External Storage" "common name of all E2E tests"
179181

180182
# csi-sanity testing from the csi-test repo can be run against the installed
181183
# CSI driver. For this to work, deploying the driver must expose the Unix ___domain
@@ -520,7 +522,7 @@ find_deployment () {
520522

521523
# Fixed deployment name? Use it if it exists, otherwise fail.
522524
if [ "${CSI_PROW_DEPLOYMENT}" ]; then
523-
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy-hostpath.sh"
525+
file="$dir/${CSI_PROW_DEPLOYMENT}/${CSI_PROW_DEPLOY_SCRIPT}"
524526
if ! [ -e "$file" ]; then
525527
return 1
526528
fi
@@ -530,22 +532,23 @@ find_deployment () {
530532

531533
# Ignore: See if you can use ${variable//search/replace} instead.
532534
# shellcheck disable=SC2001
533-
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/deploy-hostpath.sh"
535+
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/${CSI_PROW_DEPLOY_SCRIPT}"
534536
if ! [ -e "$file" ]; then
535-
file="$dir/kubernetes-latest/deploy-hostpath.sh"
537+
file="$dir/kubernetes-latest/${CSI_PROW_DEPLOY_SCRIPT}"
536538
if ! [ -e "$file" ]; then
537539
return 1
538540
fi
539541
fi
540542
echo "$file"
541543
}
542544

543-
# This installs the hostpath driver example. CSI_PROW_HOSTPATH_CANARY overrides all
544-
# image versions with that canary version. The parameters of install_hostpath can be
545+
# This installs the driver from the current repo or (if none found and CSI_PROW_HOSTPATH_REPO is set)
546+
# the hostpath driver example. CSI_PROW_HOSTPATH_CANARY overrides all
547+
# image versions with that canary version. The parameters of install_driver can be
545548
# used to override registry and/or tag of individual images (CSI_PROVISIONER_REGISTRY=localhost:9000
546549
# CSI_PROVISIONER_TAG=latest).
547-
install_hostpath () {
548-
local images deploy_hostpath
550+
install_driver () {
551+
local images deploy
549552
images="$*"
550553

551554
if [ "${CSI_PROW_DEPLOYMENT}" = "none" ]; then
@@ -561,16 +564,16 @@ install_hostpath () {
561564
done
562565
fi
563566

564-
if deploy_hostpath="$(find_deployment "$(pwd)/deploy")"; then
567+
if deploy="$(find_deployment "$(pwd)/deploy")"; then
565568
:
566569
elif [ "${CSI_PROW_HOSTPATH_REPO}" = "none" ]; then
567570
return 1
568571
else
569572
git_checkout "${CSI_PROW_HOSTPATH_REPO}" "${CSI_PROW_WORK}/hostpath" "${CSI_PROW_HOSTPATH_VERSION}" --depth=1 || die "checking out hostpath repo failed"
570-
if deploy_hostpath="$(find_deployment "${CSI_PROW_WORK}/hostpath/deploy")"; then
573+
if deploy="$(find_deployment "${CSI_PROW_WORK}/hostpath/deploy")"; then
571574
:
572575
else
573-
die "deploy-hostpath.sh not found in ${CSI_PROW_HOSTPATH_REPO} ${CSI_PROW_HOSTPATH_VERSION}. To disable E2E testing, set CSI_PROW_HOSTPATH_REPO=none"
576+
die "${CSI_PROW_DEPLOY_SCRIPT} not found in ${CSI_PROW_HOSTPATH_REPO} ${CSI_PROW_HOSTPATH_VERSION}. To disable E2E testing, set CSI_PROW_HOSTPATH_REPO=none"
574577
fi
575578
fi
576579

@@ -580,12 +583,12 @@ install_hostpath () {
580583
# Ignore: Double quote to prevent globbing and word splitting.
581584
# It's intentional here for $images.
582585
# shellcheck disable=SC2086
583-
if ! run env $images "${deploy_hostpath}"; then
586+
if ! run env $images "${deploy}"; then
584587
# Collect information about failed deployment before failing.
585588
collect_cluster_info
586589
(start_loggers >/dev/null; wait)
587590
info "For container output see job artifacts."
588-
die "deploying the hostpath driver with ${deploy_hostpath} failed"
591+
die "deploying the CSI driver with ${deploy} failed"
589592
fi
590593
}
591594

@@ -686,6 +689,16 @@ run_filter_junit () {
686689
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" go run "${RELEASE_TOOLS_ROOT}/filter-junit.go" "$@"
687690
}
688691
692+
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
693+
# and to avoid the large number of "skipped" tests that we get from using
694+
# the full Kubernetes E2E testsuite while only running a few tests.
695+
move_junit () {
696+
local name="$1"
697+
if ls "${ARTIFACTS}"/junit_[0-9]*.xml 2>/dev/null >/dev/null; then
698+
run_filter_junit -t="${CSI_PROW_E2E_TEST_PREFIX}" -o "${ARTIFACTS}/junit_${name}.xml" "${ARTIFACTS}"/junit_[0-9]*.xml && rm -f "${ARTIFACTS}"/junit_[0-9]*.xml
699+
fi
700+
}
701+
689702
# Runs the E2E test suite in a sub-shell.
690703
run_e2e () (
691704
name="$1"
@@ -716,15 +729,7 @@ DriverInfo:
716729
multipods: true
717730
EOF
718731
719-
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
720-
# and to avoid the large number of "skipped" tests that we get from using
721-
# the full Kubernetes E2E testsuite while only running a few tests.
722-
move_junit () {
723-
if ls "${ARTIFACTS}"/junit_[0-9]*.xml 2>/dev/null >/dev/null; then
724-
run_filter_junit -t="External Storage" -o "${ARTIFACTS}/junit_${name}.xml" "${ARTIFACTS}"/junit_[0-9]*.xml && rm -f "${ARTIFACTS}"/junit_[0-9]*.xml
725-
fi
726-
}
727-
trap move_junit EXIT
732+
trap "move_junit '$name'" EXIT
728733
729734
cd "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
730735
run_with_loggers ginkgo -v "$@" "${CSI_PROW_WORK}/e2e.test" -- -report-dir "${ARTIFACTS}" -storage.testdriver="${CSI_PROW_WORK}/hostpath-test-driver.yaml"
@@ -893,7 +898,7 @@ main () {
893898
cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')"
894899
# Get the image that was just built (if any) from the
895900
# top-level Makefile CMDS variable and set the
896-
# deploy-hostpath.sh env variables for it. We also need to
901+
# deploy env variables for it. We also need to
897902
# side-load those images into the cluster.
898903
for i in $cmds; do
899904
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
@@ -921,7 +926,7 @@ main () {
921926
start_cluster || die "starting the non-alpha cluster failed"
922927
923928
# Installing the driver might be disabled.
924-
if install_hostpath "$images"; then
929+
if install_driver "$images"; then
925930
collect_cluster_info
926931
927932
if sanity_enabled; then
@@ -934,7 +939,7 @@ main () {
934939
# Ignore: Double quote to prevent globbing and word splitting.
935940
# shellcheck disable=SC2086
936941
if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
937-
-focus="External.Storage" \
942+
-focus="${CSI_PROW_E2E_TEST_PREFIX}" \
938943
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
939944
warn "E2E parallel failed"
940945
ret=1
@@ -943,7 +948,7 @@ main () {
943948
944949
if tests_enabled "serial"; then
945950
if ! run_e2e serial \
946-
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_SERIAL}"))" \
951+
-focus="${CSI_PROW_E2E_TEST_PREFIX}.*($(regex_join "${CSI_PROW_E2E_SERIAL}"))" \
947952
-skip="$(regex_join "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
948953
warn "E2E serial failed"
949954
ret=1
@@ -957,14 +962,14 @@ main () {
957962
start_cluster "${CSI_PROW_E2E_ALPHA_GATES}" || die "starting alpha cluster failed"
958963
959964
# Installing the driver might be disabled.
960-
if install_hostpath "$images"; then
965+
if install_driver "$images"; then
961966
collect_cluster_info
962967
963968
if tests_enabled "parallel-alpha"; then
964969
# Ignore: Double quote to prevent globbing and word splitting.
965970
# shellcheck disable=SC2086
966971
if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
967-
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \
972+
-focus="${CSI_PROW_E2E_TEST_PREFIX}.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \
968973
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_SKIP}")"; then
969974
warn "E2E parallel alpha failed"
970975
ret=1
@@ -973,7 +978,7 @@ main () {
973978
974979
if tests_enabled "serial-alpha"; then
975980
if ! run_e2e serial-alpha \
976-
-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}")))" \
981+
-focus="${CSI_PROW_E2E_TEST_PREFIX}.*(($(regex_join "${CSI_PROW_E2E_SERIAL}")).*($(regex_join "${CSI_PROW_E2E_ALPHA}"))|($(regex_join "${CSI_PROW_E2E_ALPHA}")).*($(regex_join "${CSI_PROW_E2E_SERIAL}")))" \
977982
-skip="$(regex_join "${CSI_PROW_E2E_SKIP}")"; then
978983
warn "E2E serial alpha failed"
979984
ret=1

0 commit comments

Comments
 (0)