From d47f8985001dd6bac527d915ae5c65df993ddc97 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Wed, 25 Jan 2017 11:23:19 -0500 Subject: [PATCH] Re-enable test-cmd.sh tests --- hack/make-rules/test-cmd-util.sh | 11 ++++++----- hack/make-rules/test-cmd.sh | 10 +++++----- hack/make-rules/test-federation-cmd.sh | 10 +++++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hack/make-rules/test-cmd-util.sh b/hack/make-rules/test-cmd-util.sh index 667d0956706..e1704b8bdb1 100644 --- a/hack/make-rules/test-cmd-util.sh +++ b/hack/make-rules/test-cmd-util.sh @@ -21,8 +21,9 @@ set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. -source "${KUBE_ROOT}/hack/lib/init.sh" -source "${KUBE_ROOT}/hack/lib/test.sh" +# Expects the following has already been done by whatever sources this script +# source "${KUBE_ROOT}/hack/lib/init.sh" +# source "${KUBE_ROOT}/hack/lib/test.sh" ETCD_HOST=${ETCD_HOST:-127.0.0.1} ETCD_PORT=${ETCD_PORT:-2379} @@ -2409,9 +2410,9 @@ run_multi_resources_tests() { # Requires an env var SUPPORTED_RESOURCES which is a comma separated list of # resources for which tests should be run. runTests() { - if [ -z "${SUPPORTED_RESOURCES}" ]; then - echo "Need to set SUPPORTED_RESOURCES env var. It is a comma separated list of resources that are supported and hence should be tested. Set it to (*) to test all resources" - return + if [ -z "${SUPPORTED_RESOURCES:-}" ]; then + echo "Need to set SUPPORTED_RESOURCES env var. It is a list of resources that are supported and hence should be tested. Set it to (*) to test all resources" + exit 1 fi kube::log::status "Checking kubectl version" kubectl version diff --git a/hack/make-rules/test-cmd.sh b/hack/make-rules/test-cmd.sh index 4afa2ccc9bf..bd07bf515dc 100755 --- a/hack/make-rules/test-cmd.sh +++ b/hack/make-rules/test-cmd.sh @@ -22,6 +22,8 @@ set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. +source "${KUBE_ROOT}/hack/lib/init.sh" +source "${KUBE_ROOT}/hack/lib/test.sh" source "${KUBE_ROOT}/hack/make-rules/test-cmd-util.sh" function run_kube_apiserver() { @@ -135,10 +137,8 @@ run_kube_controller_manager run_kubelet create_node SUPPORTED_RESOURCES=("*") -output_message=$(runTests "SUPPORTED_RESOURCES=${SUPPORTED_RESOURCES[@]}") -# Ensure that tests were run. We cannot check all resources here. We check a few -# to catch bugs due to which no tests run. -kube::test::if_has_string "${output_message}" "Testing kubectl(v1:pods)" -kube::test::if_has_string "${output_message}" "Testing kubectl(v1:services)" +# WARNING: Do not wrap this call in a subshell to capture output, e.g. output=$(runTests) +# Doing so will suppress errexit behavior inside runTests +runTests kube::log::status "TESTS PASSED" diff --git a/hack/make-rules/test-federation-cmd.sh b/hack/make-rules/test-federation-cmd.sh index bceeaac35b9..7d768def0bc 100755 --- a/hack/make-rules/test-federation-cmd.sh +++ b/hack/make-rules/test-federation-cmd.sh @@ -22,6 +22,8 @@ set -o nounset set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. +source "${KUBE_ROOT}/hack/lib/init.sh" +source "${KUBE_ROOT}/hack/lib/test.sh" source "${KUBE_ROOT}/hack/make-rules/test-cmd-util.sh" function run_federation_apiserver() { @@ -75,10 +77,8 @@ run_federation_apiserver run_federation_controller_manager # TODO: Fix for replicasets and deployments. SUPPORTED_RESOURCES=("configmaps" "daemonsets" "events" "ingress" "namespaces" "secrets" "services") -output_message=$(runTests "SUPPORTED_RESOURCES=${SUPPORTED_RESOURCES[@]}") -# Ensure that tests were run. We cannot check all resources here. We check a few -# to catch bugs due to which no tests run. -kube::test::if_has_string "${output_message}" "Testing kubectl(v1:namespaces)" -kube::test::if_has_string "${output_message}" "Testing kubectl(v1:services)" +# WARNING: Do not wrap this call in a subshell to capture output, e.g. output=$(runTests) +# Doing so will suppress errexit behavior inside runTests +runTests kube::log::status "TESTS PASSED"