]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: extract display_log()
authorKefu Chai <kchai@redhat.com>
Sat, 27 Jun 2020 16:57:43 +0000 (00:57 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 29 Jun 2020 08:30:12 +0000 (16:30 +0800)
so it can be reused to display log created by other services, for
instance, osd.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/dashboard/run-backend-api-tests.sh

index 2fd61c57e916c77051dd9856650bc4cdc28103ef..5d9e6f9fbac7d1308f25eb3e1765dd4d814dea06 100755 (executable)
@@ -64,17 +64,25 @@ setup_coverage() {
     deactivate
 }
 
+display_log() {
+    local daemon=$1
+    shift
+    local lines=$1
+    shift
+
+    local log_files=$(find "$CEPH_OUT_DIR" -iname "${daemon}.*.log" | tr '\n' ' ')
+    for log_file in ${log_files[@]}; do
+        printf "\n\nDisplaying last ${lines} lines of: ${log_file}\n\n"
+        tail -n ${lines} $log_file
+        printf "\n\nEnd of: ${log_file}\n\n"
+    done
+    printf "\n\nTEST FAILED.\n\n"
+}
+
 on_tests_error() {
     if [[ -n "$JENKINS_HOME" ]]; then
         CEPH_OUT_DIR=${CEPH_OUT_DIR:-"$LOCAL_BUILD_DIR"/out}
-        MGR_LOG_FILES=$(find "$CEPH_OUT_DIR" -iname "mgr.*.log" | tr '\n' ' ')
-        MGR_LOG_FILE_LAST_LINES=60000
-        for mgr_log_file in ${MGR_LOG_FILES[@]}; do
-            printf "\n\nDisplaying last ${MGR_LOG_FILE_LAST_LINES} lines of: $mgr_log_file\n\n"
-            tail -n ${MGR_LOG_FILE_LAST_LINES} $mgr_log_file
-            printf "\n\nEnd of: $mgr_log_file\n\n"
-        done
-        printf "\n\nTEST FAILED.\n\n"
+        display_log "mgr" 60000
     fi
 }