Whamcloud - gitweb
Branch b1_6
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
index cc0ed11..f053663 100644 (file)
@@ -28,6 +28,9 @@ HOSTNAME=`hostname`
 
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
+# use small MDS + OST size to speed formatting time
+MDSSIZE=40000
+OSTSIZE=40000
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 
 reformat() {
@@ -87,6 +90,16 @@ stop_ost2() {
        stop ost2 -f  || return 93
 }
 
+start_client() {
+       echo "start client on `facet_active_host client`"
+       start client || return 99 
+}
+
+stop_client() {
+       echo "stop client on `facet_active_host client`"
+       stop client || return 100 
+}
+
 mount_client() {
        local MOUNTPATH=$1
        echo "mount $FSNAME on ${MOUNTPATH}....."
@@ -109,8 +122,12 @@ umount_client() {
 }
 
 manual_umount_client(){
+       local rc
+       local FORCE=$1
        echo "manual umount lustre on ${MOUNT}...."
-       do_facet client "umount -d $MOUNT"
+       do_facet client "umount -d ${FORCE} $MOUNT"
+       rc=$?
+       return $rc
 }
 
 setup() {
@@ -231,8 +248,8 @@ test_5() {
        kill -TERM $UMOUNT_PID
        echo "waiting for umount to finish"
        wait $UMOUNT_PID
-       if grep " $MOUNT " /etc/mtab; then
-               echo "test 5: mtab after failed umount"
+       if grep " $MOUNT " /proc/mounts; then
+               echo "test 5: /proc/mounts after failed umount"
                umount $MOUNT &
                UMOUNT_PID=$!
                sleep 2
@@ -240,7 +257,7 @@ test_5() {
                kill -TERM $UMOUNT_PID
                echo "waiting for umount to finish"
                wait $UMOUNT_PID
-               grep " $MOUNT " /etc/mtab && echo "test 5: mtab after second umount" && return 11
+               grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
        fi
 
        manual_umount_client
@@ -611,54 +628,53 @@ run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
 test_16() {
         TMPMTPT="${MOUNT%/*}/conf16"
 
-        if [ ! -f "$MDSDEV" ]; then
-            echo "no $MDSDEV existing, so mount Lustre to create one"
-           setup
+        if [ ! -e "$MDSDEV" ]; then
+            log "no $MDSDEV existing, so mount Lustre to create one"
+            setup
             check_mount || return 41
             cleanup || return $?
         fi
 
-        echo "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
+        [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
+
+        log "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
         do_facet mds "mkdir -p $TMPMTPT &&
-                      mount -o loop -t ext3 $MDSDEV $TMPMTPT &&
+                      mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
                       chmod 555 $TMPMTPT/{OBJECTS,LOGS,PENDING} &&
                       umount $TMPMTPT" || return $?
 
-        echo "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
+        log "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
        setup
         check_mount || return 41
         cleanup || return $?
 
-        echo "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
+        log "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
         EXPECTEDOBJECTSMODE=`do_facet mds "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
         EXPECTEDLOGSMODE=`do_facet mds "debugfs -R 'stat LOGS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
         EXPECTEDPENDINGMODE=`do_facet mds "debugfs -R 'stat PENDING' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
 
         if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
-                echo "Success:Lustre change the mode of OBJECTS correctly"
+                log "Success:Lustre change the mode of OBJECTS correctly"
         else
-                echo "Error: Lustre does not change mode of OBJECTS properly"
-                return 1
+                error "Lustre does not change mode of OBJECTS properly"
         fi
 
         if [ "$EXPECTEDLOGSMODE" = "0777" ]; then
-                echo "Success:Lustre change the mode of LOGS correctly"
+                log "Success:Lustre change the mode of LOGS correctly"
         else
-                echo "Error: Lustre does not change mode of LOGS properly"
-                return 1
+                error "Lustre does not change mode of LOGS properly"
         fi
 
         if [ "$EXPECTEDPENDINGMODE" = "0777" ]; then
-                echo "Success:Lustre change the mode of PENDING correctly"
+                log "Success:Lustre change the mode of PENDING correctly"
         else
-                echo "Error: Lustre does not change mode of PENDING properly"
-                return 1
+                error "Lustre does not change mode of PENDING properly"
         fi
 }
 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
 
 test_17() {
-        if [ ! -f "$MDSDEV" ]; then
+        if [ ! -e "$MDSDEV" ]; then
             echo "no $MDSDEV existing, so mount Lustre to create one"
            setup
             check_mount || return 41
@@ -687,13 +703,11 @@ test_18() {
         check_mount || return 41
 
         echo "check journal size..."
-        FOUNDJOURNALSIZE=`do_facet mds "debugfs -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
-        if [ "$FOUNDJOURNALSIZE" = "79691776" ]; then
-                echo "Success:lconf creates large journals"
+        FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
+        if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
+                log "Success: mkfs creates large journals"
         else
-                echo "Error:lconf not create large journals correctly"
-                echo "expected journal size: 79691776(76M), found journal size: $FOUNDJOURNALSIZE"
-                return 1
+                error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
         fi
 
         cleanup || return $?
@@ -701,7 +715,7 @@ test_18() {
         MDSSIZE=$OLDMDSSIZE
         gen_config
 }
-run_test 18 "check lconf creates large journals"
+run_test 18 "check mkfs creates large journals"
 
 test_19a() {
        start_mds || return 1
@@ -815,16 +829,22 @@ test_23() {
 
 test_24a() {
        local fs2mds_HOST=$mds_HOST
+       local fs2ost_HOST=$ost_HOST
+
+       [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
+            log "mixed loopback and real device not working" && return
+
+       local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
+       local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
+
        # test 8-char fsname as well
        local FSNAME2=test1234
-        add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat ${MDSDEV}_2 || exit 10
+       add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
 
-       local fs2ost_HOST=$ost_HOST
-       local fs2ostdev=$(ostdevname 1)_2
        add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
 
        setup
-       start fs2mds ${MDSDEV}_2 $MDS_MOUNT_OPTS
+       start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
        start fs2ost $fs2ostdev $OST_MOUNT_OPTS
        mkdir -p $MOUNT2
        mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
@@ -846,7 +866,7 @@ test_24a() {
        umount_client $MOUNT 
        # the MDS must remain up until last MDT
        stop_mds
-       MDS=$(awk '($3 ~ "mdt" && $4 ~ "MDS") { print $4 }' $LPROC/devices)
+       MDS=$(do_facet mds "cat $LPROC/devices" | awk '($3 ~ "mdt" && $4 ~ "MDS") { print $4 }')
        [ -z "$MDS" ] && error "No MDS" && return 8
        umount $MOUNT2
        stop fs2mds -f
@@ -857,9 +877,14 @@ run_test 24a "Multiple MDTs on a single node"
 
 test_24b() {
        local fs2mds_HOST=$mds_HOST
-        add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat ${MDSDEV}_2 || exit 10
+        [ -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
+            log "mixed loopback and real device not working" && return
+
+       local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
+
+        add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10 
        setup
-       start fs2mds ${MDSDEV}_2 $MDS_MOUNT_OPTS && return 2
+       start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
        cleanup || return 6
 }
 run_test 24b "Multiple MGSs on a single node (should return err)"
@@ -876,7 +901,7 @@ run_test 25 "Verify modules are referenced"
 test_26() {
     load_modules
     # we need modules before mount for sysctl, so make sure...
-    [ -z "$(lsmod | grep lustre)" ] && modprobe lustre 
+    do_facet mds "lsmod | grep -q lustre || modprobe lustre"
 #define OBD_FAIL_MDS_FS_SETUP            0x135
     do_facet mds "sysctl -w lustre.fail_loc=0x80000135"
     start_mds && echo MDS started && return 1
@@ -888,23 +913,24 @@ test_26() {
 run_test 26 "MDT startup failure cleans LOV (should return errs)"
 
 set_and_check() {
-        local TEST=$1
-       local PARAM=$2
-       local ORIG=$($TEST) 
-       if [ $# -gt 2 ]; then
-           local FINAL=$3
+       local myfacet=$1
+       local TEST=$2
+       local PARAM=$3
+       local ORIG=$(do_facet $myfacet "$TEST") 
+       if [ $# -gt 3 ]; then
+           local FINAL=$4
        else
            local -i FINAL
            FINAL=$(($ORIG + 5))
        fi
        echo "Setting $PARAM from $ORIG to $FINAL"
-       $LCTL conf_param $PARAM=$FINAL
+       do_facet mds "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
        local RESULT
        local MAX=30
        local WAIT=0
        while [ 1 ]; do
            sleep 5
-           RESULT=$($TEST
+           RESULT=$(do_facet $myfacet "$TEST"
            if [ $RESULT -eq $FINAL ]; then
                echo "Updated config after $WAIT sec (got $RESULT)"
                break
@@ -923,7 +949,7 @@ test_27a() {
        start_mds || return 2
        echo "Requeue thread should have started: " 
        ps -e | grep ll_cfg_requeue 
-       set_and_check "cat $LPROC/obdfilter/$FSNAME-OST0000/client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3 
+       set_and_check ost1 "cat $LPROC/obdfilter/$FSNAME-OST0000/client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3 
        cleanup_nocli
 }
 run_test 27a "Reacquire MGS lock if OST started first"
@@ -931,8 +957,8 @@ run_test 27a "Reacquire MGS lock if OST started first"
 test_27b() {
         setup
        facet_failover mds
-       set_and_check "cat $LPROC/mds/$FSNAME-MDT0000/group_acquire_expire" "$FSNAME-MDT0000.mdt.group_acquire_expire" || return 3 
-       set_and_check "cat $LPROC/mdc/$FSNAME-MDT0000-mdc-*/max_rpcs_in_flight" "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4 
+       set_and_check mds "cat $LPROC/mds/$FSNAME-MDT0000/group_acquire_expire" "$FSNAME-MDT0000.mdt.group_acquire_expire" || return 3 
+       set_and_check client "cat $LPROC/mdc/$FSNAME-MDT0000-mdc-*/max_rpcs_in_flight" "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4 
        cleanup
 }
 run_test 27b "Reacquire MGS lock after failover"
@@ -943,8 +969,8 @@ test_28() {
        ORIG=$($TEST) 
        declare -i FINAL
        FINAL=$(($ORIG + 10))
-       set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
-       set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
+       set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
+       set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
        umount_client $MOUNT || return 200
        mount_client $MOUNT
        RESULT=$($TEST)
@@ -974,7 +1000,7 @@ test_29() {
        fi
        ACTV=$(cat $PROC_ACT)
        DEAC=$((1 - $ACTV))
-       set_and_check "cat $PROC_ACT" "$PARAM" $DEAC || return 2
+       set_and_check client "cat $PROC_ACT" "$PARAM" $DEAC || return 2
         # also check ost_server_uuid status
        RESULT=$(grep DEACTIV $PROC_UUID)
        if [ -z "$RESULT" ]; then
@@ -986,15 +1012,14 @@ test_29() {
 
        # check MDT too 
        local MPROC="$LPROC/osc/$FSNAME-OST0001-osc/active"
-       if [ -r $MPROC ]; then
-           RESULT=$(cat $MPROC)
-           if [ $RESULT -ne $DEAC ]; then
-               echo "MDT not deactivated: $(cat $MPROC)"
-               return 4
-           fi
-           echo "MDT deactivated also"
+        RESULT=`do_facet mds " [ -r $MPROC ] && cat $MPROC"`
+        [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
+        if [ $RESULT -ne $DEAC ]; then
+            echo "MDT not deactivated: $RESULT"
+            return 4
+        else
+            echo "MDT deactivated: also"
        fi
-
         # test new client starts deactivated
        umount_client $MOUNT || return 200
        mount_client $MOUNT
@@ -1007,7 +1032,7 @@ test_29() {
        fi
 
        # make sure it reactivates
-       set_and_check "cat $PROC_ACT" "$PARAM" $ACTV || return 6
+       set_and_check client "cat $PROC_ACT" "$PARAM" $ACTV || return 6
 
        umount_client $MOUNT
        stop_ost2
@@ -1025,13 +1050,13 @@ test_30() {
        TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
        ORIG=$($TEST) 
        for i in $(seq 1 20); do 
-           set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
+           set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
        done
        # make sure client restart still works 
        umount_client $MOUNT
        mount_client $MOUNT || return 4
        [ "$($TEST)" -ne "$i" ] && return 5   
-       set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
+       set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
        cleanup
 }
 run_test 30 "Big config llog"
@@ -1044,6 +1069,11 @@ test_31() { # bug 10734
 run_test 31 "Connect to non-existent node (shouldn't crash)"
 
 test_32a() {
+        # XXX - make this run on client-only systems with real hardware on
+        #       the OST and MDT
+        #       there appears to be a lot of assumption here about loopback
+        #       devices
+        # or maybe this test is just totally useless on a client-only system
         [ -z "$TUNEFS" ] && echo "No tunefs" && return
         [ ! -r disk1_4.zip ] && echo "Cant find disk1_4.zip, skipping" && return
        unzip -o -j -d $TMP/$tdir disk1_4.zip || { echo "Cant unzip disk1_4, skipping" && return ; }
@@ -1075,9 +1105,11 @@ test_32a() {
        echo "ok."
 
        cleanup_nocli
+       load_modules
 
         # mount a second time to make sure we didnt leave upgrade flag on
         $TUNEFS --dryrun $TMP/$tdir/mds || error "tunefs failed"
+       load_modules
         start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 12
         cleanup_nocli
 
@@ -1086,6 +1118,11 @@ test_32a() {
 run_test 32a "Upgrade from 1.4 (not live)"
 
 test_32b() {
+        # XXX - make this run on client-only systems with real hardware on
+        #       the OST and MDT
+        #       there appears to be a lot of assumption here about loopback
+        #       devices
+        # or maybe this test is just totally useless on a client-only system
         [ -z "$TUNEFS" ] && echo "No tunefs" && return
         [ ! -r disk1_4.zip ] && echo "Cant find disk1_4.zip, skipping" && return
        unzip -o -j -d $TMP/$tdir disk1_4.zip || { echo "Cant unzip disk1_4, skipping" && return ; }
@@ -1117,7 +1154,7 @@ test_32b() {
        # a fully-functioning client
        echo "Check client and old fs contents"
        mount_client $MOUNT
-       set_and_check "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
+       set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
        [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12  
        echo "ok."
 
@@ -1126,8 +1163,142 @@ test_32b() {
 }
 run_test 32b "Upgrade from 1.4 with writeconf"
 
+test_33() { # bug 12333
+        local FSNAME2=test1234
+        local fs2mds_HOST=$mds_HOST
+        local fs2ost_HOST=$ost_HOST
+
+        [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
+            log "mixed loopback and real device not working" && return
+
+        local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
+        local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
+        add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
+        add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=`hostname`@tcp --reformat $fs2ostdev || exit 10
+
+        start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
+        start fs2ost $fs2ostdev $OST_MOUNT_OPTS
+        mkdir -p $MOUNT2
+        mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
+        echo "ok."
+
+        umount -d $MOUNT2
+        stop fs2ost -f
+        stop fs2mds -f
+        rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
+        cleanup_nocli || return 6
+}
+run_test 33 "Mount ost with a large index number"
+
 umount_client $MOUNT   
 cleanup_nocli
 
+test_33a() {
+        setup
+
+        do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
+        # Drop lock cancelation reply during umount
+       #define OBD_FAIL_LDLM_CANCEL             0x304
+        do_facet client sysctl -w lustre.fail_loc=0x80000304
+        #sysctl -w lnet.debug=-1
+        umount_client $MOUNT
+        cleanup
+}
+run_test 33a "Drop cancel during umount"
+
+test_34a() {
+        setup
+       do_facet client multiop $DIR/file O_c &
+
+       manual_umount_client
+       rc=$?
+       do_facet client killall -USR1 multiop
+       if [ $rc -eq 0 ]; then
+               error "umount not fail!"
+       fi
+       sleep 1
+        cleanup
+}
+run_test 34a "umount with opened file should be fail"
+
+
+test_34b() {
+       setup
+       touch $DIR/$tfile || return 1
+       stop_mds --force || return 2
+
+       manual_umount_client --force
+       rc=$?
+       if [ $rc -ne 0 ]; then
+               error "mtab after failed umount - rc $rc"
+       fi
+
+       cleanup
+       return 0        
+}
+run_test 34b "force umount with failed mds should be normal"
+
+test_34c() {
+       setup
+       touch $DIR/$tfile || return 1
+       stop_ost --force || return 2
+
+       manual_umount_client --force
+       rc=$?
+       if [ $rc -ne 0 ]; then
+               error "mtab after failed umount - rc $rc"
+       fi
+
+       cleanup
+       return 0        
+}
+run_test 34c "force umount with failed mds should be normal"
+
+test_35() { # bug 12459
+       setup
+
+       debugsave
+       sysctl -w lnet.debug="ha"
+
+       log "Set up a fake failnode for the MDS"
+       FAKENID="127.0.0.2"
+       $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || return 4
+
+       log "Wait for RECONNECT_INTERVAL seconds (10s)"
+       sleep 10
+
+       MSG="conf-sanity.sh test_33 `date +%F%kh%Mm%Ss`"
+       $LCTL clear
+       log "$MSG"
+       log "Stopping the MDT:"
+       stop_mds || return 5
+
+       df $MOUNT > /dev/null 2>&1 &
+       DFPID=$!
+       log "Restarting the MDT:"
+       start_mds || return 6
+       log "Wait for df ($DFPID) ... "
+       wait $DFPID
+       log "done"
+       debugrestore
+
+       # retrieve from the log the first server that the client tried to
+       # contact after the connection loss
+       $LCTL dk $TMP/lustre-log-$TESTNAME.log
+       NEXTCONN=`awk "/${MSG}/ {start = 1;}
+                      /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
+                               if (start) {
+                                       if (\\\$NF ~ /$FAKENID/)
+                                               print \\\$NF;
+                                       else
+                                               print 0;
+                                       exit;
+                               }
+                      }" $TMP/lustre-log-$TESTNAME.log`
+       [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
+       cleanup
+}
+run_test 35 "Reconnect to the last active server first"
+
 equals_msg "Done"
 echo "$0: completed"