Whamcloud - gitweb
b=16818
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 6d7a725..0b0968e 100644 (file)
@@ -757,6 +757,34 @@ cleanup_check() {
     return 0
 }
 
+wait_update () {
+    local node=$1
+    local TEST=$2
+    local FINAL=$3
+    local MAX=${4:-90}
+
+        local RESULT
+        local WAIT=0
+        local sleep=5
+        while [ $WAIT -lt $MAX ]; do
+            sleep $sleep
+            RESULT=$(do_node $node "$TEST")
+            if [ $RESULT -eq $FINAL ]; then
+                echo "Updated after $WAIT sec: wanted $FINAL got $RESULT"
+                return 0
+            fi
+            WAIT=$((WAIT + sleep))
+            echo "Waiting $((MAX - WAIT)) secs for update"
+        done
+        echo "Update not seen after $MAX sec: wanted $FINAL got $RESULT"
+        return 3
+}
+
+wait_update_facet () {
+    local facet=$1
+    wait_update  $(facet_host $facet) $@
+}
+
 wait_delete_completed () {
     local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
                      awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
@@ -776,14 +804,14 @@ wait_delete_completed () {
 }
 
 wait_for_host() {
-    HOST=$1
+    local HOST=$1
     check_network "$HOST" 900
     while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
 }
 
 wait_for() {
-    facet=$1
-    HOST=`facet_active_host $facet`
+    local facet=$1
+    local HOST=`facet_active_host $facet`
     wait_for_host $HOST
 }
 
@@ -792,8 +820,8 @@ wait_mds_recovery_done () {
 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
 # as we are in process of changing obd_timeout in different ways
 # let's set MAX longer than that
-    MAX=$(( timeout * 4 ))
-    WAIT=0
+    local MAX=$(( timeout * 4 ))
+    local WAIT=0
     while [ $WAIT -lt $MAX ]; do
         STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
         echo $STATUS | grep COMPLETE && return 0
@@ -880,8 +908,8 @@ client_reconnect() {
 }
 
 facet_failover() {
-    facet=$1
-    sleep_time=$2
+    local facet=$1
+    local sleep_time=$2
     echo "Failing $facet on node `facet_active_host $facet`"
     shutdown_facet $facet
     [ -n "$sleep_time" ] && sleep $sleep_time
@@ -1296,16 +1324,6 @@ remount_client()
        zconf_mount `hostname` $1 || error "mount failed"
 }
 
-set_obd_timeout() {
-    local facet=$1
-    local timeout=$2
-
-    do_facet $facet lsmod | grep -q obdclass || \
-        do_facet $facet "modprobe obdclass"
-
-    do_facet $facet "lctl set_param timeout=$timeout"
-}
-
 writeconf_facet () {
     local facet=$1
     local dev=$2
@@ -1334,7 +1352,6 @@ setupall() {
             writeconf_all
         for num in `seq $MDSCOUNT`; do
             DEVNAME=$(mdsdevname $num)
-            set_obd_timeout mds$num $TIMEOUT
             start mds$num $DEVNAME $MDS_MOUNT_OPTS
 
             # We started mds, now we should set failover variables properly.
@@ -1350,7 +1367,6 @@ setupall() {
         done
         for num in `seq $OSTCOUNT`; do
             DEVNAME=$(ostdevname $num)
-            set_obd_timeout ost$num $TIMEOUT
             start ost$num $DEVNAME $OST_MOUNT_OPTS
 
             # We started ost$num, now we should set ost${num}failover variable properly.
@@ -1375,7 +1391,7 @@ setupall() {
         [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
     fi
 
-    init_versions_vars
+    init_param_vars
 
     # by remounting mdt before ost, initial connect from mdt to ost might
     # timeout because ost is not ready yet. wait some time to its fully
@@ -1429,10 +1445,13 @@ init_facets_vars () {
     done
 }
 
-init_versions_vars () {
+init_param_vars () {
     export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
     export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
     export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
+
+    TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
+    log "Using TIMEOUT=$TIMEOUT"
 }
 
 check_config () {
@@ -1453,6 +1472,15 @@ check_config () {
     fi
 }
 
+check_timeout () {
+    local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
+    local cltimeout=$(lctl get_param -n timeout)
+    if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
+        error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
+        return 1
+    fi
+}
+
 check_and_setup_lustre() {
     local MOUNTED=$(mounted_lustre_filesystems)
     if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
@@ -1464,7 +1492,7 @@ check_and_setup_lustre() {
     else
         check_config $MOUNT
         init_facets_vars
-        init_versions_vars
+        init_param_vars
     fi
     if [ "$ONLY" == "setup" ]; then
         exit 0