Whamcloud - gitweb
b=21829 fix broken llobdstat and add a counter parameter
[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 || \
170         error "can not generate machinefile $MACHINEFILE"
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 || \
212         error "can not generate machinefile $MACHINEFILE"
213
214     print_opts SIMUL clients simul_REP simul_THREADS
215
216     local testdir=$DIR/d0.simul
217     mkdir -p $testdir
218     # mpi_run uses mpiuser
219     chmod 0777 $testdir
220
221     # -n # : repeat each test # times
222     # -N # : repeat the entire set of tests # times
223
224     local cmd="$SIMUL -d $testdir -n $simul_REP -N $simul_REP"
225
226     echo "+ $cmd"
227     mpi_run -np $((num_clients * $simul_THREADS)) -machinefile ${MACHINEFILE} $cmd
228
229     local rc=$?
230     if [ $rc != 0 ] ; then
231         error "simul failed! $rc"
232     fi
233     rm -rf $testdir
234 }
235 run_test simul "simul"
236
237 test_connectathon() {
238     print_opts cnt_DIR cnt_NRUN
239
240     [ x$cnt_DIR = x ] &&
241         { skip_env "connectathon dir not found" && return; }
242
243     [ -e $cnt_DIR/runtests ] || \
244         { skip_env "No connectathon runtests found" && return; }
245
246     local testdir=$DIR/d0.connectathon
247     mkdir -p $testdir
248
249     local savePWD=$PWD
250     cd $cnt_DIR
251
252     # -f      a quick functionality test
253     # -a      run basic, general, special, and lock tests
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     local cmd="./runtests -N $cnt_NRUN -a -f $testdir"
259
260     log "$cmd"
261
262     local rc=0
263     eval $cmd
264     rc=$?
265
266     cd $savePWD
267     [ $rc = 0 ] || error "connectathon failed: $rc"
268     rm -rf $testdir
269 }
270 run_test connectathon "connectathon"
271
272 test_ior() {
273     [ x$IOR = x ] &&
274         { skip_env "IOR not found" && return; }
275
276     local clients=$CLIENTS
277     [ -z $clients ] && clients=$(hostname)
278
279     local num_clients=$(get_node_count ${clients//,/ })
280
281     local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
282     echo "+ $ior_blockSize * 1024 * 1024 * $num_clients * $ior_THREADS "
283     if [ $((space / 2)) -le $(( ior_blockSize * 1024 * 1024 * num_clients * ior_THREADS)) ]; then
284         echo "+ $space * 9/10 / 1024 / 1024 / $num_clients / $ior_THREADS"
285         ior_blockSize=$(( space /2 /1024 /1024 / num_clients / ior_THREADS ))
286         [ $ior_blockSize = 0 ] && \
287             skip_env "Need free space more than ($num_clients * $ior_THREADS )Gb: $((num_clients*ior_THREADS *1024 *1024*2)), have $space" && return
288
289         echo "free space=$space, Need: $num_clients x $ior_THREADS x $ior_blockSize Gb (blockSize reduced to $ior_blockSize Gb)"
290     fi
291  
292     generate_machine_file $clients $MACHINEFILE || \
293         error "can not generate machinefile $MACHINEFILE"
294
295     print_opts IOR ior_THREADS ior_DURATION MACHINEFILE
296
297     local testdir=$DIR/d0.ior
298     mkdir -p $testdir
299     # mpi_run uses mpiuser
300     chmod 0777 $testdir
301     if [ "$NFSCLIENT" ]; then
302         setstripe_nfsserver $testdir -c -1 || 
303             { error "setstripe on nfsserver failed" && return 1; } 
304     else
305         $LFS setstripe $testdir -c -1 ||
306             { error "setstripe failed" && return 2; }
307     fi
308     # 
309     # -b N  blockSize -- contiguous bytes to write per task  (e.g.: 8, 4k, 2m, 1g)"
310     # -o S  testFileName
311     # -t N  transferSize -- size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)"
312     # -w    writeFile -- write file"
313     # -r    readFile -- read existing file"
314     # -T    maxTimeDuration -- max time in minutes to run tests"
315     # -k    keepFile -- keep testFile(s) on program exit
316     local cmd="$IOR -a POSIX -b ${ior_blockSize}g -o $testdir/iorData -t 2m -v -w -r -T $ior_DURATION -k"
317
318     echo "+ $cmd"
319     mpi_run -np $((num_clients * $ior_THREADS)) -machinefile ${MACHINEFILE} $cmd
320
321     local rc=$?
322     if [ $rc != 0 ] ; then
323         error "ior failed! $rc"
324     fi
325     rm -rf $testdir
326 }
327 run_test ior "ior"
328  
329 test_cascading_rw() {
330     if [ "$NFSCLIENT" ]; then
331         skip "skipped for NFSCLIENT mode"
332         return
333     fi
334
335     [ x$CASC_RW = x ] &&
336         { skip_env "cascading_rw not found" && return; }
337
338     local clients=$CLIENTS
339     [ -z $clients ] && clients=$(hostname)
340
341     num_clients=$(get_node_count ${clients//,/ })
342
343     # FIXME
344     # Need space estimation here.
345
346     generate_machine_file $clients $MACHINEFILE || \
347         error "can not generate machinefile $MACHINEFILE"
348
349     print_opts CASC_RW clients casc_THREADS casc_REP MACHINEFILE
350
351     local testdir=$DIR/d0.cascading_rw
352     mkdir -p $testdir
353     # mpi_run uses mpiuser
354     chmod 0777 $testdir
355
356     # -g: debug mode 
357     # -n: repeat test # times
358
359     local cmd="$CASC_RW -g -d $testdir -n $casc_REP"
360
361     echo "+ $cmd"
362     mpi_run -np $((num_clients * $casc_THREADS)) -machinefile ${MACHINEFILE} $cmd
363
364     local rc=$?
365     if [ $rc != 0 ] ; then
366         error "cascading_rw failed! $rc"
367     fi
368     rm -rf $testdir
369 }
370 run_test cascading_rw "cascading_rw"
371
372 test_write_append_truncate() {
373     if [ "$NFSCLIENT" ]; then
374         skip "skipped for NFSCLIENT mode"
375         return
376     fi
377
378     # location is lustre/tests dir 
379     if ! which write_append_truncate > /dev/null 2>&1 ; then
380         skip_env "write_append_truncate not found"
381         return
382     fi
383
384     local clients=$CLIENTS
385     [ -z $clients ] && clients=$(hostname)
386
387     local num_clients=$(get_node_count ${clients//,/ })
388
389     # FIXME
390     # Need space estimation here.
391
392     generate_machine_file $clients $MACHINEFILE || \
393         error "can not generate machinefile $MACHINEFILE"
394
395     local testdir=$DIR/d0.write_append_truncate
396     local file=$testdir/f0.wat
397
398     print_opts clients write_REP write_THREADS MACHINEFILE
399
400     mkdir -p $testdir
401     # mpi_run uses mpiuser
402     chmod 0777 $testdir
403
404     local cmd="write_append_truncate -n $write_REP $file"
405
406     echo "+ $cmd"
407     mpi_run -np $((num_clients * $write_THREADS)) -machinefile ${MACHINEFILE} $cmd
408
409     local rc=$?
410     if [ $rc != 0 ] ; then
411         error "write_append_truncate failed! $rc"
412         return $rc
413     fi
414     rm -rf $testdir
415 }
416 run_test write_append_truncate "write_append_truncate"
417
418 test_write_disjoint() {
419     if [ "$NFSCLIENT" ]; then
420         skip "skipped for NFSCLIENT mode"
421         return
422     fi
423
424     [ x$WRITE_DISJOINT = x ] &&
425         { skip_env "write_disjoint not found" && return; }
426
427     local clients=$CLIENTS
428     [ -z $clients ] && clients=$(hostname)
429
430     local num_clients=$(get_node_count ${clients//,/ })
431
432     # FIXME
433     # Need space estimation here.
434
435     generate_machine_file $clients $MACHINEFILE || \
436         error "can not generate machinefile $MACHINEFILE"
437
438     print_opts WRITE_DISJOINT clients wdisjoint_THREADS wdisjoint_REP MACHINEFILE
439     local testdir=$DIR/d0.write_disjoint
440     mkdir -p $testdir
441     # mpi_run uses mpiuser
442     chmod 0777 $testdir
443
444     local cmd="$WRITE_DISJOINT -f $testdir/file -n $wdisjoint_REP"
445
446     echo "+ $cmd"
447     mpi_run -np $((num_clients * $wdisjoint_THREADS)) -machinefile ${MACHINEFILE} $cmd
448
449     local rc=$?
450     if [ $rc != 0 ] ; then
451         error "write_disjoint failed! $rc"
452     fi
453     rm -rf $testdir
454 }
455 run_test write_disjoint "write_disjoint"
456
457 test_parallel_grouplock() {
458     if [ "$NFSCLIENT" ]; then
459         skip "skipped for NFSCLIENT mode"
460         return
461     fi
462
463     [ x$PARALLEL_GROUPLOCK = x ] &&
464         { skip "PARALLEL_GROUPLOCK not found" && return; }
465
466     local clients=$CLIENTS
467     [ -z $clients ] && clients=$(hostname)
468
469     local num_clients=$(get_node_count ${clients//,/ })
470
471     generate_machine_file $clients $MACHINEFILE || \
472         error "can not generate machinefile $MACHINEFILE"
473
474     print_opts clients parallel_grouplock_MINTASKS MACHINEFILE
475
476     local testdir=$DIR/d0.parallel_grouplock
477     mkdir -p $testdir
478     # mpi_run uses mpiuser
479     chmod 0777 $testdir
480
481     do_nodes $clients "lctl set_param llite.*.max_rw_chunk=0" ||
482         error "set_param max_rw_chunk=0 failed "
483
484     local cmd
485     local status=0
486     local subtest
487     for i in $(seq 12); do
488         subtest="-t $i"
489         local cmd="$PARALLEL_GROUPLOCK -g -v -d $testdir $subtest"
490         echo "+ $cmd"
491
492         mpi_run -np $parallel_grouplock_MINTASKS -machinefile ${MACHINEFILE} $cmd
493         local rc=$?
494         if [ $rc != 0 ] ; then
495             error_noexit "parallel_grouplock subtests $subtest failed! $rc"
496         else
497             echo "parallel_grouplock subtests $subtest PASS"
498         fi
499         let status=$((status + rc))
500         # clear debug to collect one log per one test
501         do_nodes $(comma_list $(nodes_list)) lctl clear
502      done
503     [ $status -eq 0 ] || error "parallel_grouplock status: $status"
504     rm -rf $testdir
505 }
506 run_test parallel_grouplock "parallel_grouplock"
507
508 statahead_NUMMNTPTS=${statahead_NUMMNTPTS:-5}
509 statahead_NUMFILES=${statahead_NUMFILES:-500000}
510
511 cleanup_statahead () {
512     trap 0
513
514     local clients=$1
515     local mntpt_root=$2
516     local num_mntpts=$3
517
518     for i in $(seq 0 $num_mntpts);do
519         zconf_umount_clients $clients ${mntpt_root}$i ||
520             error_exit "Failed to umount lustre on ${mntpt_root}$i"
521     done
522 }
523
524 test_statahead () {
525    
526     # create large dir
527
528     local dir=d0.statahead
529     # FIXME has to use DIR
530     local testdir=$DIR/$dir
531
532     mkdir -p $testdir
533
534     local num_files=$statahead_NUMFILES
535
536     local IFree=$(inodes_available)
537     if [ $IFree -lt $num_files ]; then
538       num_files=$IFree
539     fi
540
541     cancel_lru_locks mdc
542
543     log "createmany -o $testdir/f-%d $num_files"
544     createmany -o $testdir/$f-%d $num_files
545
546     local rc=$?
547     if [ $rc != 0 ] ; then
548         error "createmany failed to create $rc"
549         return $rc
550     fi
551
552     local num_mntpts=$statahead_NUMMNTPTS
553     local mntpt_root=$TMP/mntpt/lustre
554     mntopts=${MNTOPTSTATAHEAD:-$MOUNTOPT}
555
556     local clients=$CLIENTS
557     [ -z $clients ] && clients=$(hostname)
558
559     echo "Mounting $num_mntpts lustre clients starts on $clients"
560     trap "cleanup_statahead $clients $mntpt_root $num_mntpts" EXIT ERR
561     for i in $(seq 0 $num_mntpts);do
562         zconf_mount_clients $clients ${mntpt_root}$i $mntopts ||
563             error_exit "Failed to mount lustre on ${mntpt_root}$i on $clients"
564     done
565
566     do_rpc_nodes $clients cancel_lru_locks mdc
567
568     do_rpc_nodes $clients do_ls $mntpt_root $num_mntpts $dir
569
570     cleanup_statahead $clients $mntpt_root $num_mntpts
571 }
572
573 run_test statahead "statahead test, multiple clients"
574
575 equals_msg `basename $0`: test complete, cleaning up
576 check_and_cleanup_lustre
577 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true