Whamcloud - gitweb
LU-6142 tests: Fix style issues for statmany.c
[fs/lustre-release.git] / lustre / tests / recovery-random-scale.sh
index 9de55c0..c3b2d4e 100644 (file)
@@ -1,6 +1,5 @@
 #!/bin/bash
-# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
-
+#
 # client failure does not affect other clients
 
 # Start load on clients (each client works on it's own directory).
@@ -14,15 +13,16 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+init_logging
+
 # bug number for skipped test:
 ALWAYS_EXCEPT="$RECOVERY_RANDOM_SCALE_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
-. $LUSTRE/tests/test-framework.sh
-init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-init_logging
+build_test_filter
 
 remote_mds_nodsh && skip_env "remote MDS with nodsh" && exit 0
 remote_ost_nodsh && skip_env "remote OST with nodsh" && exit 0
@@ -52,24 +52,25 @@ SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 10))} # 10 minutes
 
 MINSLEEP=${MINSLEEP:-120}
 REQFAIL_PERCENT=${REQFAIL_PERCENT:-3}    # bug17839 comment 62
-REQFAIL=${REQFAIL:-$((DURATION / SERVER_FAILOVER_PERIOD *
-                      REQFAIL_PERCENT / 100))}
+# round up the result of integer division: C=(A + (B - 1)) / B
+REQFAIL=${REQFAIL:-$(((DURATION * REQFAIL_PERCENT + (SERVER_FAILOVER_PERIOD *
+       100 - 1 )) / SERVER_FAILOVER_PERIOD / 100))}
 
 END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
 LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
 VMSTAT_PID_FILE=${VMSTAT_PID_FILE:-$TMP/vmstat.pid}
 
 numfailovers () {
-    local facet
-    local var
-
-    for facet in $MDTS ${FAILED_CLIENTS//,/ }; do
-        var=${facet}_nums
-        val=${!var}
-        if [ "$val" ] ; then
-            echo "$facet failed over $val times"
-        fi
-    done
+       local facet
+       local var
+
+       for facet in ${MDTS//,/ } ${FAILED_CLIENTS//,/ }; do
+               var=$(node_var_name $facet)_nums
+               val=${!var}
+               if [ "$val" ] ; then
+                       echo "$facet failed over $val times"
+               fi
+       done
 }
 
 summary_and_cleanup () {
@@ -100,20 +101,16 @@ Status: $result: rc=$rc"
     # stop the client loads
     stop_client_loads $NODES_TO_USE $LOAD_PID_FILE
 
-    if [ $rc -ne 0 ]; then
-        # we are interested in only on failed clients and servers
-        local failedclients=$(cat $END_RUN_FILE | grep -v $0)
-        # FIXME: need ostfailover-s nodes also for FLAVOR=OST
-        gather_logs $(comma_list $(osts_nodes) $(mdts_nodes) \
-                      $mdsfailover_HOST $failedclients)
-    fi
+       if [ $rc -ne 0 ]; then
+               # we are interested in only on failed clients and servers
+               local failedclients=$(cat $END_RUN_FILE | grep -v $0)
+               gather_logs $(comma_list $(all_server_nodes) $failedclients)
+       fi
 
     exit $rc
 }
 
 ################################## Main Flow ###################################
-build_test_filter
-
 check_and_setup_lustre
 rm -rf $DIR/[Rdfs][0-9]*
 
@@ -171,8 +168,8 @@ test_fail_client_mds() {
         # lists are comma separated
         FAILED_CLIENTS=$(expand_list $FAILED_CLIENTS $fail_client)
 
-        serverfacet=$(get_random_entry $MDTS)
-        var=${serverfacet}_nums
+       serverfacet=$(get_random_entry $MDTS)
+       var=$(node_var_name $serverfacet)_nums
 
         # Check that our client loads are still running. If any have died,
         # that means they have died outside of recovery, which is unacceptable.
@@ -265,6 +262,6 @@ run_test fail_client_mds "fail client, then failover MDS"
 zconf_mount $HOSTNAME $MOUNT || error "mount $MOUNT on $HOSTNAME failed"
 client_up || error "start client on $HOSTNAME failed"
 
-complete $(basename $0) $SECONDS
+complete $SECONDS
 check_and_cleanup_lustre
 exit_status