Whamcloud - gitweb
LU-544 reduce the journal size for conf-sanity test 56
[fs/lustre-release.git] / lustre / tests / parallel-scale.sh
1 #!/bin/bash
2 #
3 #set -vx
4
5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
6 . $LUSTRE/tests/test-framework.sh
7 init_test_env $@
8 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
9 init_logging
10
11 # bug number:
12 ALWAYS_EXCEPT="$PARALLEL_SCALE_EXCEPT"
13
14 #
15 # compilbench
16 #
17 cbench_DIR=${cbench_DIR:-""}
18 cbench_IDIRS=${cbench_IDIRS:-10}
19 cbench_RUNS=${cbench_RUNS:-10}  # FIXME: wiki page requirements is 30, do we really need 30 ?
20
21 if [ "$SLOW" = "no" ]; then
22     cbench_IDIRS=2
23     cbench_RUNS=2
24 fi
25
26 #
27 # metabench
28 #
29 METABENCH=${METABENCH:-$(which metabench 2> /dev/null || true)}
30 mbench_NFILES=${mbench_NFILES:-30400}
31 [ "$SLOW" = "no" ] && mbench_NFILES=10000
32 MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
33 # threads per client
34 mbench_THREADS=${mbench_THREADS:-4}
35
36 #
37 # simul
38 #
39 SIMUL=${SIMUL:=$(which simul 2> /dev/null || true)}
40 # threads per client
41 simul_THREADS=${simul_THREADS:-2}
42 simul_REP=${simul_REP:-20}
43 [ "$SLOW" = "no" ] && simul_REP=2
44
45 #
46 # connectathon
47 #
48 cnt_DIR=${cnt_DIR:-""}
49 cnt_NRUN=${cnt_NRUN:-10}
50 [ "$SLOW" = "no" ] && cnt_NRUN=2
51
52 #
53 # cascading rw
54 #
55 CASC_RW=${CASC_RW:-$(which cascading_rw 2> /dev/null || true)}
56 # threads per client
57 casc_THREADS=${casc_THREADS:-2}
58 casc_REP=${casc_REP:-300}
59 [ "$SLOW" = "no" ] && casc_REP=10
60
61 #
62 # IOR
63 #
64 IOR=${IOR:-$(which IOR 2> /dev/null || true)}
65 # threads per client
66 ior_THREADS=${ior_THREADS:-2}
67 ior_blockSize=${ior_blockSize:-6}       # Gb
68 ior_DURATION=${ior_DURATION:-30}        # minutes
69 [ "$SLOW" = "no" ] && ior_DURATION=5
70
71 #
72 # write_append_truncate
73 #
74 # threads per client
75 write_THREADS=${write_THREADS:-8}
76 write_REP=${write_REP:-10000}
77 [ "$SLOW" = "no" ] && write_REP=100
78
79 #
80 # write_disjoint
81 #
82 WRITE_DISJOINT=${WRITE_DISJOINT:-$(which write_disjoint 2> /dev/null || true)}
83 # threads per client
84 wdisjoint_THREADS=${wdisjoint_THREADS:-4}
85 wdisjoint_REP=${wdisjoint_REP:-10000}
86 [ "$SLOW" = "no" ] && wdisjoint_REP=100
87
88 #
89 # parallel_grouplock
90 #
91 #
92 PARALLEL_GROUPLOCK=${PARALLEL_GROUPLOCK:-$(which parallel_grouplock 2> /dev/null || true)}
93 parallel_grouplock_MINTASKS=${parallel_grouplock_MINTASKS:-5}
94
95 build_test_filter
96 check_and_setup_lustre
97
98 print_opts () {
99     local var
100
101     echo OPTIONS:
102
103     for i in $@; do
104         var=$i
105         echo "${var}=${!var}"
106     done
107     [ -e $MACHINEFILE ] && cat $MACHINEFILE
108 }
109
110 # Takes:
111 # 5 min * cbench_RUNS
112 #        SLOW=no     10 mins
113 #        SLOW=yes    50 mins
114 # Space estimation:
115 #        compile dir kernel-1 680MB
116 #        required space       680MB * cbench_IDIRS = ~7 Gb
117
118 test_compilebench() {
119     print_opts cbench_DIR cbench_IDIRS cbench_RUNS
120
121     [ x$cbench_DIR = x ] &&
122         { skip_env "compilebench not found" && return; }
123
124     [ -e $cbench_DIR/compilebench ] || \
125         { skip_env "No compilebench build" && return; }
126
127     local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
128     if [ $space -le $((680 * 1024 * cbench_IDIRS)) ]; then
129         cbench_IDIRS=$(( space / 680 / 1024))
130         [ $cbench_IDIRS = 0 ] && \
131             skip_env "Need free space atleast 680 Mb, have $space" && return
132
133         log free space=$space, reducing initial dirs to $cbench_IDIRS
134     fi
135     # FIXME:
136     # t-f _base needs to be modifyed to set properly tdir
137     # for new "test_foo" functions names
138     # local testdir=$DIR/$tdir
139     local testdir=$DIR/d0.compilebench
140     mkdir -p $testdir
141
142     local savePWD=$PWD
143     cd $cbench_DIR
144     local cmd="./compilebench -D $testdir -i $cbench_IDIRS -r $cbench_RUNS --makej"
145
146     log "$cmd"
147
148     local rc=0
149     eval $cmd
150     rc=$?
151
152     cd $savePWD
153     [ $rc = 0 ] || error "compilebench failed: $rc"
154     rm -rf $testdir
155 }
156 run_test compilebench "compilebench"
157
158 test_metabench() {
159     [ x$METABENCH = x ] &&
160         { skip_env "metabench not found" && return; }
161
162     local clients=$CLIENTS
163     [ -z $clients ] && clients=$(hostname)
164
165     num_clients=$(get_node_count ${clients//,/ })
166
167     # FIXME
168     # Need space estimation here.
169
170     generate_machine_file $clients $MACHINEFILE || return $?
171
172     print_opts METABENCH clients mbench_NFILES mbench_THREADS
173
174     local testdir=$DIR/d0.metabench
175     mkdir -p $testdir
176     # mpi_run uses mpiuser
177     chmod 0777 $testdir
178
179     # -C             Run the file creation tests.
180     # -S             Run the file stat tests.
181     # -c nfile       Number of files to be used in each test.
182     # -k             Cleanup.  Remove the test directories.
183     local cmd="$METABENCH -w $testdir -c $mbench_NFILES -C -S -k"
184     echo "+ $cmd"
185     mpi_run -np $((num_clients * $mbench_THREADS)) -machinefile ${MACHINEFILE} $cmd
186     local rc=$?
187     if [ $rc != 0 ] ; then
188         error "metabench failed! $rc"
189     fi
190     rm -rf $testdir
191 }
192 run_test metabench "metabench"
193
194 test_simul() {
195     if [ "$NFSCLIENT" ]; then
196         skip "skipped for NFSCLIENT mode"
197         return
198     fi
199
200     [ x$SIMUL = x ] &&
201         { skip_env "simul not found" && return; }
202
203     local clients=$CLIENTS
204     [ -z $clients ] && clients=$(hostname)
205
206     local num_clients=$(get_node_count ${clients//,/ })
207
208     # FIXME
209     # Need space estimation here.
210
211     generate_machine_file $clients $MACHINEFILE || return $?
212
213     print_opts SIMUL clients simul_REP simul_THREADS
214
215     local testdir=$DIR/d0.simul
216     mkdir -p $testdir
217     # mpi_run uses mpiuser
218     chmod 0777 $testdir
219
220     # -n # : repeat each test # times
221     # -N # : repeat the entire set of tests # times
222
223     local cmd="$SIMUL -d $testdir -n $simul_REP -N $simul_REP"
224
225     echo "+ $cmd"
226     mpi_run -np $((num_clients * $simul_THREADS)) -machinefile ${MACHINEFILE} $cmd
227
228     local rc=$?
229     if [ $rc != 0 ] ; then
230         error "simul failed! $rc"
231     fi
232     rm -rf $testdir
233 }
234 run_test simul "simul"
235
236 test_connectathon() {
237     print_opts cnt_DIR cnt_NRUN
238
239     [ x$cnt_DIR = x ] &&
240         { skip_env "connectathon dir not found" && return; }
241
242     [ -e $cnt_DIR/runtests ] || \
243         { skip_env "No connectathon runtests found" && return; }
244
245     local testdir=$DIR/d0.connectathon
246     mkdir -p $testdir
247
248     local savePWD=$PWD
249     cd $cnt_DIR
250
251     #
252     # cthon options (must be in this order)
253     #
254     # -N numpasses - will be passed to the runtests script.  This argument
255     #         is optional.  It specifies the number of times to run
256     #         through the tests.
257     #
258     # One of these test types
259     #    -b  basic
260     #    -g  general
261     #    -s  special
262     #    -l  lock
263     #    -a  all of the above
264     #
265     # -f      a quick functionality test
266     #
267
268     tests="-b -g -s"
269     # Include lock tests unless we're running on nfsv4
270     local fstype=$(df -TP $testdir | awk 'NR==2  {print $2}')
271     echo "$testdir: $fstype"
272     if [[ $fstype != "nfs4" ]]; then
273         tests="$tests -l"
274     fi
275     echo "tests: $tests"
276     for test in $tests; do
277         local cmd="./runtests -N $cnt_NRUN $test -f $testdir"
278         local rc=0
279
280         log "$cmd"
281         eval $cmd
282         rc=$?
283         [ $rc = 0 ] || error "connectathon failed: $rc"
284     done
285
286     cd $savePWD
287     rm -rf $testdir
288 }
289 run_test connectathon "connectathon"
290
291 test_ior() {
292     [ x$IOR = x ] &&
293         { skip_env "IOR not found" && return; }
294
295     local clients=$CLIENTS
296     [ -z $clients ] && clients=$(hostname)
297
298     local num_clients=$(get_node_count ${clients//,/ })
299
300     local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
301     echo "+ $ior_blockSize * 1024 * 1024 * $num_clients * $ior_THREADS "
302     if [ $((space / 2)) -le $(( ior_blockSize * 1024 * 1024 * num_clients * ior_THREADS)) ]; then
303         echo "+ $space * 9/10 / 1024 / 1024 / $num_clients / $ior_THREADS"
304         ior_blockSize=$(( space /2 /1024 /1024 / num_clients / ior_THREADS ))
305         [ $ior_blockSize = 0 ] && \
306             skip_env "Need free space more than ($num_clients * $ior_THREADS )Gb: $((num_clients*ior_THREADS *1024 *1024*2)), have $space" && return
307
308         echo "free space=$space, Need: $num_clients x $ior_THREADS x $ior_blockSize Gb (blockSize reduced to $ior_blockSize Gb)"
309     fi
310
311     generate_machine_file $clients $MACHINEFILE || return $?
312
313     print_opts IOR ior_THREADS ior_DURATION MACHINEFILE
314
315     local testdir=$DIR/d0.ior
316     mkdir -p $testdir
317     # mpi_run uses mpiuser
318     chmod 0777 $testdir
319     if [ "$NFSCLIENT" ]; then
320         setstripe_nfsserver $testdir -c -1 ||
321             { error "setstripe on nfsserver failed" && return 1; }
322     else
323         $LFS setstripe $testdir -c -1 ||
324             { error "setstripe failed" && return 2; }
325     fi
326     #
327     # -b N  blockSize -- contiguous bytes to write per task  (e.g.: 8, 4k, 2m, 1g)"
328     # -o S  testFileName
329     # -t N  transferSize -- size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)"
330     # -w    writeFile -- write file"
331     # -r    readFile -- read existing file"
332     # -T    maxTimeDuration -- max time in minutes to run tests"
333     # -k    keepFile -- keep testFile(s) on program exit
334     local cmd="$IOR -a POSIX -b ${ior_blockSize}g -o $testdir/iorData -t 2m -v -w -r -T $ior_DURATION -k"
335
336     echo "+ $cmd"
337     mpi_run -np $((num_clients * $ior_THREADS)) -machinefile ${MACHINEFILE} $cmd
338
339     local rc=$?
340     if [ $rc != 0 ] ; then
341         error "ior failed! $rc"
342     fi
343     rm -rf $testdir
344 }
345 run_test ior "ior"
346
347 test_cascading_rw() {
348     if [ "$NFSCLIENT" ]; then
349         skip "skipped for NFSCLIENT mode"
350         return
351     fi
352
353     [ x$CASC_RW = x ] &&
354         { skip_env "cascading_rw not found" && return; }
355
356     local clients=$CLIENTS
357     [ -z $clients ] && clients=$(hostname)
358
359     num_clients=$(get_node_count ${clients//,/ })
360
361     # FIXME
362     # Need space estimation here.
363
364     generate_machine_file $clients $MACHINEFILE || return $?
365
366     print_opts CASC_RW clients casc_THREADS casc_REP MACHINEFILE
367
368     local testdir=$DIR/d0.cascading_rw
369     mkdir -p $testdir
370     # mpi_run uses mpiuser
371     chmod 0777 $testdir
372
373     # -g: debug mode
374     # -n: repeat test # times
375
376     local cmd="$CASC_RW -g -d $testdir -n $casc_REP"
377
378     echo "+ $cmd"
379     mpi_run -np $((num_clients * $casc_THREADS)) -machinefile ${MACHINEFILE} $cmd
380
381     local rc=$?
382     if [ $rc != 0 ] ; then
383         error "cascading_rw failed! $rc"
384     fi
385     rm -rf $testdir
386 }
387 run_test cascading_rw "cascading_rw"
388
389 test_write_append_truncate() {
390     if [ "$NFSCLIENT" ]; then
391         skip "skipped for NFSCLIENT mode"
392         return
393     fi
394
395     # location is lustre/tests dir
396     if ! which write_append_truncate > /dev/null 2>&1 ; then
397         skip_env "write_append_truncate not found"
398         return
399     fi
400
401     local clients=$CLIENTS
402     [ -z $clients ] && clients=$(hostname)
403
404     local num_clients=$(get_node_count ${clients//,/ })
405
406     # FIXME
407     # Need space estimation here.
408
409     generate_machine_file $clients $MACHINEFILE || return $?
410
411     local testdir=$DIR/d0.write_append_truncate
412     local file=$testdir/f0.wat
413
414     print_opts clients write_REP write_THREADS MACHINEFILE
415
416     mkdir -p $testdir
417     # mpi_run uses mpiuser
418     chmod 0777 $testdir
419
420     local cmd="write_append_truncate -n $write_REP $file"
421
422     echo "+ $cmd"
423     mpi_run -np $((num_clients * $write_THREADS)) -machinefile ${MACHINEFILE} $cmd
424
425     local rc=$?
426     if [ $rc != 0 ] ; then
427         error "write_append_truncate failed! $rc"
428         return $rc
429     fi
430     rm -rf $testdir
431 }
432 run_test write_append_truncate "write_append_truncate"
433
434 test_write_disjoint() {
435     if [ "$NFSCLIENT" ]; then
436         skip "skipped for NFSCLIENT mode"
437         return
438     fi
439
440     [ x$WRITE_DISJOINT = x ] &&
441         { skip_env "write_disjoint not found" && return; }
442
443     local clients=$CLIENTS
444     [ -z $clients ] && clients=$(hostname)
445
446     local num_clients=$(get_node_count ${clients//,/ })
447
448     # FIXME
449     # Need space estimation here.
450
451     generate_machine_file $clients $MACHINEFILE || return $?
452
453     print_opts WRITE_DISJOINT clients wdisjoint_THREADS wdisjoint_REP MACHINEFILE
454     local testdir=$DIR/d0.write_disjoint
455     mkdir -p $testdir
456     # mpi_run uses mpiuser
457     chmod 0777 $testdir
458
459     local cmd="$WRITE_DISJOINT -f $testdir/file -n $wdisjoint_REP"
460
461     echo "+ $cmd"
462     mpi_run -np $((num_clients * $wdisjoint_THREADS)) -machinefile ${MACHINEFILE} $cmd
463
464     local rc=$?
465     if [ $rc != 0 ] ; then
466         error "write_disjoint failed! $rc"
467     fi
468     rm -rf $testdir
469 }
470 run_test write_disjoint "write_disjoint"
471
472 test_parallel_grouplock() {
473     if [ "$NFSCLIENT" ]; then
474         skip "skipped for NFSCLIENT mode"
475         return
476     fi
477
478     [ x$PARALLEL_GROUPLOCK = x ] &&
479         { skip "PARALLEL_GROUPLOCK not found" && return; }
480
481     local clients=$CLIENTS
482     [ -z $clients ] && clients=$(hostname)
483
484     local num_clients=$(get_node_count ${clients//,/ })
485
486     generate_machine_file $clients $MACHINEFILE || return $?
487
488     print_opts clients parallel_grouplock_MINTASKS MACHINEFILE
489
490     local testdir=$DIR/d0.parallel_grouplock
491     mkdir -p $testdir
492     # mpi_run uses mpiuser
493     chmod 0777 $testdir
494
495     do_nodes $clients "lctl set_param llite.*.max_rw_chunk=0" ||
496         error "set_param max_rw_chunk=0 failed "
497
498     local cmd
499     local status=0
500     local subtest
501     for i in $(seq 12); do
502         subtest="-t $i"
503         local cmd="$PARALLEL_GROUPLOCK -g -v -d $testdir $subtest"
504         echo "+ $cmd"
505
506         mpi_run -np $parallel_grouplock_MINTASKS -machinefile ${MACHINEFILE} $cmd
507         local rc=$?
508         if [ $rc != 0 ] ; then
509             error_noexit "parallel_grouplock subtests $subtest failed! $rc"
510         else
511             echo "parallel_grouplock subtests $subtest PASS"
512         fi
513         let status=$((status + rc))
514         # clear debug to collect one log per one test
515         do_nodes $(comma_list $(nodes_list)) lctl clear
516      done
517     [ $status -eq 0 ] || error "parallel_grouplock status: $status"
518     rm -rf $testdir
519 }
520 run_test parallel_grouplock "parallel_grouplock"
521
522 statahead_NUMMNTPTS=${statahead_NUMMNTPTS:-5}
523 statahead_NUMFILES=${statahead_NUMFILES:-500000}
524
525 cleanup_statahead () {
526     trap 0
527
528     local clients=$1
529     local mntpt_root=$2
530     local num_mntpts=$3
531
532     for i in $(seq 0 $num_mntpts);do
533         zconf_umount_clients $clients ${mntpt_root}$i ||
534             error_exit "Failed to umount lustre on ${mntpt_root}$i"
535     done
536 }
537
538 test_statahead () {
539     if [ "$NFSCLIENT" ]; then
540         skip "skipped for NFSCLIENT mode"
541         return
542     fi
543
544     [ x$MDSRATE = x ] &&
545         { skip_env "mdsrate not found" && return; }
546
547     local clients=$CLIENTS
548     [ -z $clients ] && clients=$(hostname)
549
550     local num_clients=$(get_node_count ${clients//,/ })
551
552     generate_machine_file $clients $MACHINEFILE || return $?
553
554     print_opts MDSRATE clients statahead_NUMMNTPTS statahead_NUMFILES
555
556     # create large dir
557
558     # do not use default "d[0-9]*" dir name
559     # to avoid of rm $statahead_NUMFILES (500k) files in t-f cleanup
560     local dir=dstatahead
561     local testdir=$DIR/$dir
562
563     # cleanup only if dir exists
564     # cleanup only $statahead_NUMFILES number of files
565     # ignore the other files created by someone else
566     [ -d $testdir ] &&
567         mdsrate_cleanup $((num_clients * 32)) $MACHINEFILE $statahead_NUMFILES $testdir 'f%%d' --ignore
568
569     mkdir -p $testdir
570     # mpi_run uses mpiuser
571     chmod 0777 $testdir
572
573     local num_files=$statahead_NUMFILES
574
575     local IFree=$(inodes_available)
576     if [ $IFree -lt $num_files ]; then
577       num_files=$IFree
578     fi
579
580     cancel_lru_locks mdc
581
582     local cmd="${MDSRATE} ${MDSRATE_DEBUG} --mknod --dir $testdir --nfiles $num_files --filefmt 'f%%d'"
583     echo "+ $cmd"
584
585     mpi_run -np $((num_clients * 32)) -machinefile ${MACHINEFILE} $cmd
586
587     local rc=$?
588     if [ $rc != 0 ] ; then
589         error "mdsrate failed to create $rc"
590         return $rc
591     fi
592
593     local num_mntpts=$statahead_NUMMNTPTS
594     local mntpt_root=$TMP/mntpt/lustre
595     local mntopts=${MNTOPTSTATAHEAD:-$MOUNTOPT}
596
597     echo "Mounting $num_mntpts lustre clients starts on $clients"
598     trap "cleanup_statahead $clients $mntpt_root $num_mntpts" EXIT ERR
599     for i in $(seq 0 $num_mntpts); do
600         zconf_mount_clients $clients ${mntpt_root}$i "$mntopts" ||
601             error_exit "Failed to mount lustre on ${mntpt_root}$i on $clients"
602     done
603
604     do_rpc_nodes $clients cancel_lru_locks mdc
605
606     do_rpc_nodes $clients do_ls $mntpt_root $num_mntpts $dir
607
608     mdsrate_cleanup $((num_clients * 32)) $MACHINEFILE $num_files $testdir 'f%%d' --ignore
609
610     # use rm instead of rmdir because of
611     # testdir could contain the files created by someone else,
612     # or by previous run where is num_files prev > num_files current
613     rm -rf $testdir
614     cleanup_statahead $clients $mntpt_root $num_mntpts
615 }
616
617 run_test statahead "statahead test, multiple clients"
618
619 complete $(basename $0) $SECONDS
620 check_and_cleanup_lustre
621 exit_status