mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Cleanup hack/test-integration.sh
Proper quoting, error checks, use $KUBE_* variables when applicable, trap to do cleanup on all errors, call cleanup explicitly on successful exit. Tested: - Ran it manually to completion, test run successful. - Interrupted it during the run, checked that $? was non-zero, etcd was killed. Signed-off-by: Filipe Brandenburger <filbranden@google.com>
This commit is contained in:
parent
7743f33359
commit
30db3e281d
@ -14,41 +14,40 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
source $(dirname $0)/util.sh
|
set -o errexit
|
||||||
source $(dirname $0)/config-go.sh
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
function cleanup()
|
basedir=$(dirname "$0")
|
||||||
{
|
source "${basedir}/config-go.sh"
|
||||||
set +e
|
|
||||||
kill ${ETCD_PID} 1>&2 2>/dev/null
|
source "${KUBE_REPO_ROOT}/hack/util.sh"
|
||||||
rm -rf ${ETCD_DIR} 1>&2 2>/dev/null
|
|
||||||
echo
|
cleanup() {
|
||||||
echo "Complete"
|
kill "${ETCD_PID-}" >/dev/null 2>&1 || :
|
||||||
|
rm -rf "${ETCD_DIR-}"
|
||||||
|
echo ""
|
||||||
|
echo "Complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stop right away if the build fails
|
if [[ "${KUBE_NO_BUILD_INTEGRATION+set}" != "set" ]]; then
|
||||||
set -e
|
"${KUBE_REPO_ROOT}/hack/build-go.sh" cmd/integration
|
||||||
|
|
||||||
if [[ -z $KUBE_NO_BUILD_INTEGRATION ]]; then
|
|
||||||
$(dirname $0)/build-go.sh cmd/integration
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run cleanup to stop etcd on interrupt or other kill signal.
|
||||||
|
trap cleanup HUP INT QUIT TERM
|
||||||
|
|
||||||
start_etcd
|
start_etcd
|
||||||
|
|
||||||
trap cleanup EXIT SIGINT
|
echo ""
|
||||||
|
echo "Integration test cases..."
|
||||||
echo
|
echo ""
|
||||||
echo Integration test cases ...
|
|
||||||
echo
|
|
||||||
GOFLAGS="-tags 'integration no-docker'" \
|
GOFLAGS="-tags 'integration no-docker'" \
|
||||||
${KUBE_REPO_ROOT}/hack/test-go.sh test/integration
|
"${KUBE_REPO_ROOT}/hack/test-go.sh" test/integration
|
||||||
# leave etcd running if integration tests fail
|
|
||||||
trap "echo etcd still running" EXIT
|
|
||||||
|
|
||||||
echo
|
echo ""
|
||||||
echo Integration scenario ...
|
echo "Integration scenario ..."
|
||||||
echo
|
echo ""
|
||||||
${KUBE_TARGET}/bin/integration
|
"${KUBE_TARGET}/bin/integration"
|
||||||
|
|
||||||
# nuke etcd
|
cleanup
|
||||||
trap cleanup EXIT SIGINT
|
|
||||||
|
Loading…
Reference in New Issue
Block a user