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