Whamcloud - gitweb
LU-6609 test: wait for import state FULL
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 3f02efa..509041d 100755 (executable)
@@ -250,6 +250,7 @@ init_test_env() {
        export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
        [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
        export MCREATE=${MCREATE:-mcreate}
+       export MULTIOP=${MULTIOP:-multiop}
        # Ubuntu, at least, has a truncate command in /usr/bin
        # so fully path our truncate command.
        export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
@@ -4128,12 +4129,16 @@ mountcli() {
                [ "$arg1" = "server_only" ] && return
        fi
        mount_client $MOUNT
-       [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
+       if [ -n "$CLIENTS" ]; then
+               zconf_mount_clients $CLIENTS $MOUNT
+       fi
        clients_up
 
        if [ "$MOUNT_2" ]; then
                mount_client $MOUNT2
-               [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
+               if [ -n "$CLIENTS" ]; then
+                       zconf_mount_clients $CLIENTS $MOUNT2
+               fi
        fi
 }
 
@@ -6357,7 +6362,7 @@ convert_facet2label() {
 }
 
 get_clientosc_proc_path() {
-       echo "${1}-osc-*"
+       echo "${1}-osc-ffff*"
 }
 
 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
@@ -8419,3 +8424,65 @@ get_layout_param()
        local param=$($LFS getstripe -d $1 | parse_layout_param)
        echo "$param"
 }
+
+lfsck_verify_pfid()
+{
+       local f
+       local rc=0
+
+       # Cancel locks before setting lfsck_verify_pfid so that errors are more
+        # controllable
+       cancel_lru_locks mdc
+       cancel_lru_locks osc
+        
+       # make sure PFID is set correctly for files
+       do_nodes $(comma_list $(osts_nodes)) \
+              "$LCTL set_param -n obdfilter.${FSNAME}-OST*.lfsck_verify_pfid=1"
+
+       for f in "$@"; do
+               cat $f &> /dev/nullA ||
+                       { rc=$?; echo "verify $f failed"; break; }
+       done
+
+       do_nodes $(comma_list $(osts_nodes)) \
+              "$LCTL set_param -n obdfilter.${FSNAME}-OST*.lfsck_verify_pfid=0"
+       return $rc
+}
+
+# check that clients "oscs" was evicted after "before"
+check_clients_evicted() {
+       local before=$1
+       shift
+       local oscs=${@}
+       local osc
+       local rc=0
+
+       for osc in $oscs; do
+               ((rc++))
+               echo "Check state for $osc"
+               local evicted=$(do_facet client $LCTL get_param osc.$osc.state |
+                       tail -n 3 | awk -F"[ [,]" \
+                       '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
+               if (($? == 0)) && (($evicted > $before)); then
+                       echo "$osc is evicted at $evicted"
+                       ((rc--))
+               fi
+       done
+
+       [ $rc -eq 0 ] || error "client not evicted from OST"
+}
+
+# check that clients OSCS current_state is FULL
+check_clients_full() {
+       local timeout=$1
+       shift
+       local oscs=${@}
+
+       for osc in $oscs; do
+               wait_update_facet client \
+                       "lctl get_param -n osc.$osc.state |
+                       grep 'current_state: FULL'" \
+                       "current_state: FULL" $timeout
+               [ $? -eq 0 ] || error "$osc state is not FULL"
+       done
+}