Whamcloud - gitweb
LU-3665 tests: Cleanup echo client after obdfilter-survey
[fs/lustre-release.git] / lustre-iokit / obdfilter-survey / obdfilter-survey
index 36578cc..382db0c 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/bash
-set -e
 ######################################################################
 # customize per survey
 
@@ -14,7 +13,7 @@ set -e
 # one can specify only case=disk or case=network or case=netdisk through
 # command line.
 
-# Perquisite: For "disk" case and "netdisk" case you need to have lustre setup
+# Prerequisite: For "disk" case and "netdisk" case you need to have lustre setup
 #             with one or more ost's. For "network" case  you need to have all
 #             modules (those llmount.sh loades) loaded in kernel. And the
 #             'lctl dl' output must be blank.
@@ -236,16 +235,27 @@ print_summary () {
        echo $minusn "$*"
 }
 
+# Return a numeric version code based on a version string.  The version
+# code is useful for comparison two version strings to see which is newer.
 version_code() {
        # split arguments like "2.3.61" into "2", "3", "61"
        eval set -- $(tr "[:punct:]" " " <<< $*)
        echo -n "$((($1 << 16) | ($2 << 8) | $3))"
 }
 
+# inspired from the lustre_build_version routine in test-framework.sh
 get_lustre_version() {
        local host=${1:-${unique_hosts[0]}}
-       remote_shell $host $lctl get_param -n version |
-               awk '/^lustre:/ {print $2}'
+       local ver
+
+       ver=$(remote_shell $host "$lctl get_param -n version 2>/dev/null ||
+                               $lctl lustre_build_version 2>/dev/null ||
+                               $lctl --version 2>/dev/null | cut -d' ' -f2")
+       local lver=$(egrep -i "lustre: |version: " <<<$ver | head -n 1)
+       [ -n "$lver" ] && ver="$lver"
+
+       sed -e 's/.*: //' -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$ver |
+               cut -d. -f1-4
 }
 
 # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size
@@ -423,7 +433,7 @@ if [ $case == "network" ]; then
                exit 1
        fi
        # Now start client setup
-       osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
+       osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP || true)
        if [ -n "$osc_names_str" ]; then
                echo "The existing setup must be cleaned";
                exit 0;
@@ -460,7 +470,7 @@ for ((i=0; i < $ndevs; i++)); do
        host=${host_names[$i]}
        devno=($(get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"))
        if ((${#devno[@]} != 3)); then
-               exit 1
+               cleanup 2
        fi
        devnos[$i]=${devno[0]}
        client_names[$i]=${devno[1]}
@@ -518,7 +528,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
                                rm $tmpf
                                if [ $first_obj = "ERROR" ]; then
                                        print_summary "created object #s on $client_name not contiguous"
-                                       exit 1
+                                       cleanup 3
                                fi
                                first_objs[$idx]=$first_obj
                        done # $ndevs
@@ -528,7 +538,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
                                declare -a pidarray
                                for host in ${unique_hosts[@]}; do
                                        remote_shell $host \
-                                           "lctl set_param -n osd*.*OST*.force_sync 1"
+                                           "lctl set_param -n osd*.*.force_sync 1 &>/dev/null || true"
                                        echo "starting run for test: $test rsz: $rsz " \
                                        "threads: $thr objects: $nobj" >> ${vmstatf}_${host}
                                done
@@ -605,7 +615,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
                                                str=$(printf "%17s " SHORT)
                                        fi
                                else
-                                       str=$(awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
+                                       str=$(awk "BEGIN {printf \"[%7.2f, %7.2f] \",\
                                        (${stats[1]} * $actual_rsz)/1024,\
                                        (${stats[2]} * $actual_rsz)/1024; exit}")
                                fi