3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
16 ALWAYS_EXCEPT="$SANITY_GSS_EXCEPT "
18 # bug number for skipped tests: LU-9795 LU-9795
19 ALWAYS_EXCEPT+=" 8 90 "
22 [ "$SLOW" = "no" ] && EXCEPT_SLOW="100 101"
26 require_dsh_mds || exit 0
28 # $RUNAS_ID may get set incorrectly somewhere else
29 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
30 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
32 # remove $SEC, we'd like to control everything by ourselves
36 # global variables of this sanity
43 # we want double mount
44 MOUNT_2=${MOUNT_2:-"yes"}
45 check_and_setup_lustre
47 rm -rf $DIR/[df][0-9]*
49 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
53 NPROC=`cat /proc/cpuinfo 2>/dev/null | grep ^processor | wc -l`
54 [ $NPROC -gt 2 ] && NPROC=2
55 bash rundbench $NPROC 1>/dev/null &
59 num=`ps --no-headers -p $DBENCH_PID 2>/dev/null | wc -l`
60 if [ $num -ne 1 ]; then
61 error "failed to start dbench $NPROC"
63 echo "started dbench with $NPROC processes at background"
71 num=`ps --no-headers -p $DBENCH_PID 2>/dev/null | wc -l`
72 if [ $num -eq 0 ]; then
73 echo "dbench $DBENCH_PID already finished"
74 wait $DBENCH_PID || error "dbench $PID exit with error"
76 elif [ $num -ne 1 ]; then
78 error "found $num instance of pid $DBENCH_PID ???"
87 killall dbench 2>/dev/null
88 num=`ps --no-headers -p $DBENCH_PID | wc -l`
89 if [ $num -eq 0 ]; then
90 echo "dbench finished"
93 echo "dbench $DBENCH_PID is still running, waiting 2s..."
97 wait $DBENCH_PID || true
104 # Stop previously existing gss daemons
107 echo "bring up gss daemons..."
108 # start gss daemon with -z flag for gssnull
109 start_gss_daemons $(comma_list $(mdts_nodes)) "$LSVCGSSD -z -vv" ||
110 error "can't start gss daemons on MDTs"
111 start_gss_daemons $(comma_list $(osts_nodes)) "$LSVCGSSD -z -vv" ||
112 error "can't start gss daemons on OSTs"
114 lctl set_param sptlrpc.gss.lgss_keyring.debug_level=4
116 echo "cat /etc/request-key.d/lgssc.conf"
117 cat /etc/request-key.d/lgssc.conf ||
118 error_noexit "/etc/request-key.d/lgssc.conf does not exist"
119 echo "cat /etc/request-key.conf"
120 cat /etc/request-key.conf ||
121 error_noexit "/etc/request-key.conf does not exist"
123 set_flavor_all gssnull
126 local file=$DIR/$tfile
128 chmod 0777 $DIR || error "chmod $DIR failed"
130 $RUNAS $LFS flushctx $MOUNT || error "can't flush context on $MOUNT"
132 $RUNAS touch $file || error "should not fail"
133 [ -f $file ] || error "$file not found"
135 run_test 1 "create file"
138 local file1=$DIR/$tfile-1
139 local file2=$DIR/$tfile-2
141 chmod 0777 $DIR || error "chmod $DIR failed"
142 # current access should be ok
143 $RUNAS touch $file1 || error "can't touch $file1"
144 [ -f $file1 ] || error "$file1 not found"
146 # cleanup all cred/ctx and touch
147 $RUNAS $LFS flushctx $MOUNT || error "can't flush context on $MOUNT"
148 $RUNAS touch $file2 && error "unexpected success"
150 run_test 2 "lfs flushctx"
153 local file=$DIR/$tfile
156 echo "aaaaaaaaaaaaaaaaa" > $file
158 $CHECKSTAT -p 0666 $file || error "$UID checkstat error"
159 $RUNAS $CHECKSTAT -p 0666 $file || error "$RUNAS_ID checkstat error"
160 $RUNAS cat $file > /dev/null || error "$RUNAS_ID cat error"
163 $RUNAS $MULTIOP $file o_r &
165 # wait multiop finish its open()
168 # cleanup all cred/ctx and check
169 # metadata check should fail, but file data check should success
170 # because we always use root credential to OSTs
171 $RUNAS $LFS flushctx $MOUNT || error "can't flush context on $MOUNT"
172 echo "destroied credentials/contexs for $RUNAS_ID"
173 $RUNAS $CHECKSTAT -p 0666 $file && error "checkstat succeed"
175 wait $OPPID || error "read file data failed"
176 echo "read file data OK"
178 run_test 3 "local cache under DLM lock"
183 mkdir $DIR/d6 || error "mkdir $DIR/d6 failed"
184 for ((i=0; i<$nfile; i++)); do
185 dd if=/dev/zero of=$DIR/d6/file$i bs=8k count=1 || error "dd file$i failed"
187 ls -l $DIR/d6/* > /dev/null || error "ls failed"
188 rm -rf $DIR2/d6/* || error "rm failed"
189 rmdir $DIR2/d6/ || error "rmdir failed"
191 run_test 6 "test basic DLM callback works"
197 # for open(), client only reserve space for default stripe count lovea,
198 # and server may return larger lovea in reply (because of larger stripe
199 # count), client need call enlarge_reqbuf() and save the replied lovea
200 # in request for future possible replay.
202 # Note: current script does NOT guarantee enlarge_reqbuf() will be in
203 # the path, however it does work in local test which has 2 OSTs and
204 # default stripe count is 1.
205 num_osts=$($LFS getstripe $MOUNT | egrep "^[0-9]*:.*ACTIVE" | wc -l)
206 echo "found $num_osts active OSTs"
207 [ $num_osts -lt 2 ] &&
208 echo "skipping $TESTNAME (must have >= 2 OSTs)" && return
210 mkdir $tdir || error "mkdir $tdir failed"
211 $LFS setstripe -c $num_osts $tdir || error "setstripe -c $num_osts"
214 for ((i = 0; i < 20; i++)); do
215 dd if=/dev/zero of=$tdir/f$i bs=4k count=16 2>/dev/null
218 for ((i = 0; i < 20; i++)); do
219 dd if=$tdir/f$i of=/dev/null bs=4k count=16 2>/dev/null
223 run_test 7 "exercise enlarge_reqbuf()"
227 local ATHISTORY=$(do_facet $SINGLEMDS "find /sys/ -name at_history")
228 local ATOLDBASE=$(do_facet $SINGLEMDS "cat $ATHISTORY")
230 do_facet $SINGLEMDS "echo 8 >> $ATHISTORY"
237 sysctl -w lnet.debug="+other"
239 # wait for the at estimation come down, this is faster
241 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
242 awk '/portal 12/ {print $5}' | tail -1`
243 [ $REQ_DELAY -le 5 ] && break
244 echo "current AT estimation is $REQ_DELAY, wait a little bit"
247 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
249 # sleep sometime in ctx handle
250 do_facet $SINGLEMDS lctl set_param fail_val=$REQ_DELAY
251 #define OBD_FAIL_SEC_CTX_HDL_PAUSE 0x1204
252 do_facet $SINGLEMDS lctl set_param fail_loc=0x1204
254 $RUNAS $LFS flushctx $MOUNT || error "can't flush context on $MOUNT"
256 $RUNAS touch $DIR/d8/f &
258 echo "waiting for touch (pid $TOUCHPID) to finish..."
259 sleep 2 # give it a chance to really trigger context init rpc
260 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
261 wait $TOUCHPID || error "touch should have succeeded"
263 $LCTL dk | grep -i "Early reply #" || error "No early reply"
266 do_facet $SINGLEMDS "echo $ATOLDBASE >> $ATHISTORY" || true
268 run_test 8 "Early reply sent for slow gss context negotiation"
271 # following tests will manipulate flavors and may end with any flavor set,
272 # so each test should not assume any start flavor.
276 if [ "$SLOW" = "no" ]; then
282 restore_to_default_flavor
283 set_rule $FSNAME any any gssnull
284 wait_flavor all2all gssnull
288 for ((n=0;n<$total;n++)); do
291 echo "flush ctx ($n/$total) ..."
292 $LFS flushctx $MOUNT || error "can't flush context on $MOUNT"
295 #sleep to let ctxs be re-established
299 run_test 90 "recoverable from losing contexts under load"
309 nrule_old=`do_facet mgs lctl get_param -n mgs.MGS.live.$FSNAME 2>/dev/null \
310 | grep "$FSNAME.srpc.flavor." | wc -l`
311 echo "original general rules: $nrule_old"
313 for ((i = $nrule_old; i < $max; i++)); do
314 set_rule $FSNAME elan$i any gssnull || error "set rule $i"
316 for ((i = $nrule_old; i < $max; i++)); do
317 set_rule $FSNAME elan$i any || error "remove rule $i"
320 nrule_new=`do_facet mgs lctl get_param -n mgs.MGS.live.$FSNAME 2>/dev/null \
321 | grep "$FSNAME.srpc.flavor." | wc -l`
322 if [ $nrule_new != $nrule_old ]; then
323 error "general rule: $nrule_new != $nrule_old"
326 run_test 99 "set large number of sptlrpc rules"
339 # started from default flavors
340 restore_to_default_flavor
342 # running dbench background
346 # all: null -> gssnull -> plain
348 set_rule $FSNAME any any gssnull
349 wait_flavor all2all gssnull || error_dbench "1"
352 set_rule $FSNAME any any plain
353 wait_flavor all2all plain || error_dbench "2"
362 set_rule $FSNAME any mdt2mdt gssnull
363 wait_flavor mdt2mdt gssnull || error_dbench "3"
366 set_rule $FSNAME any cli2mdt gssnull
367 wait_flavor cli2mdt gssnull || error_dbench "4"
370 set_rule $FSNAME any mdt2ost gssnull
371 wait_flavor mdt2ost gssnull || error_dbench "5"
374 set_rule $FSNAME any cli2ost gssnull
375 wait_flavor cli2ost gssnull || error_dbench "6"
382 # nothing should be changed because they are override by above dir rules
384 set_rule $FSNAME-MDT0000 any any plain
385 set_rule $FSNAME-OST0000 any any plain
386 wait_flavor mdt2mdt gssnull || error_dbench "7"
387 wait_flavor cli2mdt gssnull || error_dbench "8"
389 wait_flavor mdt2ost gssnull || error_dbench "9"
390 wait_flavor cli2ost gssnull || error_dbench "10"
393 # delete all dir-specific rules
395 set_rule $FSNAME any mdt2mdt
396 set_rule $FSNAME any cli2mdt
397 set_rule $FSNAME any mdt2ost
398 set_rule $FSNAME any cli2ost
399 wait_flavor mdt2mdt gssnull $((MDSCOUNT - 1)) || error_dbench "11"
400 wait_flavor cli2mdt gssnull $(get_clients_mount_count) ||
403 wait_flavor mdt2ost gssnull $MDSCOUNT || error_dbench "13"
404 wait_flavor cli2ost gssnull $(get_clients_mount_count) ||
413 set_rule $FSNAME-MDT0000 any any
414 set_rule $FSNAME-OST0000 any any || error_dbench "15"
415 wait_flavor all2all plain || error_dbench "16"
420 run_test 100 "change security flavor on the fly under load"
426 local filename=$DIR/$tfile
431 # after set to flavor0, start multop which use flavor0 rpc, and let
432 # server drop the reply; then switch to flavor1, the resend should be
433 # completed using flavor1. To exercise the code of switching ctx/sec
434 # for a resend request.
436 log ">>>>>>>>>>>>>>> Testing $flavor0 -> $flavor1 <<<<<<<<<<<<<<<<<<<"
438 set_rule $FSNAME any cli2mdt $flavor0
439 wait_flavor cli2mdt $flavor0
440 rm -f $filename || error "remove old $filename failed"
443 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
444 do_facet $SINGLEMDS lctl set_param fail_val=36
445 do_facet $SINGLEMDS lctl set_param fail_loc=0x513
446 log "starting multiop"
447 $MULTIOP $filename m &
449 echo "multiop pid=$multiop_pid"
452 set_rule $FSNAME any cli2mdt $flavor1
453 wait_flavor cli2mdt $flavor1
455 num=`ps --no-headers -p $multiop_pid 2>/dev/null | wc -l`
456 [ $num -eq 1 ] || error "multiop($multiop_pid) already ended ($num)"
457 echo "process $multiop_pid is still hanging there... OK"
459 do_facet $SINGLEMDS lctl set_param fail_loc=0
460 log "waiting for multiop ($multiop_pid) to finish"
461 wait $multiop_pid || error "multiop returned error"
466 # started from default flavors
467 restore_to_default_flavor
469 switch_sec_test null plain
470 switch_sec_test plain gssnull
471 switch_sec_test gssnull null
472 switch_sec_test null gssnull
473 switch_sec_test gssnull plain
474 switch_sec_test plain gssnull
476 run_test 101 "switch ctx/sec for resending request"
489 # started from default flavors
490 restore_to_default_flavor
492 # run dbench background
495 echo "Testing null->gssnull->plain->null"
496 set_rule $FSNAME any any gssnull
497 set_rule $FSNAME any any plain
498 set_rule $FSNAME any any null
501 wait_flavor all2all null || error_dbench "1"
504 echo "waiting for 15s and check again"
508 echo "Testing null->gssnull->null->gssnull->null..."
509 for ((i=0; i<10; i++)); do
510 set_rule $FSNAME any any gssnull
511 set_rule $FSNAME any any null
513 set_rule $FSNAME any any gssnull
516 wait_flavor all2all gssnull || error_dbench "2"
519 echo "waiting for 15s and check again"
525 run_test 102 "survive from insanely fast flavor switch"
530 local clients=$CLIENTS
532 [ -z $clients ] && clients=$HOSTNAME
534 # started from default flavors
535 restore_to_default_flavor
537 # at this time no rules has been set on mgs; mgc use null
538 # flavor connect to mgs.
539 count=`flvr_cnt_mgc2mgs null`
540 [ $count -eq 1 ] || error "$count mgc connection use null flavor"
542 zconf_umount_clients $clients $MOUNT || return 1
544 # mount client with conflict flavor - should fail
545 mount_opts="${MOUNT_OPTS:+$MOUNT_OPTS,}mgssec=gssnull"
546 zconf_mount_clients $clients $MOUNT $mount_opts &&
547 error "mount with conflict flavor should have failed"
549 # mount client with same flavor - should succeed
550 mount_opts="${MOUNT_OPTS:+$MOUNT_OPTS,}mgssec=null"
551 zconf_mount_clients $clients $MOUNT $mount_opts ||
552 error "mount with same flavor should have succeeded"
553 zconf_umount_clients $clients $MOUNT || return 2
555 # mount client with default flavor - should succeed
556 zconf_mount_clients $clients $MOUNT || \
557 error "mount with default flavor should have succeeded"
559 run_test 150 "secure mgs connection: client flavor setting"
564 # set mgs only accept gssnull
565 set_rule _mgs any any gssnull
567 # umount everything, modules still loaded
570 # mount mgs with default flavor, in current framework it means mgs+mdt1.
571 # the connection of mgc of mdt1 to mgs is expected fail.
572 DEVNAME=$(mdsdevname 1)
573 start mds1 $DEVNAME $MDS_MOUNT_OPTS && error "mount with default flavor should have failed"
575 # mount with unauthorized flavor should fail
576 save_opts=$MDS_MOUNT_OPTS
577 MDS_MOUNT_OPTS="$MDS_MOUNT_OPTS,mgssec=null"
578 start mds1 $DEVNAME $MDS_MOUNT_OPTS && error "mount with unauthorized flavor should have failed"
579 MDS_MOUNT_OPTS=$save_opts
581 # mount with designated flavor should succeed
582 save_opts=$MDS_MOUNT_OPTS
583 MDS_MOUNT_OPTS="$MDS_MOUNT_OPTS,mgssec=gssnull"
584 start mds1 $DEVNAME $MDS_MOUNT_OPTS ||
585 error "mount with designated flavor should have succeeded"
586 MDS_MOUNT_OPTS=$save_opts
590 run_test 151 "secure mgs connection: server flavor control"
593 if $GSS_KRB5 || $GSS_SK; then
597 restore_to_default_flavor
600 check_and_cleanup_lustre