configvar CSI_PROW_GO_VERSION_BUILD "$(go_from_travis_yml)""Go version for building the component"# depends on component's source code
configvar CSI_PROW_GO_VERSION_E2E """override Go version for building the Kubernetes E2E test suite"# normally doesn't need to be set, see install_e2e
configvar CSI_PROW_GO_VERSION_SANITY "${CSI_PROW_GO_VERSION_BUILD}""Go version for building the csi-sanity test suite"# depends on CSI_PROW_SANITY settings below
configvar CSI_PROW_GO_VERSION_KIND "${CSI_PROW_GO_VERSION_BUILD}""Go version for building 'kind'"# depends on CSI_PROW_KIND_VERSION below
configvar CSI_PROW_GO_VERSION_GINKGO "${CSI_PROW_GO_VERSION_BUILD}""Go version for building ginkgo"# depends on CSI_PROW_GINKGO_VERSION below
# kind version to use. If the pre-installed version is different,
# the desired version is downloaded from https://github.com/kubernetes-sigs/kind/releases/download/
# (if available), otherwise it is built from source.
configvar CSI_PROW_KIND_VERSION 0.2.1 "kind"
# ginkgo test runner version to use. If the pre-installed version is
# different, the desired version is built from source.
configvar CSI_PROW_GINKGO_VERSION v1.7.0 "Ginkgo"
# Ginkgo runs the E2E test in parallel. The default is based on the number
# of CPUs, but typically this can be set to something higher in the job.
# The E2E testing can come from an arbitrary repo. The expectation is that
# the repo supports "go test ./test/e2e -args --storage.testdriver" (https://github.com/kubernetes/kubernetes/pull/72836)
# after setting KUBECONFIG. As a special case, if the repository is Kubernetes,
# then `make WHAT=test/e2e/e2e.test` is called first to ensure that
# all generated files are present.
#
# CSI_PROW_E2E_REPO=none disables E2E testing.
configvar CSI_PROW_E2E_VERSION_1_13 v1.14.0 "E2E version for Kubernetes 1.13.x"# we can't use the one from 1.13.x because it didn't have --storage.testdriver
configvar CSI_PROW_E2E_VERSION_1_14 v1.14.0 "E2E version for Kubernetes 1.14.x"
# TODO: add new CSI_PROW_E2E_VERSION entry for future Kubernetes releases
configvar CSI_PROW_E2E_VERSION_LATEST master "E2E version for Kubernetes master"# testing against Kubernetes master is already tracking a moving target, so we might as well use a moving E2E version
configvar CSI_PROW_E2E_REPO_LATEST https://github.com/kubernetes/kubernetes "E2E repo for Kubernetes >= 1.13.x"# currently the same for all versions
configvar CSI_PROW_E2E_IMPORT_PATH_LATEST k8s.io/kubernetes "E2E package for Kubernetes >= 1.13.x"# currently the same for all versions
# Which tests are alpha depends on the Kubernetes version. We could
# use the same E2E test for all Kubernetes version. This would have
# the advantage that new tests can be applied to older versions
# without having to backport tests.
#
# But the feature tag gets removed from E2E tests when the corresponding
# feature becomes beta, so we would have to track which tests were
# alpha in previous Kubernetes releases. This was considered too
# error prone. Therefore we use E2E tests that match the Kubernetes
# version that is getting tested.
#
# However, for 1.13.x testing we have to use the E2E tests from 1.14
# because 1.13 didn't have --storage.testdriver yet, so for that (and only
# that version) we have to define alpha tests differently.
configvar CSI_PROW_E2E_ALPHA_1_13 '\[Feature: \[Testpattern:.Dynamic.PV..block.volmode.\] should.create.and.delete.block.persistent.volumes'"alpha tests for Kubernetes 1.13"# Raw block was an alpha feature in 1.13.
configvar CSI_PROW_E2E_ALPHA_LATEST '\[Feature:'"alpha tests for Kubernetes >= 1.14"# there's no need to update this, adding a new case for CSI_PROW_E2E for a new Kubernetes is enough
echo"$(date)$(go version | sed-e's/.*version \(go[^ ]*\).*/\1/')$(if["$(pwd)"!="${REPO_DIR}"];then pwd;fi)\$""$@">&2
"$@"
}
info (){
echo>&2 INFO: "$@"
}
warn (){
echo>&2 WARNING: "$@"
}
die (){
echo>&2 ERROR: "$@"
exit 1
}
# For additional tools.
CSI_PROW_BIN="${CSI_PROW_WORK}/bin"
mkdir-p"${CSI_PROW_BIN}"
PATH="${CSI_PROW_BIN}:$PATH"
# Ensure that PATH has the desired version of the Go tools, then run command given as argument.
# Empty parameter uses the already installed Go. In Prow, that version is kept up-to-date by
# bumping the container image regularly.
run_with_go (){
local version
version="$1"
shift
if!["$version"]|| go version 2>/dev/null | grep-q"go$version";then
run "$@"
else
if![-d"${CSI_PROW_WORK}/go-$version"];then
run curl --fail--location"https://dl.google.com/go/go$version.linux-amd64.tar.gz" | tar-C"${CSI_PROW_WORK}"-zxf - || die "installation of Go $version failed"
PATH="${CSI_PROW_WORK}/go-$version/bin:$PATH" run "$@"
fi
}
# Ensure that we have the desired version of kind.
install_kind (){
if kind --version 2>/dev/null | grep-q" ${CSI_PROW_KIND_VERSION}$";then
return
fi
if run curl --fail--location-o"${CSI_PROW_WORK}/bin/kind""https://github.com/kubernetes-sigs/kind/releases/download/${CSI_PROW_KIND_VERSION}/kind-linux-amd64";then
git_checkout https://github.com/kubernetes/kubernetes "$GOPATH/src/k8s.io/kubernetes""$version"--depth=1 || die "checking out Kubernetes $version failed"
# "kind build" and/or the Kubernetes build rules need at least one tag, which we don't have
# when doing a shallow fetch. Therefore we fake one:
# release-1.12 -> v1.12.0-release.<rev>.csiprow
# latest or <revision> -> v1.14.0-<rev>.csiprow
case"${CSI_PROW_KUBERNETES_VERSION}"in
release-*)
# Ignore: See if you can use ${variable//search/replace} instead.
# Gets logs of all containers in the default namespace. When passed -f, kubectl will
# keep running and capture new output. Prints the pid of all background processes.
# The caller must kill (when using -f) and/or wait for them.
#
# May be called multiple times and thus appends.
start_loggers (){
kubectl get pods -o go-template --template='{{range .items}}{{.metadata.name}} {{range .spec.containers}}{{.name}} {{end}}{{"\n"}}{{end}}' | while read-r pod containers;do
run_with_go "${CSI_PROW_GO_VERSION_E2E}" go test-c-o"${CSI_PROW_WORK}/e2e.test""${CSI_PROW_E2E_IMPORT_PATH}/test/e2e"
fi
}
# Makes the csi-sanity test suite binary available as
# "${CSI_PROW_WORK}/csi-sanity".
install_sanity ()(
if[-e"${CSI_PROW_WORK}/csi-sanity"];then
return
fi
git_checkout "${CSI_PROW_SANITY_REPO}""${GOPATH}/src/${CSI_PROW_SANITY_IMPORT_PATH}""${CSI_PROW_SANITY_VERSION}"--depth=1 || die "checking out csi-sanity failed"
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"
)
# Whether the hostpath driver supports raw block devices depends on which version
# we are testing. It would be much nicer if we could determine that by querying the
# cleanup: warning: NodeUnpublishVolume: rpc error: code = NotFound desc = volume id 5211b280-4fad-11e9-8127-0242dfe2bdaf does not exit in the volumes list
# rmdir: '/tmp/mount': Directory not empty
# command terminated with exit code 1
#
# Somehow the mount directory was not empty. All tests after that
# failed in "mkdir". This only occurred once, so its uncertain
# why it happened.
cat>"${CSI_PROW_WORK}/rmdir_in_pod.sh"<<EOF
#!/bin/sh
if ! kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- rmdir "\$@"; then