Whamcloud - gitweb
LU-2864 test: waiting import state in fail().
authoryangsheng <yang.sheng@intel.com>
Tue, 26 Feb 2013 08:40:24 +0000 (16:40 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 18 Mar 2013 05:02:11 +0000 (01:02 -0400)
Anyway, There still has a rare chance that the request meet
a invalid import after fail() return. So we should waiting
import restore to a certain state and doing next operation.
Add wait_import_state_mount() to check import state while
client has a mount point.

Signed-off-by: yang sheng <yang.sheng@intel.com>
Change-Id: I0b4a79c877bd6f240020d629fd672ba87ee6c99b
Reviewed-on: http://review.whamcloud.com/5743
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/test-framework.sh

index b1f6693..6691ddb 100644 (file)
@@ -1863,8 +1863,12 @@ ost_evict_client() {
 }
 
 fail() {
-    facet_failover $* || error "failover: $?"
-    clients_up || error "post-failover df: $?"
+       local facets=$1
+       local clients=${CLIENTS:-$HOSTNAME}
+
+       facet_failover $* || error "failover: $?"
+       wait_clients_import_state "$clients" "$facets" FULL
+       clients_up || error "post-failover df: $?"
 }
 
 fail_nodf() {
@@ -4217,7 +4221,7 @@ _wait_import_state () {
     local CONN_STATE
     local i=0
 
-    CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
+       CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
     while [ "${CONN_STATE}" != "${expected}" ]; do
         if [ "${expected}" == "DISCONN" ]; then
             # for disconn we can check after proc entry is removed
@@ -4230,7 +4234,8 @@ _wait_import_state () {
             error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
             return 1
         sleep 1
-        CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
+       # Add uniq for multi-mount case
+       CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
         i=$(($i + 1))
     done
 
@@ -4249,6 +4254,14 @@ wait_import_state() {
     done
 }
 
+wait_import_state_mount() {
+       if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
+               return 0
+       fi
+
+       wait_import_state $*
+}
+
 # One client request could be timed out because server was not ready
 # when request was sent by client.
 # The request timeout calculation details :
@@ -4348,7 +4361,7 @@ wait_clients_import_state () {
     local params=$(expand_list $params $proc_path)
     done
 
-    if ! do_rpc_nodes $list wait_import_state $expected $params; then
+    if ! do_rpc_nodes $list wait_import_state_mount $expected $params; then
         error "import is not in ${expected} state"
         return 1
     fi