Whamcloud - gitweb
- landing of b_hd_cleanup_merge to HEAD.
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index b493c9c..c0f9c0f 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/sh
 
 set -e
-
 export REFORMAT=""
 export VERBOSE=false
 
@@ -27,10 +26,11 @@ usage() {
 init_test_env() {
     export LUSTRE=`absolute_path $LUSTRE`
     export TESTSUITE=`basename $0 .sh`
-    export XMLCONFIG="${TESTSUITE}.xml"
+    export XMLCONFIG=${XMLCONFIG:-${TESTSUITE}.xml}
     export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
 
     [ -d /r ] && export ROOT=/r
+    export TMP=${TMP:-$ROOT/tmp}
 
     export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
     export LLMOUNT=${LLMOUNT:-"llmount"}
@@ -38,6 +38,7 @@ init_test_env() {
     export LMC=${LMC:-"lmc"}
     export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
     export CHECKSTAT="${CHECKSTAT:-checkstat} "
+    export FSYTPE=${FSTYPE:-"ext3"}
 
     # Paths on remote nodes, if different 
     export RLUSTRE=${RLUSTRE:-$LUSTRE}
@@ -54,6 +55,9 @@ init_test_env() {
        esac
     done
     
+    shift $((OPTIND - 1))
+    ONLY=${ONLY:-$*}
+    
     # save the name of the config file for the upcall
     echo "XMLCONFIG=$LUSTRE/tests/$XMLCONFIG"  > $LUSTRE/tests/XMLCONFIG
 #    echo "CONFIG=`canonical_path $CONFIG`"  > $LUSTRE/tests/CONFIG
@@ -85,12 +89,11 @@ zconf_mount() {
     do_node $client mkdir $mnt 2> /dev/null || :
 
     if [ -x /sbin/mount.lustre ] ; then
-       do_node $client mount -t lustre -o nettype=$NETTYPE `facet_active_host mds`:/mds_svc/client_facet $mnt || return 1
+       do_node $client mount -t lustre -o nettype=$NETTYPE `facet_active_host mds1`:/mds1_svc/client_facet $mnt || return 1
     else
        # this is so cheating
        do_node $client $LCONF --nosetup --node client_facet $XMLCONFIG  > /dev/null || return 2
-       $LCONF --nosetup --node client_facet $XMLCONFIG
-       do_node $client $LLMOUNT `facet_active_host mds`:/mds_svc/client_facet $mnt -o nettype=$NETTYPE|| return 4
+       do_node $client $LLMOUNT `facet_active_host mds1`:/mds1_svc/client_facet $mnt -o nettype=$NETTYPE|| return 4
     fi
 
     [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
@@ -125,7 +128,6 @@ reboot_facet() {
 wait_for_host() {
    HOST=$1
    check_network  $HOST 900
-   while ! do_node $HOST "$CHECKSTAT -t dir $LUSTRE"; do sleep 5; done
    while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
 }
 
@@ -169,7 +171,7 @@ replay_barrier() {
 
 mds_evict_client() {
     UUID=`cat /proc/fs/lustre/mdc/*_MNT_*/uuid`
-    do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds_svc/evict_client"
+    do_facet mds "echo $UUID > /proc/fs/lustre/mds/mds1_svc/evict_client"
 }
 
 fail() {
@@ -185,6 +187,7 @@ fail_abort() {
     start $facet
     do_facet $facet lctl --device %${facet}_svc abort_recovery
     df $MOUNT || echo "first df failed: $?"
+    sleep 1
     df $MOUNT || error "post-failover df: $?"
 }
 
@@ -193,25 +196,33 @@ do_lmc() {
 }
 
 h2gm () {
-   if [ "$1" = "client" ]; then echo \'*\'; else
+   if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
        $PDSH $1 $GMNALNID -l | cut -d\  -f2
    fi
 }
 
 h2tcp() {
-   if [ "$1" = "client" ]; then echo \'*\'; else
+   if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
    echo $1 
    fi
 }
 declare -fx h2tcp
 
 h2elan() {
-   if [ "$1" = "client" ]; then echo \'*\'; else
+   if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
    echo $1 | sed 's/[^0-9]*//g'
    fi
 }
 declare -fx h2elan
 
+h2openib() {
+   if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
+   echo $1 | sed 's/[^0-9]*//g'
+   fi
+}
+declare -fx h2openib
+
+
 facet_host() {
    local facet=$1
    varname=${facet}_HOST
@@ -231,6 +242,11 @@ facet_nid() {
 facet_active() {
     local facet=$1
     local activevar=${facet}active
+
+    if [ -f ./${facet}active ] ; then
+        source ./${facet}active
+    fi
+
     active=${!activevar}
     if [ -z "$active" ] ; then 
        echo -n ${facet}
@@ -275,11 +291,24 @@ do_node() {
     fi
     $PDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests; cd $RPWD; sh -c \"$@\")"
 }
+
+mds_list() {
+    seq -f mds%g $MDSCOUNT
+}
+
 do_facet() {
     facet=$1
     shift
-    HOST=`facet_active_host $facet`
-    do_node $HOST $@
+
+    if [ "$facet" == "mds" ]; then
+       for mds in `mds_list`; do
+           HOST=`facet_active_host $mds`
+           do_node $HOST $@
+       done
+    else
+       HOST=`facet_active_host $facet`
+       do_node $HOST $@
+    fi
 }
 
 add_facet() {
@@ -297,14 +326,14 @@ add_mds() {
     shift
     rm -f ${facet}active
     add_facet $facet
-    do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc $*
+    do_lmc --add mds --node ${facet}_facet --mds ${facet}_svc --fstype $FSTYPE $*
 }
 
 add_mdsfailover() {
     facet=$1
     shift
     add_facet ${facet}failover  --lustre_upcall $UPCALL
-    do_lmc --add mds  --node ${facet}failover_facet --mds ${facet}_svc $*
+    do_lmc --add mds  --node ${facet}failover_facet --mds ${facet}_svc --fstype $FSTYPE $*
 }
 
 add_ost() {
@@ -312,14 +341,26 @@ add_ost() {
     shift
     rm -f ${facet}active
     add_facet $facet
-    do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc $*
+    do_lmc --add ost --node ${facet}_facet --ost ${facet}_svc --fstype $FSTYPE $*
+}
+
+del_ost() {
+    facet=$1
+    shift
+    do_lmc --delete ost --node ${facet}_facet --ost ${facet}_svc $*
+}
+
+deactivate_ost() {
+    facet=$1
+    shift
+    do_lmc --deactivate ost --node ${facet}_facet --ost ${facet}_svc $*
 }
 
 add_ostfailover() {
     facet=$1
     shift
     add_facet ${facet}failover
-    do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc $*
+    do_lmc --add ost --failover --node ${facet}failover_facet --ost ${facet}_svc --fstype $FSTYPE $*
 }
 
 add_lov() {
@@ -327,7 +368,19 @@ add_lov() {
     mds_facet=$2
     shift; shift
     do_lmc --add lov --mds ${mds_facet}_svc --lov $lov $*
-    
+}
+
+add_lov_to_lmv() {
+    lov=$1
+    lmv=$2
+    shift; shift
+    do_lmc --add lov --lmv $lmv --lov $lov $*
+}
+
+add_lmv() {
+    lmv=$1
+    shift;
+    do_lmc --add lmv --lmv $lmv $*
 }
 
 add_client() {
@@ -336,9 +389,11 @@ add_client() {
     shift; shift
     add_facet $facet --lustre_upcall $UPCALL
     do_lmc --add mtpt --node ${facet}_facet --mds ${mds}_svc $*
-
 }
 
+config_commit() {
+    do_lmc --commit
+}
 
 ####### 
 # General functions
@@ -404,6 +459,15 @@ drop_reply() {
     return $RC
 }
 
+drop_reint_reply() {
+# OBD_FAIL_MDS_REINT_NET_REP
+    RC=0
+    do_facet mds "echo 0x119 > /proc/sys/lustre/fail_loc"
+    do_facet client "$@" || RC=$?
+    do_facet mds "echo 0 > /proc/sys/lustre/fail_loc"
+    return $RC
+}
+
 pause_bulk() {
 #define OBD_FAIL_OST_BRW_PAUSE_BULK      0x214
     RC=0
@@ -450,6 +514,18 @@ cancel_lru_locks() {
     done
 }
 
+
+pgcache_empty() {
+    for a in /proc/fs/lustre/llite/*/dump_page_cache; do
+        if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
+                echo there is still data in page cache $a ?
+                cat $a;
+                return 1;
+        fi
+    done
+    return 0
+}
+
 ##################################
 # Test interface 
 error() {