Whamcloud - gitweb
b=22505 Initialize cui_tot_nregs for liblustre
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index ad8eff6..10edcd3 100644 (file)
@@ -262,7 +262,7 @@ load_module() {
            (($# > 0)) && shift 2
 
             # Ensure we have accept=all for lnet
-            if [ $module = lnet ]; then
+            if [ $(basename $module) = lnet ]; then
                 # OK, this is a bit wordy...
                 local arg accept_all_present=false
                 for arg in "$@"; do
@@ -2607,13 +2607,8 @@ run_test() {
     return $?
 }
 
-EQUALS="======================================================================"
 equals_msg() {
-    msg="$@"
-
-    local suffixlen=$((${#EQUALS} - ${#msg}))
-    [ $suffixlen -lt 5 ] && suffixlen=5
-    log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
+    banner "$*"
 }
 
 log() {
@@ -2668,18 +2663,15 @@ reset_fail_loc () {
 # Log a message (on all nodes) padded with "=" before and after. 
 # Also appends a timestamp and prepends the testsuite name.
 # 
+
+EQUALS="===================================================================================================="
 banner() {
     msg="== ${TESTSUITE} $*"
-    # pad the message out to 70 with "="
     last=${msg: -1:1}
-    [[ $last != "=" && $last != " " ]] && msg+=" "
-    for i in $(seq $((68 - ${#msg})) ); do
-       msg+="="
-    done
+    [[ $last != "=" && $last != " " ]] && msg="$msg "
+    msg=$(printf '%s%.*s'  "$msg"  $((${#EQUALS} - ${#msg})) $EQUALS )
     # always include at least == after the message
-    msg+="=="
-
-    log "$msg $(date +"%H:%M:%S (%s)")"
+    log "$msg== $(date +"%H:%M:%S (%s)")"
 }
 
 #
@@ -2724,7 +2716,7 @@ run_one_logged() {
     rm -rf $LOGDIR/err
 
     echo
-    run_one $1 "$2" 2>&1 | tee $test_log
+    (run_one $1 "$2") 2>&1 | tee $test_log
     local RC=${PIPESTATUS[0]}
 
     [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
@@ -3311,12 +3303,13 @@ get_osc_import_name() {
 }
 
 wait_import_state () {
-    local expected=$1
-    local CONN_PROC=$2
+    local facet=$1
+    local expected=$2
+    local CONN_PROC=$3
     local CONN_STATE
     local i=0
 
-    CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
+    CONN_STATE=$(do_facet $facet $LCTL get_param -n $CONN_PROC | awk '/state/ {print $2}')
     while [ "${CONN_STATE}" != "${expected}" ]; do
         if [ "${expected}" == "DISCONN" ]; then
             # for disconn we can check after proc entry is removed
@@ -3329,7 +3322,7 @@ wait_import_state () {
         [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
             error "can't put import for $CONN_PROC into ${expected} state" && return 1
         sleep 1
-        CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
+        CONN_STATE=$(do_facet $facet $LCTL get_param -n $CONN_PROC | awk '/state/ {print $2}')
         i=$(($i + 1))
     done
 
@@ -3342,33 +3335,26 @@ wait_osc_import_state() {
     local ost_facet=$2
     local expected=$3
     local ost=$(get_osc_import_name $facet $ost_facet)
-    local CONN_PROC
-    local CONN_STATE
-    local i=0
-
-    CONN_PROC="osc.${ost}.ost_server_uuid"
-    CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
-    while [ "${CONN_STATE}" != "${expected}" ]; do
-        if [ "${expected}" == "DISCONN" ]; then 
-            # for disconn we can check after proc entry is removed
-            [ "x${CONN_STATE}" == "x" ] && return 0
-            #  with AT we can have connect request timeout ~ reconnect timeout
-            # and test can't see real disconnect
-            [ "${CONN_STATE}" == "CONNECTING" ] && return 0
-        fi
-        # disconnect rpc should be wait not more obd_timeout
-        [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
-            error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
-        sleep 1
-        CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
-        i=$(($i + 1))
-    done
+    local CONN_PROC="osc.${ost}.import"
 
-    log "${ost_facet} now in ${CONN_STATE} state"
+    wait_import_state $facet $expected $CONN_PROC || return 1
     return 0
 }
+
 get_clientmdc_proc_path() {
-    echo "${1}-mdc-*"
+    local mdc=$(convert_facet2label $1)
+
+    echo "${mdc}-mdc-*"
+}
+
+wait_mdc_import_state() {
+    local facet=$1
+    local expected=$2
+    local mdc=$(get_clientmdc_proc_path $facet)
+    local CONN_PROC="mdc.${mdc}.import"
+
+    wait_import_state client $expected $CONN_PROC || return 1
+    return 0
 }
 
 do_rpc_nodes () {
@@ -3380,24 +3366,29 @@ do_rpc_nodes () {
     do_nodesv $list "PATH=$RPATH sh rpc.sh $@ "
 }
 
-wait_clients_import_state () {
-    local list=$1
-    local facet=$2
-    local expected=$3
+wait_client_import_state () {
+    local facet=$1
+    local expected=$2
     shift
 
-    local label=$(convert_facet2label $facet)
-    local proc_path
     case $facet in
-        ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
-        mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
-        *) error "unknown facet!" ;;
+        ost* ) wait_osc_import_state client $facet $expected || return 1;;
+        mds* ) wait_mdc_import_state $facet $expected || return 1 ;;
+           * ) error "unknown facet!"
+               return 1 ;;
     esac
+    return 0
+}
 
-    if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
-        error "import is not in ${expected} state"
+wait_clients_import_state () {
+    local list=$1
+    shift
+
+    if ! do_rpc_nodes $list wait_client_import_state "$@"; then
+        error "import is not in expected state"
         return 1
     fi
+    return 0
 }
 
 oos_full() {