Whamcloud - gitweb
LU-116 fix mmp test 9 and test 10
[fs/lustre-release.git] / lustre / tests / mmp.sh
index 2ac19df..77a5f23 100755 (executable)
@@ -159,13 +159,15 @@ mmp_init() {
     # Otherwise, the Lustre administrator has to manually enable
     # this feature when the file system is unmounted.
 
-    if [ -z "$mdsfailover_HOST" ]; then
+    local var=${MMP_MDS}failover_HOST
+    if [ -z "${!var}" ]; then
         log "Failover is not used on MDS, enabling MMP manually..."
         enable_mmp $MMP_MDS $MMP_MDSDEV || \
             error "failed to enable MMP on $MMP_MDSDEV on $MMP_MDS"
     fi
 
-    if [ -z "$ostfailover_HOST" ]; then
+    var=${MMP_OSS}failover_HOST
+    if [ -z "${!var}" ]; then
         log "Failover is not used on OSS, enabling MMP manually..."
         enable_mmp $MMP_OSS $MMP_OSTDEV || \
             error "failed to enable MMP on $MMP_OSTDEV on $MMP_OSS"
@@ -183,7 +185,8 @@ mmp_init() {
 # which did not use failover.
 mmp_fini() {
 
-    if [ -z "$mdsfailover_HOST" ]; then
+    local var=${MMP_MDS}failover_HOST
+    if [ -z "${!var}" ]; then
         log "Failover is not used on MDS, disabling MMP manually..."
         disable_mmp $MMP_MDS $MMP_MDSDEV || \
             error "failed to disable MMP on $MMP_MDSDEV on $MMP_MDS"
@@ -191,7 +194,8 @@ mmp_fini() {
             error "MMP was not disabled on $MMP_MDSDEV on $MMP_MDS"
     fi
 
-    if [ -z "$ostfailover_HOST" ]; then
+    var=${MMP_OSS}failover_HOST
+    if [ -z "${!var}" ]; then
         log "Failover is not used on OSS, disabling MMP manually..."
         disable_mmp $MMP_OSS $MMP_OSTDEV || \
             error "failed to disable MMP on $MMP_OSTDEV on $MMP_OSS"
@@ -348,7 +352,7 @@ mount_after_reboot() {
     if [ "$FAILURE_MODE" = "HARD" ]; then
         shutdown_facet $facet
         reboot_facet $facet
-        wait_for $facet
+        wait_for_facet $facet
     else
         replay_barrier_nodf $facet
     fi
@@ -552,7 +556,7 @@ test_9() {
     mdt_mmp_check_interval=$(get_mmp_check_interval $MMP_MDS $MMP_MDSDEV)
     run_e2fsck $MMP_MDS_FAILOVER $MMP_MDSDEV "-fy" &
     e2fsck_pid=$!
-    sleep $((2 * $mdt_mmp_check_interval + 1))
+    sleep $((2 * $mdt_mmp_check_interval))
     kill -s ABRT $e2fsck_pid
 
     log "Mounting $MMP_MDSDEV on $MMP_MDS..."
@@ -568,7 +572,7 @@ test_9() {
     ost_mmp_check_interval=$(get_mmp_check_interval $MMP_OSS $MMP_OSTDEV)
     run_e2fsck $MMP_OSS_FAILOVER $MMP_OSTDEV "-fy" &
     e2fsck_pid=$!
-    sleep $((2 * $ost_mmp_check_interval + 1))
+    sleep $((2 * $ost_mmp_check_interval))
     kill -s ABRT $e2fsck_pid
 
     log "Mounting $MMP_OSTDEV on $MMP_OSS..."
@@ -592,10 +596,14 @@ test_10() {
 
     run_e2fsck $MMP_MDS_FAILOVER $MMP_MDSDEV "-fn"
     rc=${PIPESTATUS[0]}
-    if [ $rc -ne 8 ]; then
-        error_noexit "e2fsck $MMP_MDSDEV on $MMP_MDS_FAILOVER should return 8"
+
+    # e2fsck is called with -n option (Open the filesystem read-only), so
+    # 0 (No errors) and 4 (File system errors left uncorrected) are the only
+    # acceptable exit codes in this case
+    if [ $rc -ne 0 ] && [ $rc -ne 4 ]; then
+        error_noexit "e2fsck $MMP_MDSDEV on $MMP_MDS_FAILOVER returned $rc"
         stop $MMP_MDS || return ${PIPESTATUS[0]}
-        [ $rc -ne 0 ] && return $rc || return 1
+        return $rc
     fi
 
     log "Mounting $MMP_OSTDEV on $MMP_OSS..."
@@ -608,10 +616,8 @@ test_10() {
 
     run_e2fsck $MMP_OSS_FAILOVER $MMP_OSTDEV "-fn"
     rc=${PIPESTATUS[0]}
-    if [ $rc -ne 8 ]; then
-        error_noexit "e2fsck $MMP_OSTDEV on $MMP_OSS_FAILOVER should return 8"
-        stop_services primary || return ${PIPESTATUS[0]}
-        [ $rc -ne 0 ] && return $rc || return 1
+    if [ $rc -ne 0 ] && [ $rc -ne 4 ]; then
+        error_noexit "e2fsck $MMP_OSTDEV on $MMP_OSS_FAILOVER returned $rc"
     fi
 
     stop_services primary || return ${PIPESTATUS[0]}
@@ -622,8 +628,6 @@ run_test 10 "e2fsck with mounted filesystem"
 mmp_fini
 FAIL_ON_ERROR=$SAVED_FAIL_ON_ERROR
 
-equals_msg $(basename $0): test complete
+complete $(basename $0) $SECONDS
 $MMP_RESTORE_MOUNT && setupall
-[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && \
-    grep -q FAIL $TESTSUITELOG && exit 1 || true
-echo "$0: completed"
+exit_status