]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/workunits/cephadm/test_cephadm.sh: dump logs on exit
authorMichael Fritch <mfritch@suse.com>
Fri, 28 Feb 2020 21:46:59 +0000 (14:46 -0700)
committerMichael Fritch <mfritch@suse.com>
Fri, 28 Feb 2020 22:26:56 +0000 (15:26 -0700)
dumps the last few lines from each of the surviving daemon logs

Signed-off-by: Michael Fritch <mfritch@suse.com>
qa/workunits/cephadm/test_cephadm.sh

index 15ed7f71475fa567b23c3667ca93efc61b1dea04..cc273343631d192720211d38942f28459805b39b 100755 (executable)
@@ -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