From c00b54642719e23cf904d78bea68337d5be24aad Mon Sep 17 00:00:00 2001
From: scjody <scjody>
Date: Thu, 14 Jun 2007 20:26:49 +0000
Subject: [PATCH] Branch b1_6

Modify test-framework tests to run on real hardware - based on a patch
by Nic Henke <nic@cray.com>

b=11217
i=mjmac
i=nathan
---
 lustre/tests/recovery-small.sh |  9 ++++-----
 lustre/tests/replay-dual.sh    |  2 +-
 lustre/tests/replay-single.sh  |  6 +++---
 lustre/tests/test-framework.sh | 16 +++++++++++++++-
 4 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh
index f81a27e056..7bd1efbfe5 100755
--- a/lustre/tests/recovery-small.sh
+++ b/lustre/tests/recovery-small.sh
@@ -1,4 +1,3 @@
-
 #!/bin/bash
 
 set -e
@@ -20,7 +19,7 @@ SETUP=${SETUP:-"setup"}
 CLEANUP=${CLEANUP:-"cleanup"}
 
 setup() {
-    formatall
+    [ "$REFORMAT" ] && formatall
     setupall
 }
 
@@ -202,7 +201,7 @@ test_16() {
     cancel_lru_locks osc
     # OST bulk will time out here, client resends
     do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 1
-    sysctl -w lustre.fail_loc=0
+    do_facet ost1 sysctl -w lustre.fail_loc=0
     # give recovery a chance to finish (shouldn't take long)
     sleep $TIMEOUT
     do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
@@ -213,13 +212,13 @@ run_test 16 "timeout bulk put, don't evict client (2732)"
 test_17() {
     # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
     # OST bulk will time out here, client retries
-    sysctl -w lustre.fail_loc=0x80000503
+    do_facet ost1 sysctl -w lustre.fail_loc=0x80000503
     # need to ensure we send an RPC
     do_facet client cp /etc/termcap $DIR/$tfile
     sync
 
     sleep $TIMEOUT
-    sysctl -w lustre.fail_loc=0
+    do_facet ost1 sysctl -w lustre.fail_loc=0
     do_facet client "df $DIR"
     # expect cmp to succeed, client resent bulk
     do_facet client "cmp /etc/termcap $DIR/$tfile" || return 3
diff --git a/lustre/tests/replay-dual.sh b/lustre/tests/replay-dual.sh
index 820a97b584..7d3ffc6341 100755
--- a/lustre/tests/replay-dual.sh
+++ b/lustre/tests/replay-dual.sh
@@ -30,7 +30,7 @@ fi
 
 setup() {
     cleanup
-    formatall
+    [ "$REFORMAT" ] && formatall
     setupall
     mount_client $MOUNT2
 }
diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh
index 9f7e560db4..42ae4e99c8 100755
--- a/lustre/tests/replay-single.sh
+++ b/lustre/tests/replay-single.sh
@@ -26,8 +26,8 @@ gen_config() {
     
     add_lov lov1 mds --stripe_sz $STRIPE_BYTES \
 	--stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
-    add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
-    add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
+    add_ost ost --lov lov1 --dev `ostdevname 1` --size $OSTSIZE
+    add_ost ost2 --lov lov1 --dev `ostdevname 2` --size $OSTSIZE
     add_client client mds --lov lov1 --path $MOUNT
 }
 
@@ -43,7 +43,7 @@ if [ "$ONLY" == "cleanup" ]; then
 fi
 
 setup() {
-    formatall
+    [ "$REFORMAT" ] && formatall
     setupall
 }
 
diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh
index 2deb6d34e3..2ff83c689c 100644
--- a/lustre/tests/test-framework.sh
+++ b/lustre/tests/test-framework.sh
@@ -6,7 +6,7 @@ set -e
 #set -x
 
 
-export REFORMAT=""
+export REFORMAT=${REFORMAT:-""}
 export VERBOSE=false
 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
@@ -456,6 +456,18 @@ h2gm () {
     fi
 }
 
+h2ptl() {
+   if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
+       ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
+       if [ -z "$ID" ]; then
+           echo "Could not get a ptl id for $1..."
+           exit 1
+       fi
+       echo $ID"@ptl"
+   fi
+}
+declare -fx h2ptl
+
 h2tcp() {
     if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
         echo $1"@tcp" 
@@ -633,6 +645,8 @@ setupall() {
     load_modules
     if [ -z "$CLIENTONLY" ]; then
         echo Setup mdt, osts
+        echo $REFORMAT | grep -q "reformat" \
+	    || do_facet mds "$TUNEFS --writeconf $MDSDEV"
         start mds $MDSDEV $MDS_MOUNT_OPTS
         for num in `seq $OSTCOUNT`; do
             DEVNAME=`ostdevname $num`
-- 
GitLab