Skip to content

Commit d717c8c

Browse files
authored
Merge pull request kubernetes-csi#69 from pohly/test-driver-config
prow.sh: generic driver installation
2 parents a1432bc + 84f78b1 commit d717c8c

File tree

1 file changed

+43
-61
lines changed

1 file changed

+43
-61
lines changed

prow.sh

+43-61
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,21 @@ csi_prow_kubernetes_version_suffix="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | tr
157157
# the caller.
158158
configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csiprow.XXXXXXXXXX")" "work directory"
159159

160-
# The hostpath deployment script is searched for in several places.
160+
# By default, this script tests sidecars with the CSI hostpath driver,
161+
# using the install_csi_driver function. That function depends on
162+
# a deployment script that it searches for in several places:
161163
#
162164
# - The "deploy" directory in the current repository: this is useful
163165
# for the situation that a component becomes incompatible with the
164166
# shared deployment, because then it can (temporarily!) provide its
165167
# own example until the shared one can be updated; it's also how
166168
# csi-driver-host-path itself provides the example.
167169
#
168-
# - CSI_PROW_HOSTPATH_VERSION of the CSI_PROW_HOSTPATH_REPO is checked
170+
# - CSI_PROW_DRIVER_VERSION of the CSI_PROW_DRIVER_REPO is checked
169171
# out: this allows other repos to reference a version of the example
170172
# that is known to be compatible.
171173
#
172-
# - The csi-driver-host-path/deploy directory has multiple sub-directories,
174+
# - The <driver repo>/deploy directory can have multiple sub-directories,
173175
# each with different deployments (stable set of images for Kubernetes 1.13,
174176
# stable set of images for Kubernetes 1.14, canary for latest Kubernetes, etc.).
175177
# This is necessary because there may be incompatible changes in the
@@ -186,16 +188,26 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
186188
# "none" disables the deployment of the hostpath driver.
187189
#
188190
# When no deploy script is found (nothing in `deploy` directory,
189-
# CSI_PROW_HOSTPATH_REPO=none), nothing gets deployed.
190-
configvar CSI_PROW_HOSTPATH_VERSION "v1.3.0-rc3" "hostpath driver"
191-
configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path "hostpath repo"
191+
# CSI_PROW_DRIVER_REPO=none), nothing gets deployed.
192+
#
193+
# If the deployment script is called with CSI_PROW_TEST_DRIVER=<file name> as
194+
# environment variable, then it must write a suitable test driver configuration
195+
# into that file in addition to installing the driver.
196+
configvar CSI_PROW_DRIVER_VERSION "v1.3.0-rc4" "CSI driver version"
197+
configvar CSI_PROW_DRIVER_REPO https://github.com/kubernetes-csi/csi-driver-host-path "CSI driver repo"
192198
configvar CSI_PROW_DEPLOYMENT "" "deployment"
193-
configvar CSI_PROW_HOSTPATH_DRIVER_NAME "hostpath.csi.k8s.io" "the hostpath driver name"
194199

195-
# If CSI_PROW_HOSTPATH_CANARY is set (typically to "canary", but also
196-
# "1.0-canary"), then all image versions are replaced with that
197-
# version tag.
198-
configvar CSI_PROW_HOSTPATH_CANARY "" "hostpath image"
200+
# The install_csi_driver function may work also for other CSI drivers,
201+
# as long as they follow the conventions of the CSI hostpath driver.
202+
# If they don't, then a different install function can be provided in
203+
# a .prow.sh file and this config variable can be overridden.
204+
configvar CSI_PROW_DRIVER_INSTALL "install_csi_driver" "name of the shell function which installs the CSI driver"
205+
206+
# If CSI_PROW_DRIVER_CANARY is set (typically to "canary", but also
207+
# version tag. Usually empty. CSI_PROW_HOSTPATH_CANARY is
208+
# accepted as alternative name because some test-infra jobs
209+
# still use that name.
210+
configvar CSI_PROW_DRIVER_CANARY "${CSI_PROW_HOSTPATH_CANARY}" "driver image override for canary images"
199211

200212
# The E2E testing can come from an arbitrary repo. The expectation is that
201213
# the repo supports "go test ./test/e2e -args --storage.testdriver" (https://github.com/kubernetes/kubernetes/pull/72836)
@@ -620,7 +632,7 @@ find_deployment () {
620632

621633
# Fixed deployment name? Use it if it exists, otherwise fail.
622634
if [ "${CSI_PROW_DEPLOYMENT}" ]; then
623-
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy-hostpath.sh"
635+
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy.sh"
624636
if ! [ -e "$file" ]; then
625637
return 1
626638
fi
@@ -630,22 +642,21 @@ find_deployment () {
630642

631643
# Ignore: See if you can use ${variable//search/replace} instead.
632644
# shellcheck disable=SC2001
633-
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/deploy-hostpath.sh"
645+
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/deploy.sh"
634646
if ! [ -e "$file" ]; then
635-
file="$dir/kubernetes-latest/deploy-hostpath.sh"
647+
file="$dir/kubernetes-latest/deploy.sh"
636648
if ! [ -e "$file" ]; then
637649
return 1
638650
fi
639651
fi
640652
echo "$file"
641653
}
642654

643-
# This installs the hostpath driver example. CSI_PROW_HOSTPATH_CANARY overrides all
644-
# image versions with that canary version. The parameters of install_hostpath can be
645-
# used to override registry and/or tag of individual images (CSI_PROVISIONER_REGISTRY=localhost:9000
646-
# CSI_PROVISIONER_TAG=latest).
647-
install_hostpath () {
648-
local images deploy_hostpath
655+
# This installs the CSI driver. It's called with a list of env variables
656+
# that override the default images. CSI_PROW_DRIVER_CANARY overrides all
657+
# image versions with that canary version.
658+
install_csi_driver () {
659+
local images deploy_driver
649660
images="$*"
650661

651662
if [ "${CSI_PROW_DEPLOYMENT}" = "none" ]; then
@@ -661,31 +672,31 @@ install_hostpath () {
661672
done
662673
fi
663674

664-
if deploy_hostpath="$(find_deployment "$(pwd)/deploy")"; then
675+
if deploy_driver="$(find_deployment "$(pwd)/deploy")"; then
665676
:
666-
elif [ "${CSI_PROW_HOSTPATH_REPO}" = "none" ]; then
677+
elif [ "${CSI_PROW_DRIVER_REPO}" = "none" ]; then
667678
return 1
668679
else
669-
git_checkout "${CSI_PROW_HOSTPATH_REPO}" "${CSI_PROW_WORK}/hostpath" "${CSI_PROW_HOSTPATH_VERSION}" --depth=1 || die "checking out hostpath repo failed"
670-
if deploy_hostpath="$(find_deployment "${CSI_PROW_WORK}/hostpath/deploy")"; then
680+
git_checkout "${CSI_PROW_DRIVER_REPO}" "${CSI_PROW_WORK}/csi-driver" "${CSI_PROW_DRIVER_VERSION}" --depth=1 || die "checking out CSI driver repo failed"
681+
if deploy_driver="$(find_deployment "${CSI_PROW_WORK}/csi-driver/deploy")"; then
671682
:
672683
else
673-
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"
684+
die "deploy.sh not found in ${CSI_PROW_DRIVER_REPO} ${CSI_PROW_DRIVER_VERSION}. To disable E2E testing, set CSI_PROW_DRIVER_REPO=none"
674685
fi
675686
fi
676687

677-
if [ "${CSI_PROW_HOSTPATH_CANARY}" != "stable" ]; then
678-
images="$images IMAGE_TAG=${CSI_PROW_HOSTPATH_CANARY}"
688+
if [ "${CSI_PROW_DRIVER_CANARY}" != "stable" ]; then
689+
images="$images IMAGE_TAG=${CSI_PROW_DRIVER_CANARY}"
679690
fi
680691
# Ignore: Double quote to prevent globbing and word splitting.
681692
# It's intentional here for $images.
682693
# shellcheck disable=SC2086
683-
if ! run env $images "${deploy_hostpath}"; then
694+
if ! run env "CSI_PROW_TEST_DRIVER=${CSI_PROW_WORK}/test-driver.yaml" $images "${deploy_driver}"; then
684695
# Collect information about failed deployment before failing.
685696
collect_cluster_info
686697
(start_loggers >/dev/null; wait)
687698
info "For container output see job artifacts."
688-
die "deploying the hostpath driver with ${deploy_hostpath} failed"
699+
die "deploying the CSI driver with ${deploy_driver} failed"
689700
fi
690701
}
691702

@@ -811,33 +822,6 @@ install_sanity () (
811822
run_with_go "${CSI_PROW_GO_VERSION_SANITY}" go test -c -o "${CSI_PROW_WORK}/csi-sanity" "${CSI_PROW_SANITY_IMPORT_PATH}/cmd/csi-sanity" || die "building csi-sanity failed"
812823
)
813824

814-
# The default implementation of this function generates a external
815-
# driver test configuration for the hostpath driver.
816-
#
817-
# The content depends on both what the E2E suite expects and what the
818-
# installed hostpath driver supports. Generating it here seems prone
819-
# to breakage, but it is uncertain where a better place might be.
820-
generate_test_driver () {
821-
cat <<EOF
822-
ShortName: csiprow
823-
StorageClass:
824-
FromName: true
825-
SnapshotClass:
826-
FromName: true
827-
DriverInfo:
828-
Name: ${CSI_PROW_HOSTPATH_DRIVER_NAME}
829-
Capabilities:
830-
block: true
831-
persistence: true
832-
dataSource: true
833-
multipods: true
834-
nodeExpansion: true
835-
controllerExpansion: true
836-
snapshotDataSource: true
837-
singleNodeVolume: true
838-
EOF
839-
}
840-
841825
# Captures pod output while running some other command.
842826
run_with_loggers () (
843827
loggers=$(start_loggers -f)
@@ -859,8 +843,6 @@ run_e2e () (
859843
install_e2e || die "building e2e.test failed"
860844
install_ginkgo || die "installing ginkgo failed"
861845

862-
generate_test_driver >"${CSI_PROW_WORK}/test-driver.yaml" || die "generating test-driver.yaml failed"
863-
864846
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
865847
# and to avoid the large number of "skipped" tests that we get from using
866848
# the full Kubernetes E2E testsuite while only running a few tests.
@@ -1070,7 +1052,7 @@ main () {
10701052
cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')"
10711053
# Get the image that was just built (if any) from the
10721054
# top-level Makefile CMDS variable and set the
1073-
# deploy-hostpath.sh env variables for it. We also need to
1055+
# deploy.sh env variables for it. We also need to
10741056
# side-load those images into the cluster.
10751057
for i in $cmds; do
10761058
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
@@ -1108,7 +1090,7 @@ main () {
11081090
fi
11091091

11101092
# Installing the driver might be disabled.
1111-
if install_hostpath "$images"; then
1093+
if ${CSI_PROW_DRIVER_INSTALL} "$images"; then
11121094
collect_cluster_info
11131095

11141096
if sanity_enabled; then
@@ -1165,7 +1147,7 @@ main () {
11651147
fi
11661148

11671149
# Installing the driver might be disabled.
1168-
if install_hostpath "$images"; then
1150+
if ${CSI_PROW_DRIVER_INSTALL} "$images"; then
11691151
collect_cluster_info
11701152

11711153
if tests_enabled "parallel-alpha"; then

0 commit comments

Comments
 (0)