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.
This commit is contained in:
Patrick Ohly 2019-06-07 13:17:27 +02:00
parent 25dab4b691
commit f31e6a0d66
1 changed files with 33 additions and 28 deletions

View File

@ -154,6 +154,7 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
configvar CSI_PROW_HOSTPATH_VERSION fc52d13ba07922c80555a24616a5b16480350c3f "hostpath driver" # pre-1.1.0 configvar CSI_PROW_HOSTPATH_VERSION fc52d13ba07922c80555a24616a5b16480350c3f "hostpath driver" # pre-1.1.0
configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path "hostpath repo" configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path "hostpath repo"
configvar CSI_PROW_DEPLOYMENT "" "deployment" configvar CSI_PROW_DEPLOYMENT "" "deployment"
configvar CSI_PROW_DEPLOY_SCRIPT "deploy-hostpath.sh" "deploy script inside the deployment directory"
# If CSI_PROW_HOSTPATH_CANARY is set (typically to "canary", but also # If CSI_PROW_HOSTPATH_CANARY is set (typically to "canary", but also
# "1.0-canary"), then all image versions are replaced with that # "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
configvar CSI_PROW_E2E_VERSION "$(get_versioned_variable CSI_PROW_E2E_VERSION "${csi_prow_kubernetes_version_suffix}")" "E2E version" configvar CSI_PROW_E2E_VERSION "$(get_versioned_variable CSI_PROW_E2E_VERSION "${csi_prow_kubernetes_version_suffix}")" "E2E version"
configvar CSI_PROW_E2E_REPO "$(get_versioned_variable CSI_PROW_E2E_REPO "${csi_prow_kubernetes_version_suffix}")" "E2E repo" configvar CSI_PROW_E2E_REPO "$(get_versioned_variable CSI_PROW_E2E_REPO "${csi_prow_kubernetes_version_suffix}")" "E2E repo"
configvar CSI_PROW_E2E_IMPORT_PATH "$(get_versioned_variable CSI_PROW_E2E_IMPORT_PATH "${csi_prow_kubernetes_version_suffix}")" "E2E package" configvar CSI_PROW_E2E_IMPORT_PATH "$(get_versioned_variable CSI_PROW_E2E_IMPORT_PATH "${csi_prow_kubernetes_version_suffix}")" "E2E package"
configvar CSI_PROW_E2E_TEST_PREFIX "External Storage" "common name of all E2E tests"
# csi-sanity testing from the csi-test repo can be run against the installed # csi-sanity testing from the csi-test repo can be run against the installed
# CSI driver. For this to work, deploying the driver must expose the Unix domain # CSI driver. For this to work, deploying the driver must expose the Unix domain
@ -520,7 +522,7 @@ find_deployment () {
# Fixed deployment name? Use it if it exists, otherwise fail. # Fixed deployment name? Use it if it exists, otherwise fail.
if [ "${CSI_PROW_DEPLOYMENT}" ]; then if [ "${CSI_PROW_DEPLOYMENT}" ]; then
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy-hostpath.sh" file="$dir/${CSI_PROW_DEPLOYMENT}/${CSI_PROW_DEPLOY_SCRIPT}"
if ! [ -e "$file" ]; then if ! [ -e "$file" ]; then
return 1 return 1
fi fi
@ -530,9 +532,9 @@ find_deployment () {
# Ignore: See if you can use ${variable//search/replace} instead. # Ignore: See if you can use ${variable//search/replace} instead.
# shellcheck disable=SC2001 # shellcheck disable=SC2001
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/deploy-hostpath.sh" file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/${CSI_PROW_DEPLOY_SCRIPT}"
if ! [ -e "$file" ]; then if ! [ -e "$file" ]; then
file="$dir/kubernetes-latest/deploy-hostpath.sh" file="$dir/kubernetes-latest/${CSI_PROW_DEPLOY_SCRIPT}"
if ! [ -e "$file" ]; then if ! [ -e "$file" ]; then
return 1 return 1
fi fi
@ -540,12 +542,13 @@ find_deployment () {
echo "$file" echo "$file"
} }
# This installs the hostpath driver example. CSI_PROW_HOSTPATH_CANARY overrides all # This installs the driver from the current repo or (if none found and CSI_PROW_HOSTPATH_REPO is set)
# image versions with that canary version. The parameters of install_hostpath can be # the hostpath driver example. CSI_PROW_HOSTPATH_CANARY overrides all
# image versions with that canary version. The parameters of install_driver can be
# used to override registry and/or tag of individual images (CSI_PROVISIONER_REGISTRY=localhost:9000 # used to override registry and/or tag of individual images (CSI_PROVISIONER_REGISTRY=localhost:9000
# CSI_PROVISIONER_TAG=latest). # CSI_PROVISIONER_TAG=latest).
install_hostpath () { install_driver () {
local images deploy_hostpath local images deploy
images="$*" images="$*"
if [ "${CSI_PROW_DEPLOYMENT}" = "none" ]; then if [ "${CSI_PROW_DEPLOYMENT}" = "none" ]; then
@ -561,16 +564,16 @@ install_hostpath () {
done done
fi fi
if deploy_hostpath="$(find_deployment "$(pwd)/deploy")"; then if deploy="$(find_deployment "$(pwd)/deploy")"; then
: :
elif [ "${CSI_PROW_HOSTPATH_REPO}" = "none" ]; then elif [ "${CSI_PROW_HOSTPATH_REPO}" = "none" ]; then
return 1 return 1
else else
git_checkout "${CSI_PROW_HOSTPATH_REPO}" "${CSI_PROW_WORK}/hostpath" "${CSI_PROW_HOSTPATH_VERSION}" --depth=1 || die "checking out hostpath repo failed" git_checkout "${CSI_PROW_HOSTPATH_REPO}" "${CSI_PROW_WORK}/hostpath" "${CSI_PROW_HOSTPATH_VERSION}" --depth=1 || die "checking out hostpath repo failed"
if deploy_hostpath="$(find_deployment "${CSI_PROW_WORK}/hostpath/deploy")"; then if deploy="$(find_deployment "${CSI_PROW_WORK}/hostpath/deploy")"; then
: :
else else
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" 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"
fi fi
fi fi
@ -580,12 +583,12 @@ install_hostpath () {
# Ignore: Double quote to prevent globbing and word splitting. # Ignore: Double quote to prevent globbing and word splitting.
# It's intentional here for $images. # It's intentional here for $images.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if ! run env $images "${deploy_hostpath}"; then if ! run env $images "${deploy}"; then
# Collect information about failed deployment before failing. # Collect information about failed deployment before failing.
collect_cluster_info collect_cluster_info
(start_loggers >/dev/null; wait) (start_loggers >/dev/null; wait)
info "For container output see job artifacts." info "For container output see job artifacts."
die "deploying the hostpath driver with ${deploy_hostpath} failed" die "deploying the CSI driver with ${deploy} failed"
fi fi
} }
@ -686,6 +689,16 @@ run_filter_junit () {
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" go run "${RELEASE_TOOLS_ROOT}/filter-junit.go" "$@" run_with_go "${CSI_PROW_GO_VERSION_BUILD}" go run "${RELEASE_TOOLS_ROOT}/filter-junit.go" "$@"
} }
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
# and to avoid the large number of "skipped" tests that we get from using
# the full Kubernetes E2E testsuite while only running a few tests.
move_junit () {
local name="$1"
if ls "${ARTIFACTS}"/junit_[0-9]*.xml 2>/dev/null >/dev/null; then
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
fi
}
# Runs the E2E test suite in a sub-shell. # Runs the E2E test suite in a sub-shell.
run_e2e () ( run_e2e () (
name="$1" name="$1"
@ -716,15 +729,7 @@ DriverInfo:
multipods: true multipods: true
EOF EOF
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again trap "move_junit '$name'" EXIT
# and to avoid the large number of "skipped" tests that we get from using
# the full Kubernetes E2E testsuite while only running a few tests.
move_junit () {
if ls "${ARTIFACTS}"/junit_[0-9]*.xml 2>/dev/null >/dev/null; then
run_filter_junit -t="External Storage" -o "${ARTIFACTS}/junit_${name}.xml" "${ARTIFACTS}"/junit_[0-9]*.xml && rm -f "${ARTIFACTS}"/junit_[0-9]*.xml
fi
}
trap move_junit EXIT
cd "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" && cd "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
run_with_loggers ginkgo -v "$@" "${CSI_PROW_WORK}/e2e.test" -- -report-dir "${ARTIFACTS}" -storage.testdriver="${CSI_PROW_WORK}/hostpath-test-driver.yaml" 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 () {
cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')" cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')"
# Get the image that was just built (if any) from the # Get the image that was just built (if any) from the
# top-level Makefile CMDS variable and set the # top-level Makefile CMDS variable and set the
# deploy-hostpath.sh env variables for it. We also need to # deploy env variables for it. We also need to
# side-load those images into the cluster. # side-load those images into the cluster.
for i in $cmds; do for i in $cmds; do
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _) e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
@ -921,7 +926,7 @@ main () {
start_cluster || die "starting the non-alpha cluster failed" start_cluster || die "starting the non-alpha cluster failed"
# Installing the driver might be disabled. # Installing the driver might be disabled.
if install_hostpath "$images"; then if install_driver "$images"; then
collect_cluster_info collect_cluster_info
if sanity_enabled; then if sanity_enabled; then
@ -934,7 +939,7 @@ main () {
# Ignore: Double quote to prevent globbing and word splitting. # Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \ if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
-focus="External.Storage" \ -focus="${CSI_PROW_E2E_TEST_PREFIX}" \
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then -skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E parallel failed" warn "E2E parallel failed"
ret=1 ret=1
@ -943,7 +948,7 @@ main () {
if tests_enabled "serial"; then if tests_enabled "serial"; then
if ! run_e2e serial \ if ! run_e2e serial \
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_SERIAL}"))" \ -focus="${CSI_PROW_E2E_TEST_PREFIX}.*($(regex_join "${CSI_PROW_E2E_SERIAL}"))" \
-skip="$(regex_join "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then -skip="$(regex_join "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E serial failed" warn "E2E serial failed"
ret=1 ret=1
@ -957,14 +962,14 @@ main () {
start_cluster "${CSI_PROW_E2E_ALPHA_GATES}" || die "starting alpha cluster failed" start_cluster "${CSI_PROW_E2E_ALPHA_GATES}" || die "starting alpha cluster failed"
# Installing the driver might be disabled. # Installing the driver might be disabled.
if install_hostpath "$images"; then if install_driver "$images"; then
collect_cluster_info collect_cluster_info
if tests_enabled "parallel-alpha"; then if tests_enabled "parallel-alpha"; then
# Ignore: Double quote to prevent globbing and word splitting. # Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \ if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \ -focus="${CSI_PROW_E2E_TEST_PREFIX}.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_SKIP}")"; then -skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E parallel alpha failed" warn "E2E parallel alpha failed"
ret=1 ret=1
@ -973,7 +978,7 @@ main () {
if tests_enabled "serial-alpha"; then if tests_enabled "serial-alpha"; then
if ! run_e2e serial-alpha \ if ! run_e2e serial-alpha \
-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}")))" \ -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}")))" \
-skip="$(regex_join "${CSI_PROW_E2E_SKIP}")"; then -skip="$(regex_join "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E serial alpha failed" warn "E2E serial alpha failed"
ret=1 ret=1