Whamcloud - gitweb
b=20057 Autovetting and test-framework enhancements
[fs/lustre-release.git] / lustre / tests / sanity-sec.sh
index b65f722..0c99c11 100644 (file)
@@ -7,7 +7,12 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-[ "$EXCEPT" ] && echo "Skipping tests: `echo $EXCEPT`"
+# bug number for skipped test: 19430 19967 19967
+ALWAYS_EXCEPT="                2     5     6    $SANITY_SEC_EXCEPT"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+[ "$ALWAYS_EXCEPT$EXCEPT" ] && \
+    echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
 
 SRCDIR=`dirname $0`
 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
@@ -17,6 +22,7 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
 
 RUNAS=${RUNAS:-"$LUSTRE/tests/runas"}
 WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
@@ -26,8 +32,8 @@ PERM_CONF=$CONFDIR/perm.conf
 SANITYSECLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
 FAIL_ON_ERROR=false
 
-remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
-remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
+require_dsh_mds || exit 0
+require_dsh_ost || exit 0
 
 ID0=${ID0:-500}
 ID1=${ID1:-501}
@@ -42,6 +48,12 @@ USER1=`cat /etc/passwd|grep :$ID1:$ID1:|cut -d: -f1`
 
 check_and_setup_lustre
 
+sec_cleanup() {
+       if [ "$I_MOUNTED" = "yes" ]; then
+               cleanupall -f || error "sec_cleanup"
+       fi
+}
+
 DIR=${DIR:-$MOUNT}
 [ -z "`echo $DIR | grep $MOUNT`" ] && \
        error "$DIR not in $MOUNT" && sec_cleanup && exit 1
@@ -62,17 +74,13 @@ else
        echo "without GSS support"
 fi
 
-MDT="`do_facet $SINGLEMDS "lctl get_param -N mdt.\*MDT\*/stats 2>/dev/null | cut -d"." -f2" || true`"
-if [ ! -z "$MDT" ]; then
-       do_facet $SINGLEMDS "mkdir -p $CONFDIR"
-       IDENTITY_FLUSH=mdt.$MDT.identity_flush
-       MDSCAPA=mdt.$MDT.capa
-       CAPA_TIMEOUT=mdt.$MDT.capa_timeout
-       MDSSECLEVEL=mdt.$MDT.sec_level
-       LOCALMDT=$MDT
-else
-       LOCALMDT=""
-fi
+MDT="`do_facet $SINGLEMDS "lctl get_param -N mdt.\*MDT\*.stats 2>/dev/null | cut -d"." -f2" || true`"
+[ -z "$MDT" ] && error "fail to get MDT device" && exit 1
+do_facet $SINGLEMDS "mkdir -p $CONFDIR"
+IDENTITY_FLUSH=mdt.$MDT.identity_flush
+MDSCAPA=mdt.$MDT.capa
+CAPA_TIMEOUT=mdt.$MDT.capa_timeout
+MDSSECLEVEL=mdt.$MDT.sec_level
 
 # for CLIENT_TYPE
 if [ -z "$(lctl get_param -n llite.*.client_type | grep remote 2>/dev/null)" ]; then
@@ -128,11 +136,10 @@ test_0() {
        umask 0022
 
        chmod 0755 $DIR || error "chmod (1)"
-       rm -rf $DIR/* || error "rm (1)"
+       rm -rf $DIR/$tdir || error "rm (1)"
        mkdir -p $DIR/$tdir || error "mkdir (1)"
 
        if [ "$CLIENT_TYPE" = "remote" ]; then
-               [ -z "$MDT" ] && skip "do not support do_facet operations." && return
                do_facet $SINGLEMDS "echo '* 0 normtown' > $PERM_CONF"
                do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
                chown $USER0 $DIR/$tdir && error "chown (1)"
@@ -154,7 +161,7 @@ test_0() {
        $RUNAS -u $ID0 touch $DIR/$tdir/f4 || error "touch (5)"
        $RUNAS -u $ID1 touch $DIR/$tdir/f5 && error "touch (6)"
        touch $DIR/$tdir/f6 || error "touch (7)"
-       rm -rf $DIR/* || error "rm (3)"
+       rm -rf $DIR/$tdir || error "rm (3)"
 
        if [ "$CLIENT_TYPE" = "remote" ]; then
                do_facet $SINGLEMDS "rm -f $PERM_CONF"
@@ -166,7 +173,6 @@ run_test 0 "uid permission ============================="
 # setuid/gid
 test_1() {
        [ $GSS_SUP = 0 ] && skip "without GSS support." && return
-       [ -z "$MDT" ] && skip "do not support do_facet operations." && return
 
        if [ "$CLIENT_TYPE" = "remote" ]; then
                do_facet $SINGLEMDS "echo '* 0 rmtown' > $PERM_CONF"
@@ -216,7 +222,6 @@ test_2 () {
        [ -z "$(which setfacl 2>/dev/null)" ] && \
                skip "could not find setfacl" && return
        [ "$UID" != 0 ] && skip "must run as root" && return
-       [ -z "$MDT" ] && skip "do not support do_facet operations." && return
 
        do_facet $SINGLEMDS "echo '* 0 rmtacl,rmtown' > $PERM_CONF"
        do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
@@ -269,7 +274,6 @@ run_test 3 "rootsquash ============================="
 # will be obtained by upcall /sbin/l_getidentity and used.
 test_4() {
        if [ "$CLIENT_TYPE" = "remote" ]; then
-               [ -z "$MDT" ] && skip "do not support do_facet operations." && return
                do_facet $SINGLEMDS "echo '* 0 rmtown' > $PERM_CONF"
                do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
        fi
@@ -280,19 +284,15 @@ test_4() {
         chgrp $ID0 $DIR/$tdir
        $RUNAS -u $ID0 ls $DIR/$tdir || error "setgroups (1)"
        if [ "$CLIENT_TYPE" = "local" ]; then
-               if [ ! -z "$MDT" ]; then
-                       do_facet $SINGLEMDS "echo '* $ID1 setgrp' > $PERM_CONF"
-                       do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
-                       $RUNAS -u $ID1 -G1,2,$ID0 ls $DIR/$tdir || error "setgroups (2)"
-               fi
+               do_facet $SINGLEMDS "echo '* $ID1 setgrp' > $PERM_CONF"
+               do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
+               $RUNAS -u $ID1 -G1,2,$ID0 ls $DIR/$tdir || error "setgroups (2)"
        fi
        $RUNAS -u $ID1 -G1,2 ls $DIR/$tdir && error "setgroups (3)"
        rm -rf $DIR/$tdir
 
-       if [ ! -z "$MDT" ]; then
-               do_facet $SINGLEMDS "rm -f $PERM_CONF"
-               do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
-       fi
+       do_facet $SINGLEMDS "rm -f $PERM_CONF"
+       do_facet $SINGLEMDS "lctl set_param -n $IDENTITY_FLUSH=-1"
 }
 run_test 4 "set supplementary group ==============="
 
@@ -425,8 +425,11 @@ test_5() {
         local file=$DIR/f5
 
        [ $GSS_SUP = 0 ] && skip "without GSS support." && return
-       [ -z "$MDT" ] && skip "do not support do_facet operations." && return
-       [ ! -z "$LOCALMDT" ] && skip "client should be separated from server." && return
+       if ! remote_mds; then
+                skip "client should be separated from server."
+                return
+        fi
+
        rm -f $file
 
        turn_capability_off
@@ -493,8 +496,10 @@ test_6() {
         local file=$DIR/f6
 
        [ $GSS_SUP = 0 ] && skip "without GSS support." && return
-       [ -z "$MDT" ] && skip "do not support do_facet operations." && return
-       [ ! -z "$LOCALMDT" ] && skip "client should be separated from server." && return
+       if ! remote_mds; then
+                skip "client should be separated from server."
+                return
+        fi
 
        turn_capability_off
        if [ $? != 0 ]; then
@@ -565,11 +570,6 @@ sec_unsetup() {
 }
 sec_unsetup
 
-sec_cleanup() {
-       if [ "$I_MOUNTED" = "yes" ]; then
-               cleanupall -f || error "sec_cleanup"
-       fi
-}
 sec_cleanup
 
 echo '=========================== finished ==============================='