Whamcloud - gitweb
LU-7859 tests: Use getent instead of /etc/passwd
[fs/lustre-release.git] / lustre / tests / sanity-sec.sh
index 612cba1..7fc381d 100755 (executable)
@@ -11,8 +11,6 @@ ONLY=${ONLY:-"$*"}
 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
 export NAME=${NAME:-local}
@@ -23,6 +21,11 @@ init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 init_logging
 
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="26"
+
+[ "$ALWAYS_EXCEPT$EXCEPT$EXCEPT_SLOW" ] &&
+       echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT $EXCEPT_SLOW"
+
 RUNAS_CMD=${RUNAS_CMD:-runas}
 
 WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
@@ -47,14 +50,14 @@ clients_arr=($clients)
 
 ID0=${ID0:-500}
 ID1=${ID1:-501}
-USER0=$(grep :$ID0:$ID0: /etc/passwd | cut -d: -f1)
-USER1=$(grep :$ID1:$ID1: /etc/passwd | cut -d: -f1)
+USER0=$(getent passwd | grep :$ID0:$ID0: | cut -d: -f1)
+USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
 
 [ -z "$USER0" ] &&
-       skip "need to add user0 ($ID0:$ID0) to /etc/passwd" && exit 0
+       skip "need to add user0 ($ID0:$ID0)" && exit 0
 
 [ -z "$USER1" ] &&
-       skip "need to add user1 ($ID1:$ID1) to /etc/passwd" && exit 0
+       skip "need to add user1 ($ID1:$ID1)" && exit 0
 
 IDBASE=${IDBASE:-60000}
 
@@ -467,6 +470,9 @@ modify_flags() {
 }
 
 squash_id() {
+       [ $(lustre_version_code mgs) -lt $(version_code 2.5.53) ] &&
+               skip "No nodemap on $(lustre_build_version mgs) MGS < 2.5.53" &&
+               return
        local cmd
 
        cmd[0]="$LCTL nodemap_modify --property squash_uid"
@@ -501,7 +507,7 @@ test_idmap() {
        local rc=0
 
        ## nodemap deactivated
-       if ! do_facet mgs lctl nodemap_activate 0; then
+       if ! do_facet mgs $LCTL nodemap_activate 0; then
                return 1
        fi
        for ((id = 500; id < NODEMAP_MAX_ID; id++)); do
@@ -519,7 +525,7 @@ test_idmap() {
        done
 
        ## nodemap activated
-       if ! do_facet mgs lctl nodemap_activate 1; then
+       if ! do_facet mgs $LCTL nodemap_activate 1; then
                return 2
        fi
 
@@ -1037,7 +1043,7 @@ fops_test_setup() {
        do_servers_not_mgs $LCTL set_param nodemap.c0.trusted_nodemap=$trust
 
        # flush MDT locks to make sure they are reacquired before test
-       do_node ${clients_arr[0]} lctl set_param \
+       do_node ${clients_arr[0]} $LCTL set_param \
                ldlm.namespaces.$FSNAME-MDT*.lru_size=clear
 }
 
@@ -1521,11 +1527,46 @@ test_24() {
 }
 run_test 24 "check nodemap proc files for LBUGs and Oopses"
 
+test_25() {
+       nodemap_version_check || return 0
+       nodemap_test_setup
+
+       trap nodemap_test_cleanup EXIT
+       local tmpfile=$(mktemp)
+       do_facet mgs $LCTL nodemap_info > $tmpfile
+       cleanup_and_setup_lustre
+       diff -q <(do_facet mgs $LCTL nodemap_info) $tmpfile >& /dev/null ||
+               error "nodemap_info diff after remount"
+
+       nodemap_test_cleanup
+       rm -f $tmpfile
+}
+run_test 25 "test save and reload nodemap config"
+
+test_26() {
+       nodemap_version_check || return 0
+
+       local large_i=13000
+
+       for ((i = 0; i < large_i; i++)); do
+               ((i % 1000 == 0)) && echo $i
+               do_facet mgs $LCTL nodemap_add c$i ||
+                       error "cannot add nodemap $i to config"
+       done
+
+       for ((i = 0; i < large_i; i++)); do
+               ((i % 1000 == 0)) && echo $i
+               do_facet mgs $LCTL nodemap_del c$i ||
+                       error "cannot delete nodemap $i from config"
+       done
+}
+run_test 26 "test transferring very large nodemap"
+
 log "cleanup: ======================================================"
 
 sec_unsetup() {
        ## nodemap deactivated
-       do_facet mgs lctl nodemap_activate 0
+       do_facet mgs $LCTL nodemap_activate 0
 
        for num in $(seq $MDSCOUNT); do
                if [ "${identity_old[$num]}" = 1 ]; then