Whamcloud - gitweb
LU-2037 tests: Wait for devices to initialize on test setup
authormichael.mckay <michael_mckay@xyratex.com>
Thu, 27 Sep 2012 14:28:03 +0000 (10:28 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 12 Oct 2012 23:06:33 +0000 (19:06 -0400)
Fix an issue where we do not wait for a device to
initialize before getting the label. This label then does
not correspond to an actual device.
A check is now done on the label names to see
if you are getting back the 'ffff' which signifies that the
device has not finished initializing yet. In this case
we will wait and retry in 1,3,5,10 seconds or until
the command succeeds.

Xyratex-bug-id: MRP-546
Reviewed-by: Iurii Golovach <Iurii_Golovach@xyratex.com>
Reviewed-by: Kyrylo Shatskyy <Kyrylo_Shatskyy@xyratex.com>
Signed-off-by: Michael McKay <michael_mckay@xyratex.com>
Change-Id: I01e045227a4b3b6e007dcc9685238a5425cdffe8
Reviewed-on: http://review.whamcloud.com/4111
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/test-framework.sh

index 02890af..b662da5 100644 (file)
@@ -3006,45 +3006,70 @@ mounted_lustre_filesystems() {
 }
 
 init_facet_vars () {
 }
 
 init_facet_vars () {
-    [ "$CLIENTONLY" ] && return 0
-    local facet=$1
-    shift
-    local device=$1
+       [ "$CLIENTONLY" ] && return 0
+       local facet=$1
+       shift
+       local device=$1
 
 
-    shift
+       shift
 
 
-    eval export ${facet}_dev=${device}
-    eval export ${facet}_opt=\"$@\"
+       eval export ${facet}_dev=${device}
+       eval export ${facet}_opt=\"$@\"
 
 
-    local dev=${facet}_dev
-       local label=$(devicelabel ${facet} ${!dev})
-    [ -z "$label" ] && echo no label for ${!dev} && exit 1
+       local dev=${facet}_dev
 
 
-    eval export ${facet}_svc=${label}
+       # We need to loop for the label
+       # in case its not initialized yet.
+       for wait_time in {0,1,3,5,10}; do
 
 
-    local varname=${facet}failover_HOST
-    if [ -z "${!varname}" ]; then
-       eval $varname=$(facet_host $facet) 
-    fi
+               if [ $wait_time -gt 0 ]; then
+                       echo "${!dev} not yet initialized,"\
+                               "waiting ${wait_time} seconds."
+                       sleep $wait_time
+               fi
 
 
-    # ${facet}failover_dev is set in cfg file
-    varname=${facet}failover_dev
-    if [ -n "${!varname}" ] ; then
-        eval export ${facet}failover_dev=${!varname}
-    else
-        eval export ${facet}failover_dev=$device
-    fi
+               local label=$(devicelabel ${facet} ${!dev})
 
 
-    # get mount point of already mounted device
-    # is facet_dev is already mounted then use the real
-    #  mount point of this facet; otherwise use $(facet_mntpt $facet)
-    # i.e. ${facet}_MOUNT if specified by user or default
-    local mntpt=$(do_facet ${facet} cat /proc/mounts | \
-            awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
-    if [ -z $mntpt ]; then
-        mntpt=$(facet_mntpt $facet)
-    fi
-    eval export ${facet}_MOUNT=$mntpt
+               # Check to make sure the label does
+               # not include ffff at the end of the label.
+               # This indicates it has not been initialized yet.
+
+               if [[ $label =~ [f|F]{4}$ ]]; then
+                       # label is not initialized, unset the result
+                       # and either try again or fail
+                       unset label
+               else
+                       break
+               fi
+       done
+
+       [ -z "$label" ] && echo no label for ${!dev} && exit 1
+
+       eval export ${facet}_svc=${label}
+
+       local varname=${facet}failover_HOST
+       if [ -z "${!varname}" ]; then
+               eval $varname=$(facet_host $facet)
+       fi
+
+       # ${facet}failover_dev is set in cfg file
+       varname=${facet}failover_dev
+       if [ -n "${!varname}" ] ; then
+               eval export ${facet}failover_dev=${!varname}
+       else
+               eval export ${facet}failover_dev=$device
+       fi
+
+       # get mount point of already mounted device
+       # is facet_dev is already mounted then use the real
+       #  mount point of this facet; otherwise use $(facet_mntpt $facet)
+       # i.e. ${facet}_MOUNT if specified by user or default
+       local mntpt=$(do_facet ${facet} cat /proc/mounts | \
+                       awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
+       if [ -z $mntpt ]; then
+               mntpt=$(facet_mntpt $facet)
+       fi
+       eval export ${facet}_MOUNT=$mntpt
 }
 
 init_facets_vars () {
 }
 
 init_facets_vars () {