From ac406e652e2f7751e2248f030c1b5a5b615efdf4 Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Wed, 21 Dec 2016 11:51:53 +0100 Subject: [PATCH 1/2] Print log if error occurs --- end-to-end-test.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/end-to-end-test.sh b/end-to-end-test.sh index 8efd36bf..e68fd2ac 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -24,7 +24,6 @@ collectors=$(cat << COLLECTORS megacli COLLECTORS ) - cd "$(dirname $0)" port="$((10000 + (RANDOM % 10000)))" @@ -74,11 +73,13 @@ fi echo $! > "${tmpdir}/node_exporter.pid" finish() { - if [ ${verbose} -ne 0 ] + if [ $? -ne 0 -o ${verbose} -ne 0 ] then - echo "LOG =====================" - cat "${tmpdir}/node_exporter.log" - echo "=========================" + cat << EOF >&2 +LOG ===================== +$(cat "${tmpdir}/node_exporter.log") +========================= +EOF fi if [ ${update} -ne 0 ] From 3b1ef14e7b3cced28e40f9c8a6a290f272198a06 Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Wed, 21 Dec 2016 12:00:32 +0100 Subject: [PATCH 2/2] Add end-to-end tests as default Makefile target --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ef94cec9..a8542404 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ DOCKER_IMAGE_NAME ?= node-exporter DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) -all: format build test +all: format build test test-e2e style: @echo ">> checking code style" @@ -31,6 +31,10 @@ test: @echo ">> running tests" @$(GO) test -short $(pkgs) +test-e2e: build + @echo ">> running end-to-end tests" + ./end-to-end-test.sh + format: @echo ">> formatting code" @$(GO) fmt $(pkgs) @@ -57,4 +61,4 @@ promu: $(GO) get -u github.com/prometheus/promu -.PHONY: all style format build test vet tarball docker promu +.PHONY: all style format build test test-e2e vet tarball docker promu