Whamcloud - gitweb
LU-18390 tests: dump debug logs during module unload correctly 67/56767/5
authorEmoly Liu <emoly@whamcloud.com>
Sun, 3 Nov 2024 10:31:12 +0000 (18:31 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 24 Nov 2024 06:08:05 +0000 (06:08 +0000)
If DEBUG is enabled, debug logs will be dumped to:
- $TMP/debug by default if DEBUG_RMMOD is unset. And if memory
  leak is found, $TMP/debug will be renamed to $TMP/debug-leak.xxx;
- $DEBUG_RMMOD if $DEBUG_RMMOD is a full path name;
- $TMP/DEBUG_RMMOD if $DEBUG_RMMOD is a filename;
- standard output if DEBUG_RMMOD=- .

Memory leak in conf-sanity.sh test_29 in interop testing(LU-17962)
is used to verify this patch.

Test-Parameters: env=DEBUG=true,IGNORE_LEAK=yes,ONLY=29 \
  testlist=conf-sanity serverversion=2.15 clientdistro=el8.10 \
  serverdistro=el8.10 mdscount=2 mdtcount=4 ostcount=8
Test-Parameters: env=DEBUG_RMMOD=lu18390,IGNORE_LEAK=yes,ONLY=29 \
  testlist=conf-sanity serverversion=2.15 clientdistro=el8.10 \
  serverdistro=el8.10 mdscount=2 mdtcount=4 ostcount=8
Test-Parameters:trivial

Fixes: 255102e84e ("LU-16384 tests: dump lustre log if DEBUG_RMMOD set")
Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I23a584541d0f9b313cf00e56f63dc4ac356c3cbc
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56767
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/scripts/lustre_rmmod
lustre/tests/test-framework.sh

index 9dca753..bb4fe03 100755 (executable)
@@ -7,8 +7,13 @@
 
 SCRIPT_NAME="$(basename "$0")"
 LCTL=${LCTL:-lctl}
-DEBUG='false'
-[[ -n $DEBUG_RMMOD ]] && DEBUG='true'
+if [[ -z "$DEBUG" ]]; then
+       if [[ -n "$DEBUG_RMMOD" ]]; then
+               DEBUG=true
+       else
+               DEBUG=false
+       fi
+fi
 
 # Print help message
 print_usage() {
@@ -28,11 +33,14 @@ print_debug() {
        $LCTL mark "$SCRIPT_NAME : Stop debug"
        if [[ $DEBUG_RMMOD == "-" ]]; then
                debug_file="" # dump to stdout
+       elif [[ "${DEBUG_RMMOD:0:1}" == "/" ]]; then
+               debug_file="$DEBUG_RMMOD"
        else
-               debug_file=$DEBUG_RMMOD
+               debug_file=$TMP/${DEBUG_RMMOD:-debug}
        fi
+       echo "Dump memory leak logs to $debug_file"
        $LCTL debug_kernel $debug_file
-       DEBUG='false'
+       DEBUG=false
 }
 
 # Unload all modules dependent on $1 (exclude removal of $1)
index e8fa12b..c3f59fb 100755 (executable)
@@ -1188,9 +1188,13 @@ check_mem_leak () {
        if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
                echo "$LEAK_LUSTRE" 1>&2
                echo "$LEAK_PORTALS" 1>&2
-               mv $TMP/debug $TMP/debug-leak.`date +%s` || true
                echo "Memory leaks detected"
-               [ -n "$IGNORE_LEAK" ] &&
+               if [ $DEBUG -a -z $DEBUG_RMMOD ]; then
+                       debug_file=$TMP/debug-leak.$(date +%s)
+                       mv $TMP/debug $debug_file &&
+                       echo "Save $TMP/debug to $debug_file"
+               fi
+               [[ -n "$IGNORE_LEAK" ]] &&
                        { echo "ignoring leaks" && return 0; } || true
                return 1
        fi