Whamcloud - gitweb
b=17634
[fs/lustre-release.git] / lustre / tests / insanity.sh
index 71ce414..3c4bf29 100755 (executable)
@@ -8,27 +8,38 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 
 init_test_env $@
 
-. ${CONFIG:=$LUSTRE/tests/cfg/insanity-lmv.sh}
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+#              
+ALWAYS_EXCEPT="10  $INSANITY_EXCEPT"
+
+if [ "$FAILURE_MODE" = "HARD" ]; then
+    mixed_ost_devs && CONFIG_EXCEPTIONS="0 2 4 5 6 8" && \
+        echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. " && \
+        echo "Except the tests: $CONFIG_EXCEPTIONS" && \
+        ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
+fi
+
+#
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
 
-ALWAYS_EXCEPT="10"
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
 
 build_test_filter
 
-assert_env MDSCOUNT mds1_HOST ost1_HOST ost2_HOST client_HOST LIVE_CLIENT 
+SINGLECLIENT=${SINGLECLIENT:-$HOSTNAME}
+LIVE_CLIENT=${LIVE_CLIENT:-$SINGLECLIENT}
+FAIL_CLIENTS=${FAIL_CLIENTS:-$RCLIENTS}
 
-####
-# Initialize all the ostN_HOST 
-NUMOST=2
-if [ "$EXTRA_OSTS" ]; then
-    for host in $EXTRA_OSTS; do
-       NUMOST=$((NUMOST + 1))
-       OST=ost$NUMOST
-       eval ${OST}_HOST=$host
-    done
-fi
+assert_env mds_HOST MDS_MKFS_OPTS
+assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
+assert_env LIVE_CLIENT FSNAME
+
+remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
+remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
 
-# This can be a regexp, to allow more clients
-CLIENTS=${CLIENTS:-"`comma_list $LIVE_CLIENT $FAIL_CLIENTS $EXTRA_CLIENTS`"}
+# FAIL_CLIENTS list should not contain the LIVE_CLIENT
+FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
 
 DIR=${DIR:-$MOUNT}
 
@@ -62,20 +73,16 @@ shutdown_client() {
     fi
 }
 
-reboot_node() {
-    NODE=$1
-    if [ "$FAILURE_MODE" = HARD ]; then
-       $POWER_UP $NODE
-    fi
-}
-
 fail_clients() {
     num=$1
+
+    log "Request clients to fail: ${num}. Num of clients to fail: ${FAIL_NUM}, already failed: $DOWN_NUM"
     if [ -z "$num"  ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
        num=$((FAIL_NUM - DOWN_NUM)) 
     fi
     
     if [ -z "$num" ] || [ "$num" -le 0 ]; then
+        log "No clients failed!"
         return
     fi
 
@@ -91,7 +98,7 @@ fail_clients() {
     echo "down clients: $DOWN_CLIENTS"
 
     for client in $DOWN_CLIENTS; do
-       reboot_node $client
+       boot_node $client
     done
     DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
     client_rmdirs
@@ -107,61 +114,8 @@ reintegrate_clients() {
     DOWN_NUM=0
 }
 
-gen_config() {
-    rm -f $XMLCONFIG
-    if [ "$MDSCOUNT" -gt 1 ]; then
-        add_lmv lmv1
-        for mds in `mds_list`; do
-            MDSDEV=$TMP/${mds}-`hostname`
-            add_mds $mds --dev $MDSDEV --size $MDSSIZE --lmv lmv1
-        done
-       MDS=lmv1
-        add_lov_to_lmv lov1 lmv1 --stripe_sz $STRIPE_BYTES \
-           --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
-    else
-        add_mds mds1 --dev $MDSDEV --size $MDSSIZE
-        if [ ! -z "$mds1failover_HOST" ]; then
-            add_mdsfailover mds1 --dev $MDSDEV --size $MDSSIZE
-        fi
-       add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES \
-           --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
-       MDS=mds1_svc
-    fi
-
-    for i in `seq $NUMOST`; do
-       dev=`printf $OSTDEV $i`
-       add_ost ost$i --lov lov1 --dev $dev --size $OSTSIZE \
-           --journal-size $OSTJOURNALSIZE
-    done
-     
-    add_client client --mds $MDS --lov lov1 --path $MOUNT
-}
-
-setup() {
-    rm -rf logs/*
-    for i in `seq $NUMOST`; do
-       wait_for ost$i
-       start ost$i ${REFORMAT} $OSTLCONFARGS 
-    done
-    [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
-    for mds in `mds_list`; do
-       wait_for $mds
-       start $mds $MDSLCONFARGS ${REFORMAT}
-    done
-    while ! do_node $CLIENTS "ls -d $LUSTRE" > /dev/null; do sleep 5; done
-    grep " $MOUNT " /proc/mounts || zconf_mount $CLIENTS $MOUNT
-
-}
-
-cleanup() {
-    zconf_umount $CLIENTS $MOUNT
-
-    for mds in `mds_list`; do
-       stop $mds ${FORCE} $MDSLCONFARGS || :
-    done
-    for i in `seq $NUMOST`; do
-       stop ost$i ${REFORMAT} ${FORCE} $OSTLCONFARGS  || :
-    done
+start_ost() {
+    start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
 }
 
 trap exit INT
@@ -201,60 +155,21 @@ clients_recover_osts() {
 #    do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
 }
 
-node_to_ost() {
-    node=$1
-    retvar=$2
-    for i in `seq $NUMOST`; do
-       ostvar="ost${i}_HOST"
-       if [ "${!ostvar}" == $node ]; then
-           eval $retvar=ost${i}
-           return 0
-       fi
-    done
-    echo "No ost found for node; $node"
-    return 1
-    
-}
-
-
-
-if [ "$ONLY" == "cleanup" ]; then
-    cleanup
-    exit
-fi
-
-if [ -z "$NOSETUP" ]; then
-    gen_config
-    setup
-fi
-
-if [ ! -z "$EVAL" ]; then
-    eval "$EVAL"
-    exit $?
-fi
-
-if [ "$ONLY" == "setup" ]; then
-    exit 0
-fi
+check_and_setup_lustre
 
 # 9 Different Failure Modes Combinations
 echo "Starting Test 17 at `date`"
 
 test_0() {
-    echo "Failover MDS"
-    facet_failover mds1
+    facet_failover $SINGLEMDS
     echo "Waiting for df pid: $DFPID"
-    wait $DFPID || return 1
+    wait $DFPID || { echo "df returned $?" && return 1; }
 
-    echo "Failing OST1"
-    facet_failover ost1
-    echo "Waiting for df pid: $DFPID"
-    wait $DFPID || return 2
-
-    echo "Failing OST2"
-    facet_failover ost2
-    echo "Waiting for df pid: $DFPID"
-    wait $DFPID || return 3
+    for i in $(seq $OSTCOUNT) ; do
+        facet_failover ost$i || return 4
+        echo "Waiting for df pid: $DFPID"
+        wait $DFPID || { echo "df returned $?" && return 3; }
+    done
     return 0
 }
 run_test 0 "Fail all nodes, independently"
@@ -270,31 +185,30 @@ run_test 1 "MDS/MDS failure"
 ############### Second Failure Mode ###############
 test_2() {
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
     client_df
 
-    echo "Failing MDS"
-    shutdown_facet mds1
-    reboot_facet mds1
+    shutdown_facet $SINGLEMDS
+    reboot_facet $SINGLEMDS
 
     # prepare for MDS failover
-    change_active mds1
-    reboot_facet mds1
+    change_active $SINGLEMDS
+    reboot_facet $SINGLEMDS
 
     client_df &
     DFPID=$!
     sleep 5
 
-    echo "Failing OST"
     shutdown_facet ost1
 
     echo "Reintegrating OST"
     reboot_facet ost1
     wait_for ost1
-    start ost1
+    start_ost 1 || return 2
 
-    echo "Failover MDS"
-    wait_for mds1
-    start mds1
+    wait_for $SINGLEMDS
+    start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || return $?
 
     #Check FS
     wait $DFPID
@@ -311,9 +225,10 @@ run_test 2 "Second Failure Mode: MDS/OST `date`"
 test_3() {
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
     
     #MDS Portion
-    facet_failover mds1
+    facet_failover $SINGLEMDS
     wait $DFPID || echo df failed: $?
     #Check FS
 
@@ -333,6 +248,7 @@ test_3() {
     reintegrate_clients || return 1
 
     client_df || return 3
+    sleep 2 # give it a little time for fully recovered before next test
 }
 run_test 3  "Thirdb Failure Mode: MDS/CLIENT `date`"
 ###################################################
@@ -342,38 +258,38 @@ test_4() {
     echo "Fourth Failure Mode: OST/MDS `date`"
 
     #OST Portion
-    echo "Failing OST ost1"
     shutdown_facet ost1
  
     #Check FS
     echo "Test Lustre stability after OST failure"
-    client_df
+    client_df &
+    DFPIDA=$!
+    sleep 5
 
     #MDS Portion
-    echo "Failing MDS"
-    shutdown_facet mds1
-    reboot_facet mds1
+    shutdown_facet $SINGLEMDS
+    reboot_facet $SINGLEMDS
 
     # prepare for MDS failover
-    change_active mds1
-    reboot_facet mds1
+    change_active $SINGLEMDS
+    reboot_facet $SINGLEMDS
 
     client_df &
-    DFPID=$!
+    DFPIDB=$!
     sleep 5
 
     #Reintegration
     echo "Reintegrating OST"
     reboot_facet ost1
     wait_for ost1
-    start ost1
+    start_ost 1
     
-    echo "Failover MDS"
-    wait_for mds1
-    start mds1
+    wait_for $SINGLEMDS
+    start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS
     #Check FS
     
-    wait $DFPID
+    wait $DFPIDA
+    wait $DFPIDB
     clients_recover_osts ost1
     echo "Test Lustre stability after MDS failover"
     client_df || return 1
@@ -383,41 +299,49 @@ run_test 4 "Fourth Failure Mode: OST/MDS `date`"
 
 ############### Fifth Failure Mode ###############
 test_5() {
+    [ $OSTCOUNT -lt 2 ] && skip "$OSTCOUNT < 2, not enough OSTs" && return 0
+
     echo "Fifth Failure Mode: OST/OST `date`"
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
     client_df
     
     #OST Portion
-    echo "Failing OST"
     shutdown_facet ost1
     reboot_facet ost1
     
     #Check FS
     echo "Test Lustre stability after OST failure"
-    client_df
+    client_df &
+    DFPIDA=$!
+    sleep 5
     
     #OST Portion
-    echo "Failing OST"
     shutdown_facet ost2
     reboot_facet ost2
 
     #Check FS
     echo "Test Lustre stability after OST failure"
-    client_df
+    client_df &
+    DFPIDB=$!
+    sleep 5
 
     #Reintegration
     echo "Reintegrating OSTs"
     wait_for ost1
-    start ost1
+    start_ost 1
     wait_for ost2
-    start ost2
+    start_ost 2
     
     clients_recover_osts ost1
     clients_recover_osts ost2
     sleep $TIMEOUT
 
+    wait $DFPIDA
+    wait $DFPIDB
     client_df || return 2
 }
 run_test 5 "Fifth Failure Mode: OST/OST `date`"
@@ -429,17 +353,21 @@ test_6() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
-    client_df || return 1
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
+    client_df
     client_touch testfile || return 2
        
     #OST Portion
-    echo "Failing OST"
     shutdown_facet ost1
     reboot_facet ost1
 
     #Check FS
     echo "Test Lustre stability after OST failure"
-    client_df
+    client_df &
+    DFPIDA=$!
+    echo DFPIDA=$DFPIDA
+    sleep 5
 
     #CLIENT Portion
     echo "Failing CLIENTs"
@@ -447,17 +375,25 @@ test_6() {
     
     #Check FS
     echo "Test Lustre stability after CLIENTs failure"
-    client_df
+    client_df &
+    DFPIDB=$!
+    echo DFPIDB=$DFPIDB
+    sleep 5
     
     #Reintegration
     echo "Reintegrating OST/CLIENTs"
     wait_for ost1
-    start ost1
-    reintegrate_clients
+    start_ost 1
+    reintegrate_clients || return 1
     sleep 5 
 
+    wait_remote_prog df $((TIMEOUT * 3 + 10)) 
+    wait $DFPIDA
+    wait $DFPIDB
+
     echo "Verifying mount"
-    client_df || return 3
+    [ -z "$(mounted_lustre_filesystems)" ] && return 3
+    client_df
 }
 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
 ###################################################
@@ -469,6 +405,8 @@ test_7() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
     client_df
     client_touch testfile  || return 1
 
@@ -488,12 +426,13 @@ test_7() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && return 2
+
     client_df
     client_rm testfile
 
     #MDS Portion
-    echo "Failing MDS"
-    facet_failover mds1
+    facet_failover $SINGLEMDS
 
     #Check FS
     echo "Test Lustre stability after MDS failover"
@@ -503,8 +442,8 @@ test_7() {
 
     #Reintegration
     echo "Reintegrating CLIENTs"
-    reintegrate_clients
-    client_df || return 2
+    reintegrate_clients || return 2
+    client_df
     
     #Sleep
     echo "wait 1 minutes"
@@ -520,6 +459,8 @@ test_8() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
     client_df
     client_touch testfile
        
@@ -539,26 +480,31 @@ test_8() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
     client_df
     client_touch testfile
 
 
     #OST Portion
-    echo "Failing OST"
     shutdown_facet ost1
     reboot_facet ost1
 
     #Check FS
     echo "Test Lustre stability after OST failure"
-    client_df
-    $PDSH $LIVE_CLIENT "ls -l $MOUNT"
-    $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
+    client_df &
+    DFPID=$!
+    sleep 5
+    #non-failout hangs forever here
+    #$PDSH $LIVE_CLIENT "ls -l $MOUNT"
+    #$PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
     
     #Reintegration
     echo "Reintegrating CLIENTs/OST"
-    reintegrate_clients
+    reintegrate_clients || return 3
     wait_for ost1
-    start ost1
+    start_ost 1
+    wait $DFPID
     client_df || return 1
     client_touch testfile2 || return 2
 
@@ -576,6 +522,8 @@ test_9() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
+    [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
+
     client_df
     client_touch testfile || return 1
        
@@ -610,8 +558,8 @@ test_9() {
 
     #Reintegration
     echo "Reintegrating  CLIENTs/CLIENTs"
-    reintegrate_clients
-    client_df || return 7
+    reintegrate_clients || return 7
+    client_df
     
     #Sleep
     echo "Wait 1 minutes"
@@ -628,5 +576,6 @@ test_10() {
 }
 run_test 10 "Running Availability for 6 hours..."
 
-equals_msg "Done, cleaning up"
-cleanup
+equals_msg `basename $0`: test complete, cleaning up
+check_and_cleanup_lustre
+[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true