diff options
author | Martin Schwenke <martin@meltin.net> | 2019-10-17 15:53:09 +1100 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2019-10-22 19:39:40 +0000 |
commit | 787662604d4f578f10981845997ccd995f11d853 (patch) | |
tree | 666c761aa709319c59a4d971cdcad412c368b463 /ctdb | |
parent | 5ae330e5a56553b8809f710230101acf044c98e3 (diff) | |
download | samba-787662604d4f578f10981845997ccd995f11d853.tar.gz |
ctdb-tests: Add run_tests.sh option to print logs on test failure
Implement this for local daemons integration tests, dumping last 100
lines of logs. This makes it possible to debug some failures in
automated tests where the logs are unavailable for analysis.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/tests/run_tests.sh | 5 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration_local_daemons.bash | 17 |
2 files changed, 21 insertions, 1 deletions
diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index c162aa54bc4..8304443b196 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -12,6 +12,7 @@ Options: -e Exit on the first test failure -H No headers - for running single test with other wrapper -I <count> Iterate tests <count> times, exiting on failure (implies -e, -N) + -L Print daemon logs on test failure (only some tests) -N Don't print summary of tests results after running all tests -q Quiet - don't show tests being run (still displays summary) -S <lib> Use socket wrapper library <lib> for local integration tests @@ -44,11 +45,12 @@ export TEST_VERBOSE=false export TEST_COMMAND_TRACE=false export TEST_CAT_RESULTS_OPTS="" export TEST_DIFF_RESULTS=false +export CTDB_TEST_PRINT_LOGS_ON_ERROR=false export TEST_LOCAL_DAEMONS [ -n "$TEST_LOCAL_DAEMONS" ] || TEST_LOCAL_DAEMONS=3 export TEST_SOCKET_WRAPPER_SO_PATH="" -while getopts "AcCDehHI:NqS:T:vV:xX?" opt ; do +while getopts "AcCDehHI:LNqS:T:vV:xX?" opt ; do case "$opt" in A) TEST_CAT_RESULTS_OPTS="-A" ;; c) TEST_LOCAL_DAEMONS="" ;; @@ -57,6 +59,7 @@ while getopts "AcCDehHI:NqS:T:vV:xX?" opt ; do e) exit_on_fail=true ;; H) no_header=true ;; I) max_iterations="$OPTARG" ; exit_on_fail=true ; with_summary=false ;; + L) CTDB_TEST_PRINT_LOGS_ON_ERROR=true ;; N) with_summary=false ;; q) quiet=true ;; S) TEST_SOCKET_WRAPPER_SO_PATH="$OPTARG" ;; diff --git a/ctdb/tests/scripts/integration_local_daemons.bash b/ctdb/tests/scripts/integration_local_daemons.bash index 327c69a9ea9..ec9c477bb0f 100644 --- a/ctdb/tests/scripts/integration_local_daemons.bash +++ b/ctdb/tests/scripts/integration_local_daemons.bash @@ -39,6 +39,10 @@ setup_ctdb () rm -vf "${CTDB_BASE}/events/legacy/"* done fi + + if $CTDB_TEST_PRINT_LOGS_ON_ERROR ; then + ctdb_test_exit_hook_add _print_logs_on_test_failure + fi } start_ctdb_1 () @@ -75,3 +79,16 @@ onnode () { $ctdb_local_daemons onnode "$@" } + +_print_logs_on_test_failure () +{ + # This is called from ctdb_test_exit() where $status is available + # shellcheck disable=SC2154 + if [ "$status" -eq 0 ] ; then + return + fi + + echo "*** LOG START --------------------" + $ctdb_local_daemons print-log all | tail -n 100 + echo "*** LOG END --------------------" +} |