From 730b678dde39f0e4e3f5f9d2028af1f9ff2ef56b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Mon, 22 Oct 2018 17:53:37 -0400 Subject: [PATCH 1/2] Fail integration tests with invariant violated logs --- test-integration.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test-integration.sh b/test-integration.sh index 5b9bb7e..b7c6a24 100755 --- a/test-integration.sh +++ b/test-integration.sh @@ -52,13 +52,28 @@ pick_subset "$ALL_TESTS" TESTS $SPLIT_IDX $TOTAL_SPLITS # execute tests one by one for isolation for TEST in $TESTS; do - ./integration.test -test.v -test.run $TEST -test.coverprofile temp_${COVERFILE} \ - -test.timeout $INTEGRATION_TIMEOUT ./integration + echo "Running $TEST" + + OUTPUT="$(./integration.test -test.v -test.run $TEST -test.coverprofile temp_${COVERFILE} \ + -test.timeout $INTEGRATION_TIMEOUT ./integration)" + + # Check if any invariant violated logs were emitted and if so fail the test + # regardless of the exit code. + shopt -s nocasematch + if [[ $OUTPUT == *"invariant"* ]]; then + echo "Invariant violation detected!" + echo "$OUTPUT" + exit 1 + fi + shopt -u nocasematch + TEST_EXIT=$? if [ "$TEST_EXIT" != "0" ]; then echo "$TEST failed" - exit $TEST_EXIT + echo "$OUTPUT" + exit "$TEST_EXIT" fi + cat temp_${COVERFILE} | grep -v "mode:" >> ${SCRATCH_FILE} sleep 0.1 done From 70063ddd7cc142cc57ab2969632584d80e072d20 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 23 Oct 2018 10:53:44 -0400 Subject: [PATCH 2/2] Check exit code before invariant checks --- test-integration.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test-integration.sh b/test-integration.sh index b7c6a24..4be159f 100755 --- a/test-integration.sh +++ b/test-integration.sh @@ -57,6 +57,13 @@ for TEST in $TESTS; do OUTPUT="$(./integration.test -test.v -test.run $TEST -test.coverprofile temp_${COVERFILE} \ -test.timeout $INTEGRATION_TIMEOUT ./integration)" + TEST_EXIT=$? + if [ "$TEST_EXIT" != "0" ]; then + echo "$TEST failed" + echo "$OUTPUT" + exit "$TEST_EXIT" + fi + # Check if any invariant violated logs were emitted and if so fail the test # regardless of the exit code. shopt -s nocasematch @@ -67,13 +74,6 @@ for TEST in $TESTS; do fi shopt -u nocasematch - TEST_EXIT=$? - if [ "$TEST_EXIT" != "0" ]; then - echo "$TEST failed" - echo "$OUTPUT" - exit "$TEST_EXIT" - fi - cat temp_${COVERFILE} | grep -v "mode:" >> ${SCRATCH_FILE} sleep 0.1 done