Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prow testing: update csi-release-tools #36

Merged
merged 25 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
34010e7
Merge pull request #10 from pohly/vendor-check
k8s-ci-robot Mar 27, 2019
104a1ac
build.make: avoid unit-testing E2E test suite
pohly Mar 15, 2019
3b6af7b
Merge pull request #12 from pohly/local-e2e-suite
k8s-ci-robot Mar 29, 2019
2069a0a
Merge pull request #11 from pohly/verify-shellcheck
k8s-ci-robot Apr 2, 2019
95ae9de
Merge pull request #9 from pohly/prow
k8s-ci-robot Apr 3, 2019
f501443
prow.sh: AllAlpha=true for unknown Kubernetes versions
pohly Apr 5, 2019
31dfaf3
prow.sh: fix running of just "alpha" tests
pohly Apr 8, 2019
f3d1d2d
prow.sh: fix hostpath driver version check
pohly Apr 8, 2019
aa45a1c
prow.sh: more efficient execution of individual tests
pohly Apr 8, 2019
9b0d9cd
build.make: skip shellcheck if Docker is not available
pohly Apr 8, 2019
546d550
prow.sh: debug failing KinD cluster creation
pohly Apr 8, 2019
cda2fc5
prow.sh: avoid AllAlpha=true
pohly Apr 8, 2019
6617773
Merge pull request #13 from pohly/prow
k8s-ci-robot Apr 9, 2019
7aaac22
prow.sh: remove AllAlpha=all, part II
pohly Apr 10, 2019
c60f382
Merge pull request #14 from pohly/prow
k8s-ci-robot Apr 10, 2019
821b7d4
Merge commit 'c60f3823c09a501b1cc12b97b20eb05cec9f822e' into prow
pohly Apr 11, 2019
ff9bce4
Replace 'return' to 'exit' to fix shellcheck error
pengzhisun Apr 11, 2019
0c2677e
Merge pull request #15 from pengzhisun/master
k8s-ci-robot Apr 11, 2019
31a24b4
Merge commit '0c2677e8fecad9bf904fca32b0319068d3eaa186' into prow
pohly Apr 11, 2019
0b10f6a
prow.sh: update csi-driver-host-path
pohly Apr 11, 2019
bcac1c1
Merge pull request #16 from pohly/prow
k8s-ci-robot Apr 11, 2019
44655b3
Merge commit 'bcac1c1fb6d791fe54a84716a5fdcccd0987a351' into prow
pohly Apr 11, 2019
0fafc66
prow.sh: skip sanity testing if component doesn't support it
pohly Apr 11, 2019
88dc9a4
Merge pull request #17 from pohly/prow
k8s-ci-robot Apr 11, 2019
ddc28ba
Merge commit '88dc9a47e5aa627fc28179087d8ee1caeb40ecac' into prow
pohly Apr 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion release-tools/build.make
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,13 @@ test: test-shellcheck
test-shellcheck:
@ echo; echo "### $@:"
@ ret=0; \
if ! command -v docker; then \
echo "skipped, no Docker"; \
exit 0; \
fi; \
for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \
echo; \
echo "$$dir:"; \
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
done; \
return $$ret
exit $$ret
267 changes: 157 additions & 110 deletions release-tools/prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
#
# When no deploy script is found (nothing in `deploy` directory,
# CSI_PROW_HOSTPATH_REPO=none), nothing gets deployed.
configvar CSI_PROW_HOSTPATH_VERSION 486074dc3beef59955faf7bb5210418d9844e0a7 "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_DEPLOYMENT "" "deployment"

Expand Down Expand Up @@ -198,13 +198,42 @@ configvar CSI_PROW_SANITY_CONTAINER "hostpath" "Kubernetes container with CSI dr
# - serial, only alpha features
# - sanity
#
# Sanity testing with csi-sanity only covers the CSI driver itself and thus
# is off by default. A CSI driver can change that default in its .prow.sh
# by setting CSI_PROW_TESTS_SANITY.
configvar CSI_PROW_TESTS "unit parallel serial parallel-alpha serial-alpha ${CSI_PROW_TESTS_SANITY}" "tests to run"
test_enabled () {
echo "${CSI_PROW_TESTS}" | grep -q -w -e "$1"
# Unknown or unsupported entries are ignored.
#
# Sanity testing with csi-sanity only covers the CSI driver itself and
# thus only makes sense in repos which provide their own CSI
# driver. Repos can enable sanity testing by setting
# CSI_PROW_TESTS_SANITY=sanity.
configvar CSI_PROW_TESTS "unit parallel serial parallel-alpha serial-alpha sanity" "tests to run"
tests_enabled () {
local t1 t2
# We want word-splitting here, so ignore: Quote to prevent word splitting, or split robustly with mapfile or read -a.
# shellcheck disable=SC2206
local tests=(${CSI_PROW_TESTS})
for t1 in "$@"; do
for t2 in "${tests[@]}"; do
if [ "$t1" = "$t2" ]; then
return
fi
done
done
return 1
}
sanity_enabled () {
[ "${CSI_PROW_TESTS_SANITY}" = "sanity" ] && tests_enabled "sanity"
}
tests_need_kind () {
tests_enabled "parallel" "serial" "serial-alpha" "parallel-alpha" ||
sanity_enabled
}
tests_need_non_alpha_cluster () {
tests_enabled "parallel" "serial" ||
sanity_enabled
}
tests_need_alpha_cluster () {
tests_enabled "parallel-alpha" "serial-alpha"
}


# Serial vs. parallel is always determined by these regular expressions.
# Individual regular expressions are seperated by spaces for readability
Expand Down Expand Up @@ -246,8 +275,10 @@ configvar CSI_PROW_E2E_ALPHA "$(get_versioned_variable CSI_PROW_E2E_ALPHA "${csi
# the failing test for "latest" or by updating the test and not running
# it anymore for older releases.
configvar CSI_PROW_E2E_ALPHA_GATES_1_13 'VolumeSnapshotDataSource=true,BlockVolume=true,CSIBlockVolume=true' "alpha feature gates for Kubernetes 1.13"
# TODO: add new CSI_PROW_ALPHA_GATES entry for future Kubernetes releases
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'VolumeSnapshotDataSource=true' "alpha feature gates for latest Kubernetes"
configvar CSI_PROW_E2E_ALPHA_GATES_1_14 'VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' "alpha feature gates for Kubernetes 1.14"
# TODO: add new CSI_PROW_ALPHA_GATES_xxx entry for future Kubernetes releases and
# add new gates to CSI_PROW_E2E_ALPHA_GATES_LATEST.
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' "alpha feature gates for latest Kubernetes"
configvar CSI_PROW_E2E_ALPHA_GATES "$(get_versioned_variable CSI_PROW_E2E_ALPHA_GATES "${csi_prow_kubernetes_version_suffix}")" "alpha E2E feature gates"

# Some tests are known to be unusable in a KinD cluster. For example,
Expand Down Expand Up @@ -466,7 +497,17 @@ $(list_gates "$gates")
featureGates:
$(list_gates "$gates")
EOF
run kind create cluster --name csi-prow --config "${CSI_PROW_WORK}/kind-config.yaml" --wait 5m --image "$image" || die "'kind create cluster' failed"
info "kind-config.yaml:"
cat "${CSI_PROW_WORK}/kind-config.yaml"
if ! run kind create cluster --name csi-prow --config "${CSI_PROW_WORK}/kind-config.yaml" --wait 5m --image "$image"; then
warn "Cluster creation failed. Will try again with higher verbosity."
info "Available Docker images:"
docker image ls
if ! run kind --loglevel debug create cluster --retain --name csi-prow --config "${CSI_PROW_WORK}/kind-config.yaml" --wait 5m --image "$image"; then
run kind export logs --name csi-prow "$ARTIFACTS/kind-cluster"
die "Cluster creation failed again, giving up. See the 'kind-cluster' artifact directory for additional logs."
fi
fi
KUBECONFIG="$(kind get kubeconfig-path --name=csi-prow)"
export KUBECONFIG
}
Expand Down Expand Up @@ -511,6 +552,15 @@ install_hostpath () {
return 1
fi

if ${CSI_PROW_BUILD_JOB}; then
# Ignore: Double quote to prevent globbing and word splitting.
# Ignore: To read lines rather than words, pipe/redirect to a 'while read' loop.
# shellcheck disable=SC2086 disable=SC2013
for i in $(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//'); do
kind load docker-image --name csi-prow $i:csiprow || die "could not load the $i:latest image into the kind cluster"
done
fi

if deploy_hostpath="$(find_deployment "$(pwd)/deploy")"; then
:
elif [ "${CSI_PROW_HOSTPATH_REPO}" = "none" ]; then
Expand Down Expand Up @@ -609,18 +659,18 @@ install_sanity () (

# 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
# installed driver.
# installed driver's capabilities instead of having to do a version check.
hostpath_supports_block () {
if [ -e "cmd/hostpathplugin" ] && ${CSI_PROW_BUILD_JOB}; then
# The assumption is that if we build the hostpath driver, then it is
# a current version with support.
echo true
return
fi

case "${CSI_PROW_DEPLOYMENT}" in kubernetes-1.13) echo false;; # wasn't supported and probably won't be backported
*) echo true;; # probably all other deployments have a recent driver
esac
local result
result="$(docker exec csi-prow-control-plane docker image ls --format='{{.Repository}} {{.Tag}} {{.ID}}' | grep hostpath | while read -r repo tag id; do
if [ "$tag" == "v1.0.1" ]; then
# Old version because the revision label is missing: didn't have support yet.
echo "false"
return
fi
done)"
# If not set, then it must be a newer driver with support.
echo "${result:-true}"
}

# Captures pod output while running some other command.
Expand Down Expand Up @@ -826,7 +876,7 @@ main () {
# might have been minor or unavoidable, for example when experimenting with
# changes in "release-tools" in a PR (that fails the "is release-tools unmodified"
# test).
if test_enabled "unit"; then
if tests_enabled "unit"; then
if ! run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make -k test 2>&1 | make_test_to_junit; then
warn "'make test' failed, proceeding anyway"
ret=1
Expand All @@ -836,102 +886,99 @@ main () {
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make container || die "'make container' failed"
fi

install_kind || die "installing kind failed"
start_cluster || die "starting the cluster failed"
if tests_need_kind; then
install_kind || die "installing kind failed"

if ${CSI_PROW_BUILD_JOB}; then
cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')"
# Get the image that was just built (if any) from the
# top-level Makefile CMDS variable and set the
# deploy-hostpath.sh env variables for it. We also need to
# side-load those images into the cluster.
for i in $cmds; do
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
images="$images ${e}_REGISTRY=none ${e}_TAG=csiprow"

# We must avoid the tag "latest" because that implies
# always pulling the image
# (https://github.com/kubernetes-sigs/kind/issues/328).
docker tag "$i:latest" "$i:csiprow" || die "tagging the locally built container image for $i failed"
kind load docker-image --name csi-prow "$i:csiprow" || die "could not load the $i:latest image into the kind cluster"
done
if ${CSI_PROW_BUILD_JOB}; then
cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')"
# Get the image that was just built (if any) from the
# top-level Makefile CMDS variable and set the
# deploy-hostpath.sh env variables for it. We also need to
# side-load those images into the cluster.
for i in $cmds; do
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
images="$images ${e}_REGISTRY=none ${e}_TAG=csiprow"

# We must avoid the tag "latest" because that implies
# always pulling the image
# (https://github.com/kubernetes-sigs/kind/issues/328).
docker tag "$i:latest" "$i:csiprow" || die "tagging the locally built container image for $i failed"
done

if [ -e deploy/kubernetes/rbac.yaml ]; then
# This is one of those components which has its own RBAC rules (like external-provisioner).
# We are testing a locally built image and also want to test with the the current,
# potentially modified RBAC rules.
if [ "$(echo "$cmds" | wc -w)" != 1 ]; then
die "ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds"
if [ -e deploy/kubernetes/rbac.yaml ]; then
# This is one of those components which has its own RBAC rules (like external-provisioner).
# We are testing a locally built image and also want to test with the the current,
# potentially modified RBAC rules.
if [ "$(echo "$cmds" | wc -w)" != 1 ]; then
die "ambiguous deploy/kubernetes/rbac.yaml: need exactly one command, got: $cmds"
fi
e=$(echo "$cmds" | tr '[:lower:]' '[:upper:]' | tr - _)
images="$images ${e}_RBAC=$(pwd)/deploy/kubernetes/rbac.yaml"
fi
e=$(echo "$cmds" | tr '[:lower:]' '[:upper:]' | tr - _)
images="$images ${e}_RBAC=$(pwd)/deploy/kubernetes/rbac.yaml"
fi
fi

# Installing the driver might be disabled, in which case we bail out early.
if ! install_hostpath "$images"; then
info "hostpath driver installation disabled, skipping E2E testing"
return "$ret"
fi

collect_cluster_info

if test_enabled "sanity"; then
if ! run_sanity; then
ret=1
fi
fi

if test_enabled "parallel"; then
# Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
-focus="External.Storage" \
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E parallel failed"
ret=1
fi
fi

if test_enabled "serial"; then
if ! run_e2e serial \
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_SERIAL}"))" \
-skip="$(regex_join "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E serial failed"
ret=1
fi
fi

if (test_enabled "parallel-alpha" || test_enabled "serial-alpha") && [ "${CSI_PROW_E2E_ALPHA_GATES}" ]; then
# Need to (re)create the cluster.
start_cluster "${CSI_PROW_E2E_ALPHA_GATES}" || die "starting alpha cluster failed"
if ${CSI_PROW_BUILD_JOB}; then
# Ignore: Double quote to prevent globbing and word splitting.
# Ignore: To read lines rather than words, pipe/redirect to a 'while read' loop.
# shellcheck disable=SC2086 disable=SC2013
for i in $(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//'); do
kind load docker-image --name csi-prow $i:csiprow || die "could not load the $i:latest image into the kind cluster"
done
fi
install_hostpath "$images" || die "hostpath driver installation failed unexpectedly on alpha cluster"

if test_enabled "parallel-alpha"; then
# Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E parallel alpha failed"
ret=1
if tests_need_non_alpha_cluster; then
start_cluster || die "starting the non-alpha cluster failed"

# Installing the driver might be disabled.
if install_hostpath "$images"; then
collect_cluster_info

if sanity_enabled; then
if ! run_sanity; then
ret=1
fi
fi

if tests_enabled "parallel"; then
# Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
-focus="External.Storage" \
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E parallel failed"
ret=1
fi
fi

if tests_enabled "serial"; then
if ! run_e2e serial \
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_SERIAL}"))" \
-skip="$(regex_join "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E serial failed"
ret=1
fi
fi
fi
fi

if test_enabled "serial-alpha"; then
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}")))" \
-skip="$(regex_join "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E serial alpha failed"
ret=1
if tests_need_alpha_cluster && [ "${CSI_PROW_E2E_ALPHA_GATES}" ]; then
# Need to (re)create the cluster.
start_cluster "${CSI_PROW_E2E_ALPHA_GATES}" || die "starting alpha cluster failed"

# Installing the driver might be disabled.
if install_hostpath "$images"; then
collect_cluster_info

if tests_enabled "parallel-alpha"; then
# Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
-focus="External.Storage.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E parallel alpha failed"
ret=1
fi
fi

if tests_enabled "serial-alpha"; then
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}")))" \
-skip="$(regex_join "${CSI_PROW_E2E_SKIP}")"; then
warn "E2E serial alpha failed"
ret=1
fi
fi
fi
fi
fi
Expand Down