From 5bdcf00e873e43ece436d2868eb55312e340d8c0 Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Fri, 28 Feb 2020 14:46:59 -0700 Subject: [PATCH] qa/workunits/cephadm/test_cephadm.sh: dump logs on exit dumps the last few lines from each of the surviving daemon logs Signed-off-by: Michael Fritch --- qa/workunits/cephadm/test_cephadm.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/qa/workunits/cephadm/test_cephadm.sh b/qa/workunits/cephadm/test_cephadm.sh index 15ed7f71475f..cc273343631d 100755 --- a/qa/workunits/cephadm/test_cephadm.sh +++ b/qa/workunits/cephadm/test_cephadm.sh @@ -14,6 +14,7 @@ TMPDIR=$(mktemp -d) function cleanup() { + dump_all_logs rm -rf $TMPDIR } trap cleanup EXIT @@ -111,6 +112,32 @@ function is_available() true } +function dump_log() +{ + local name="$1" + local num_lines="$2" + + if [ -z $num_lines ]; then + num_lines=100 + fi + + echo '-------------------------' + echo 'dump daemon log:' $name + echo '-------------------------' + + $CEPHADM logs --name $name -- --no-pager -n $num_lines +} + +function dump_all_logs() +{ + names=$($CEPHADM ls | jq -r '.[].name') + + echo 'dumping logs for daemons: ' $names + for name in $names; do + dump_log $name + done +} + ## prepare + check host $SUDO $CEPHADM check-host -- 2.47.3