Whamcloud - gitweb
LU-4214 target: LWP failover should create new export
[fs/lustre-release.git] / lustre / tests / functions.sh
index 3543946..0bc4fa0 100644 (file)
@@ -254,6 +254,19 @@ short_hostname() {
   echo $(sed 's/\..*//' <<< $1)
 }
 
+###
+# short_nodename
+#
+# Find remote nodename, stripped of any domain, etc.
+# 'hostname -s' is easy, but not implemented on all systems
+short_nodename() {
+       local rname=$(do_node $1 "uname -n" || echo -1)
+       if [[ "$rname" = "-1" ]]; then
+               rname=$1
+       fi
+       echo $(short_hostname $rname)
+}
+
 print_opts () {
     local var
 
@@ -267,18 +280,13 @@ print_opts () {
 }
 
 run_compilebench() {
-
-# Takes:
-# 5 min * cbench_RUNS
-#        SLOW=no     10 mins
-#        SLOW=yes    50 mins
-# Space estimation:
-#        compile dir kernel-1 680MB
-#        required space       680MB * cbench_IDIRS = ~7 Gb
+       # Space estimation:
+       # compile dir kernel-0  ~1GB
+       # required space        ~1GB * cbench_IDIRS
 
     cbench_DIR=${cbench_DIR:-""}
-    cbench_IDIRS=${cbench_IDIRS:-4}
-    cbench_RUNS=${cbench_RUNS:-4}
+    cbench_IDIRS=${cbench_IDIRS:-2}
+    cbench_RUNS=${cbench_RUNS:-2}
 
     print_opts cbench_DIR cbench_IDIRS cbench_RUNS
 
@@ -288,14 +296,16 @@ run_compilebench() {
     [ -e $cbench_DIR/compilebench ] || \
         { skip_env "No compilebench build" && return; }
 
-    local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
-    if [ $space -le $((680 * 1024 * cbench_IDIRS)) ]; then
-        cbench_IDIRS=$(( space / 680 / 1024))
-        [ $cbench_IDIRS = 0 ] && \
-            skip_env "Need free space atleast 680 Mb, have $space" && return
+       local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
+       if [[ $space -le $((1024 * 1024 * cbench_IDIRS)) ]]; then
+               cbench_IDIRS=$((space / 1024 / 1024))
+               [[ $cbench_IDIRS -eq 0 ]] &&
+                       skip_env "Need free space at least 1GB, have $space" &&
+                       return
+
+               echo "free space=$space, reducing initial dirs to $cbench_IDIRS"
+       fi
 
-        log free space=$space, reducing initial dirs to $cbench_IDIRS
-    fi
     # FIXME:
     # t-f _base needs to be modifyed to set properly tdir
     # for new "test_foo" functions names
@@ -352,8 +362,8 @@ run_metabench() {
                        -n $((num_clients * mbench_THREADS)) \
                        -p $SRUN_PARTITION -- $cmd
        else
-               mpi_run -np $((num_clients * $mbench_THREADS)) \
-                       ${MACHINEFILE_OPTION} ${MACHINEFILE} $cmd
+               mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+                       -np $((num_clients * $mbench_THREADS)) $cmd
        fi
 
     local rc=$?
@@ -400,8 +410,8 @@ run_simul() {
                        -n $((num_clients * simul_THREADS)) -p $SRUN_PARTITION \
                        -- $cmd
        else
-               mpi_run -np $((num_clients * simul_THREADS)) \
-                       ${MACHINEFILE_OPTION} ${MACHINEFILE} $cmd
+               mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+                       -np $((num_clients * simul_THREADS)) $cmd
        fi
 
     local rc=$?
@@ -456,8 +466,8 @@ run_mdtest() {
                        -n $((num_clients * mdtest_THREADS)) \
                        -p $SRUN_PARTITION -- $cmd
        else
-               mpi_run -np $((num_clients * mdtest_THREADS)) \
-                       ${MACHINEFILE_OPTION} ${MACHINEFILE} $cmd
+               mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+                       -np $((num_clients * mdtest_THREADS)) $cmd
        fi
 
     local rc=$?
@@ -590,8 +600,8 @@ run_ior() {
                        -n $((num_clients * ior_THREADS)) -p $SRUN_PARTITION \
                        -- $cmd
        else
-               mpi_run -np $((num_clients * $ior_THREADS)) \
-                       ${MACHINEFILE_OPTION} ${MACHINEFILE} $cmd
+               mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+                       -np $((num_clients * $ior_THREADS)) $cmd
        fi
 
     local rc=$?
@@ -644,8 +654,8 @@ run_mib() {
                        -n $((num_clients * mib_THREADS)) -p $SRUN_PARTITION \
                        -- $cmd
        else
-               mpi_run -np $((num_clients * mib_THREADS)) \
-                       ${MACHINEFILE_OPTION} ${MACHINEFILE} $cmd
+               mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+                       -np $((num_clients * mib_THREADS)) $cmd
        fi
 
     local rc=$?
@@ -686,8 +696,8 @@ run_cascading_rw() {
     local cmd="$CASC_RW -g -d $testdir -n $casc_REP"
 
        echo "+ $cmd"
-       mpi_run -np $((num_clients * $casc_THREADS)) ${MACHINEFILE_OPTION} \
-               ${MACHINEFILE} $cmd
+       mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+               -np $((num_clients * $casc_THREADS)) $cmd
 
     local rc=$?
     if [ $rc != 0 ] ; then
@@ -728,8 +738,8 @@ run_write_append_truncate() {
     local cmd="write_append_truncate -n $write_REP $file"
 
        echo "+ $cmd"
-       mpi_run -np $((num_clients * $write_THREADS)) ${MACHINEFILE_OPTION} \
-               ${MACHINEFILE} $cmd
+       mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+               -np $((num_clients * $write_THREADS)) $cmd
 
     local rc=$?
     if [ $rc != 0 ] ; then
@@ -768,8 +778,8 @@ run_write_disjoint() {
     local cmd="$WRITE_DISJOINT -f $testdir/file -n $wdisjoint_REP"
 
        echo "+ $cmd"
-       mpi_run -np $((num_clients * $wdisjoint_THREADS)) \
-               ${MACHINEFILE_OPTION} ${MACHINEFILE} $cmd
+       mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+               -np $((num_clients * $wdisjoint_THREADS)) $cmd
 
     local rc=$?
     if [ $rc != 0 ] ; then
@@ -810,8 +820,8 @@ run_parallel_grouplock() {
                local cmd="$PARALLEL_GROUPLOCK -g -v -d $testdir $subtest"
                echo "+ $cmd"
 
-               mpi_run -np $parallel_grouplock_MINTASKS ${MACHINEFILE_OPTION} \
-                       ${MACHINEFILE} $cmd
+               mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+                       -np $parallel_grouplock_MINTASKS $cmd
                local rc=$?
                if [ $rc != 0 ] ; then
                        error_noexit "parallel_grouplock subtests $subtest " \
@@ -887,8 +897,8 @@ run_statahead () {
     local cmd="$cmd1 $cmd2"
     echo "+ $cmd"
 
-       mpi_run -np $((num_clients * 32)) ${MACHINEFILE_OPTION} ${MACHINEFILE} \
-               $cmd
+       mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} \
+               -np $((num_clients * 32)) $cmd
 
     local rc=$?
     if [ $rc != 0 ] ; then