Whamcloud - gitweb
LU-9364 test: wait rmultiop_start to start 29/26729/6
authorHongchao Zhang <hongchao.zhang@intel.com>
Thu, 13 Apr 2017 07:48:32 +0000 (15:48 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 9 Aug 2017 04:18:37 +0000 (04:18 +0000)
In rmultiop_start, the remote command could be delayed a while,
and wait some time for the command to run.

Test-Parameters: trivial testlist=replay-vbr

Change-Id: Ic8beec725edc89a527c74e2033e59e1da0d444c9
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Reviewed-on: https://review.whamcloud.com/26729
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Wei Liu <wei3.liu@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Saurabh Tandan <saurabh.tandan@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/replay-vbr.sh

index 7da4f8a..4e817a0 100755 (executable)
@@ -43,33 +43,46 @@ CLIENT2=${CLIENT2:-$CLIENT1}
 is_mounted $MOUNT2 || error "MOUNT2 is not mounted"
 
 rmultiop_start() {
 is_mounted $MOUNT2 || error "MOUNT2 is not mounted"
 
 rmultiop_start() {
-    local client=$1
-    local file=$2
-    local cmds=$3
-
-    # We need to run do_node in bg, because pdsh does not exit
-    # if child process of run script exists.
-    # I.e. pdsh does not exit when runmultiop_bg_pause exited,
-    # because of multiop_bg_pause -> $MULTIOP_PROG &
-    # By the same reason we need sleep a bit after do_nodes starts
-    # to let runmultiop_bg_pause start muliop and
-    # update /tmp/multiop_bg.pid ;
-    # The rm /tmp/multiop_bg.pid guarantees here that
-    # we have the updated by runmultiop_bg_pause
-    # /tmp/multiop_bg.pid file
-
-    local pid_file=$TMP/multiop_bg.pid.$$
-    do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file $cmds" &
-    local pid=$!
-    sleep 3
-    local multiop_pid
-    multiop_pid=$(do_node $client cat $pid_file)
-    [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
-    eval export $(node_var_name $client)_multiop_pid=$multiop_pid
-    eval export $(node_var_name $client)_do_node_pid=$pid
-    local var=$(node_var_name $client)_multiop_pid
-    echo client $client multiop_bg started multiop_pid=${!var}
-    return $?
+       local client=$1
+       local file=$2
+       local cmds=$3
+       local WAIT_MAX=${4:-60}
+       local wait_time=0
+
+       # We need to run do_node in bg, because pdsh does not exit
+       # if child process of run script exists.
+       # I.e. pdsh does not exit when runmultiop_bg_pause exited,
+       # because of multiop_bg_pause -> $MULTIOP_PROG &
+       # By the same reason we need sleep a bit after do_nodes starts
+       # to let runmultiop_bg_pause start muliop and
+       # update /tmp/multiop_bg.pid ;
+       # The rm /tmp/multiop_bg.pid guarantees here that
+       # we have the updated by runmultiop_bg_pause
+       # /tmp/multiop_bg.pid file
+
+       local pid_file=$TMP/multiop_bg.pid.$$
+       do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= \
+                       runmultiop_bg_pause $file $cmds" &
+       local pid=$!
+       local multiop_pid
+
+       while [[ $wait_time -lt $WAIT_MAX ]]; do
+               sleep 3
+               wait_time=$((wait_time + 3))
+               multiop_pid=$(do_node $client cat $pid_file)
+               if [ -n "$multiop_pid" ]; then
+                       break
+               fi
+       done
+
+       [ -n "$multiop_pid" ] ||
+               error "$client : Can not get multiop_pid from $pid_file "
+
+       eval export $(node_var_name $client)_multiop_pid=$multiop_pid
+       eval export $(node_var_name $client)_do_node_pid=$pid
+       local var=$(node_var_name $client)_multiop_pid
+       echo client $client multiop_bg started multiop_pid=${!var}
+       return $?
 }
 
 rmultiop_stop() {
 }
 
 rmultiop_stop() {