Whamcloud - gitweb
LU-1458 test: enable lustre_rsync debug log dump
[fs/lustre-release.git] / lustre / tests / lustre-rsync-test.sh
index e09985e..49918ae 100644 (file)
@@ -42,7 +42,7 @@ build_test_filter
 
 export LRSYNC=${LRSYNC:-"$LUSTRE/utils/lustre_rsync"}
 [ ! -f "$LRSYNC" ] && export LRSYNC=$(which lustre_rsync)
-export LRSYNC="$LRSYNC -v" # -a
+export LRSYNC="$LRSYNC -v -c no -d 2"
 
 # control the time of tests
 DBENCH_TIME=${DBENCH_TIME:-60}  # No of seconds to run dbench
@@ -108,13 +108,16 @@ check_xattr() {
 }
 
 check_diff() {
-    if [ -e $1 -o -e $2 ]; then 
-        diff -rq -x "dev1" $1 $2
-        local RC=$?
-        if [ $RC -ne 0 ]; then
-            error "Failure in replication; differences found."
-        fi
-    fi
+       local changelog_file=$(generate_logname "changelog")
+
+       if [ -e $1 -o -e $2 ]; then
+               diff -rq -x "dev1" $1 $2
+               local RC=$?
+               if [ $RC -ne 0 ]; then
+                       $LFS changelog $MDT0 > $changelog_file
+                       error "Failure in replication; differences found."
+               fi
+       fi
 }
 
 # Test 1 - test basic operations
@@ -152,9 +155,11 @@ test_1() {
     # Device files
     #mknod $DIR/$tdir/dev1 b 8 1
 
-    # Replicate
-    echo "Replication #1"
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       # Replicate
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       echo "Replication #1"
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
     # Set attributes
     chmod 000 $DIR/$tdir/d2/file3
@@ -169,8 +174,8 @@ test_1() {
         setfattr -n user.foo -v $value $DIR/$tdir/file5
     fi
 
-    echo "Replication #2"
-    $LRSYNC -l $LREPL_LOG
+       echo "Replication #2"
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
 
     if [[ "$xattr" != "no" ]]; then
         local xval1=$(get_xattr_value user.foo $TGT/$tdir/file5)
@@ -191,9 +196,9 @@ test_1() {
         RC=1
     fi
 
-    # Use diff to compare the source and the destination
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       # Use diff to compare the source and the destination
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -201,7 +206,7 @@ test_1() {
 }
 run_test 1 "Simple Replication"
 
-# Test 2a - Replicate files created by dbench 
+# Test 2a - Replicate files created by dbench
 test_2a() {
     [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
     init_src
@@ -210,12 +215,14 @@ test_2a() {
     # Run dbench
     sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME || error "dbench failed!"
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    # Use diff to compare the source and the destination
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       # Use diff to compare the source and the destination
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -240,9 +247,11 @@ test_2b() {
     echo Stopping dbench
     $KILL -SIGSTOP $child_pid
 
-    echo Starting replication
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       echo Starting replication
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
 
     echo Resuming dbench
     $KILL -SIGCONT $child_pid
@@ -251,20 +260,20 @@ test_2b() {
     echo Stopping dbench
     $KILL -SIGSTOP $child_pid
 
-    echo Starting replication
-    $LRSYNC -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
+       echo Starting replication
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
 
     echo "Wait for dbench to finish"
     $KILL -SIGCONT $child_pid
     wait
 
-    # Replicate the changes to $TGT
-    echo Starting replication
-    $LRSYNC -l $LREPL_LOG
+       # Replicate the changes to $TGT
+       echo Starting replication
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
 
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -272,7 +281,7 @@ test_2b() {
 }
 run_test 2b "Replicate files changed by dbench."
 
-# Test 2c - Replicate files while dbench is running 
+# Test 2c - Replicate files while dbench is running
 test_2c() {
     [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
     init_src
@@ -281,23 +290,25 @@ test_2c() {
     # Run dbench
     sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
 
-    # Replicate the changes to $TGT
-    sleep 10 # give dbench a headstart
-    local quit=0
-    while [ $quit -le 1 ];
-    do
-        echo "Running lustre_rsync"
-        $LRSYNC -s $DIR -t $TGT -t $TGT2 -m ${mds1_svc} -u $CL_USER -l $LREPL_LOG
-        sleep 5
-        pgrep dbench
-        if [ $? -ne 0 ]; then
-            quit=$(expr $quit + 1)
-        fi
-    done
-
-    # Use diff to compare the source and the destination
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       sleep 10 # give dbench a headstart
+       local quit=0
+       while [ $quit -le 1 ];
+       do
+               echo "Running lustre_rsync"
+               $LRSYNC -s $DIR -t $TGT -t $TGT2 -m ${mds1_svc} -u $CL_USER \
+                       -l $LREPL_LOG -D $LRSYNC_LOG
+               sleep 5
+               pgrep dbench
+               if [ $? -ne 0 ]; then
+                       quit=$(expr $quit + 1)
+               fi
+       done
+
+       # Use diff to compare the source and the destination
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -315,10 +326,12 @@ test_3a() {
     local numfiles=1000
     createmany -o $DIR/$tdir/$tfile $numfiles || error "createmany failed!"
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -338,11 +351,13 @@ test_3b() {
     local threads=5
     writemany -q -a $DIR/$tdir/$tfile $time $threads || error "writemany failed!"
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -361,10 +376,12 @@ test_3c() {
     createmany -o $DIR/$tdir/$tfile $numfiles || error "createmany failed!"
     unlinkmany $DIR/$tdir/$tfile $numfiles || error "unlinkmany failed!"
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -391,10 +408,12 @@ test_4() {
     child_pid=$(pgrep iozone)
     $KILL -SIGSTOP $child_pid
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     $KILL -SIGCONT $child_pid
     sleep 60
@@ -413,9 +432,9 @@ test_4() {
       sleep 1;
     done
 
-    $LRSYNC -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -433,17 +452,18 @@ test_5a() {
     NUMTEST=2000
     createmany -o $DIR/$tdir/$tfile $NUMTEST
 
-    # Replicate the changes to $TGT
-    
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG &
-    local child_pid=$!
-    sleep 30
-    $KILL -SIGHUP $child_pid
-    wait
-    $LRSYNC -l $LREPL_LOG
+       # Replicate the changes to $TGT
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG &
+       local child_pid=$!
+       sleep 30
+       $KILL -SIGHUP $child_pid
+       wait
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
 
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -461,17 +481,18 @@ test_5b() {
     NUMTEST=2000
     createmany -o $DIR/$tdir/$tfile $NUMTEST
 
-    # Replicate the changes to $TGT
-    
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG &
-    local child_pid=$!
-    sleep 30
-    $KILL -SIGKILL $child_pid
-    wait
-    $LRSYNC -l $LREPL_LOG
+       # Replicate the changes to $TGT
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG &
+       local child_pid=$!
+       sleep 30
+       $KILL -SIGKILL $child_pid
+       wait
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
 
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -493,10 +514,12 @@ test_6() {
       i=$(expr $i + 1)
     done
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     local count1=$(ls -l $TGT/$tdir/link0 | sed -r 's/ +/ /g' | cut -f 2 -d ' ')
     local count2=$(ls -l $TGT/$tdir/link0 | sed -r 's/ +/ /g' | cut -f 2 -d ' ')
@@ -520,26 +543,29 @@ test_7() {
     lfs setstripe -c $OSTCOUNT $DIR/$tdir
     createmany -o $DIR/$tdir/$tfile $NUMFILES
 
-    # To simulate replication to another lustre filesystem, replicate
-    # the changes to $DIR/tgt. We can't turn off the changelogs
-    # while we are registered, so lustre_rsync better not try to 
-    # replicate the replication steps.  It seems ok :)
-
-    $LRSYNC -s $DIR -t $DIR/tgt -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff ${DIR}/$tdir $DIR/tgt/$tdir
-
-    local i=0
-    while [ $i -lt $NUMFILES ];
-    do
-      local count=$(lfs getstripe $DIR/tgt/$tdir/${tfile}$i | awk '/stripe_count/ {print $2}')
-      if [ $count -ne $OSTCOUNT ]; then
-         error "Stripe size not replicated" 
-      fi
-      i=$(expr $i + 1)
-    done
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       # To simulate replication to another lustre filesystem, replicate
+       # the changes to $DIR/tgt. We can't turn off the changelogs
+       # while we are registered, so lustre_rsync better not try to
+       # replicate the replication steps.  It seems ok :)
+
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $DIR/tgt -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff ${DIR}/$tdir $DIR/tgt/$tdir
+
+       local i=0
+       while [ $i -lt $NUMFILES ];
+       do
+               local count=$(lfs getstripe $DIR/tgt/$tdir/${tfile}$i | \
+                             awk '/stripe_count/ {print $2}')
+               if [ $count -ne $OSTCOUNT ]; then
+                       error "Stripe size not replicated"
+               fi
+               i=$(expr $i + 1)
+       done
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 7 "lustre_rsync stripesize"
 
@@ -562,9 +588,11 @@ test_8() {
            mv $DIR/$tdir/d$i $DIR/$tdir/d0$i
     done
 
-    $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff ${DIR}/$tdir $TGT/$tdir
+       check_diff ${DIR}/$tdir $TGT/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -579,15 +607,18 @@ test_9() {
     mkdir $DIR/$tdir/foo
     touch $DIR/$tdir/foo/a1
 
-    $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff ${DIR}/$tdir $TGT/$tdir
+       check_diff ${DIR}/$tdir $TGT/$tdir
 
-    rm -rf $DIR/$tdir/foo
+       rm -rf $DIR/$tdir/foo
 
-    $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff ${DIR}/$tdir $TGT/$tdir
+       check_diff ${DIR}/$tdir $TGT/$tdir
 
     fini_changelog
     cleanup_src_tgt