Whamcloud - gitweb
b=21932 disable some tests on NFSCLIENT
[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 20670           21255 
12 ALWAYS_EXCEPT="parallel_grouplock  statahead $PARALLEL_SCALE_EXCEPT"
13
14 #
15 # compilbench
16 #
17 cbench_DIR=${cbench_DIR:-""}
18 cbench_IDIRS=${cbench_IDIRS:-4}
19 cbench_RUNS=${cbench_RUNS:-4}   # 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 get_mpiuser_id $MPI_USER
99 MPI_RUNAS=${MPI_RUNAS:-"runas -u $MPI_USER_UID -g $MPI_USER_GID"}
100 $GSS_KRB5 && refresh_krb5_tgt $MPI_USER_UID $MPI_USER_GID $MPI_RUNAS
101
102 print_opts () {
103     local var
104
105     echo OPTIONS:
106
107     for i in $@; do
108         var=$i
109         echo "${var}=${!var}"
110     done
111     [ -e $MACHINEFILE ] && cat $MACHINEFILE
112 }
113
114 # Takes:
115 # 5 min * cbench_RUNS
116 #        SLOW=no     10 mins
117 #        SLOW=yes    50 mins
118 # Space estimation:
119 #        compile dir kernel-1 680MB
120 #        required space       680MB * cbench_IDIRS = ~7 Gb
121
122 test_compilebench() {
123     print_opts cbench_DIR cbench_IDIRS cbench_RUNS
124
125     [ x$cbench_DIR = x ] &&
126         { skip_env "compilebench not found" && return; }
127
128     [ -e $cbench_DIR/compilebench ] || \
129         { skip_env "No compilebench build" && return; }
130
131     local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
132     if [ $space -le $((680 * 1024 * cbench_IDIRS)) ]; then
133         cbench_IDIRS=$(( space / 680 / 1024))
134         [ $cbench_IDIRS = 0 ] && \
135             skip_env "Need free space atleast 680 Mb, have $space" && return
136
137         log free space=$space, reducing initial dirs to $cbench_IDIRS
138     fi
139     # FIXME:
140     # t-f _base needs to be modifyed to set properly tdir
141     # for new "test_foo" functions names
142     # local testdir=$DIR/$tdir
143     local testdir=$DIR/d0.compilebench
144     mkdir -p $testdir
145
146     local savePWD=$PWD
147     cd $cbench_DIR 
148     local cmd="./compilebench -D $testdir -i $cbench_IDIRS -r $cbench_RUNS --makej"
149
150     log "$cmd"
151
152     local rc=0
153     eval $cmd
154     rc=$?
155         
156     cd $savePWD
157     [ $rc = 0 ] || error "compilebench failed: $rc"
158     rm -rf $testdir
159 }
160 run_test compilebench "compilebench"
161
162 test_metabench() {
163     [ x$METABENCH = x ] &&
164         { skip_env "metabench not found" && return; }
165
166     local clients=$CLIENTS
167     [ -z $clients ] && clients=$(hostname)
168
169     num_clients=$(get_node_count ${clients//,/ })
170
171     # FIXME
172     # Need space estimation here.
173
174     generate_machine_file $clients $MACHINEFILE || \
175         error "can not generate machinefile $MACHINEFILE"
176
177     print_opts METABENCH clients mbench_NFILES mbench_THREADS
178
179     local testdir=$DIR/d0.metabench
180     mkdir -p $testdir
181     # mpi_run uses mpiuser
182     chmod 0777 $testdir
183
184     # -C             Run the file creation tests.
185     # -S             Run the file stat tests.
186     # -c nfile       Number of files to be used in each test.
187     # -k             Cleanup.  Remove the test directories.
188     local cmd="$METABENCH -w $testdir -c $mbench_NFILES -C -S -k"
189     echo "+ $cmd"
190     mpi_run -np $((num_clients * $mbench_THREADS)) -machinefile ${MACHINEFILE} $cmd
191     local rc=$?
192     if [ $rc != 0 ] ; then
193         error "metabench failed! $rc"
194     fi
195     rm -rf $testdir
196 }
197 run_test metabench "metabench"
198
199 test_simul() {
200     if [ "$NFSCLIENT" ]; then
201         skip "skipped for NFSCLIENT mode"
202         return
203     fi
204
205     [ x$SIMUL = x ] &&
206         { skip_env "simul not found" && return; }
207
208     local clients=$CLIENTS
209     [ -z $clients ] && clients=$(hostname)
210
211     local num_clients=$(get_node_count ${clients//,/ })
212
213     # FIXME
214     # Need space estimation here.
215
216     generate_machine_file $clients $MACHINEFILE || \
217         error "can not generate machinefile $MACHINEFILE"
218
219     print_opts SIMUL clients simul_REP simul_THREADS
220
221     local testdir=$DIR/d0.simul
222     mkdir -p $testdir
223     # mpi_run uses mpiuser
224     chmod 0777 $testdir
225
226     # -n # : repeat each test # times
227     # -N # : repeat the entire set of tests # times
228
229     local cmd="$SIMUL -d $testdir -n $simul_REP -N $simul_REP"
230
231     echo "+ $cmd"
232     mpi_run -np $((num_clients * $simul_THREADS)) -machinefile ${MACHINEFILE} $cmd
233
234     local rc=$?
235     if [ $rc != 0 ] ; then
236         error "simul failed! $rc"
237     fi
238     rm -rf $testdir
239 }
240 run_test simul "simul"
241
242 test_connectathon() {
243     print_opts cnt_DIR cnt_NRUN
244
245     [ x$cnt_DIR = x ] &&
246         { skip_env "connectathon dir not found" && return; }
247
248     [ -e $cnt_DIR/runtests ] || \
249         { skip_env "No connectathon runtests found" && return; }
250
251     local testdir=$DIR/d0.connectathon
252     mkdir -p $testdir
253
254     local savePWD=$PWD
255     cd $cnt_DIR
256
257     # -f      a quick functionality test
258     # -a      run basic, general, special, and lock tests
259     # -N numpasses - will be passed to the runtests script.  This argument
260     #         is optional.  It specifies the number of times to run
261     #         through the tests.
262
263     local cmd="./runtests -N $cnt_NRUN -a -f $testdir"
264
265     log "$cmd"
266
267     local rc=0
268     eval $cmd
269     rc=$?
270
271     cd $savePWD
272     [ $rc = 0 ] || error "connectathon failed: $rc"
273     rm -rf $testdir
274 }
275 run_test connectathon "connectathon"
276
277 test_ior() {
278     [ x$IOR = x ] &&
279         { skip_env "IOR not found" && return; }
280
281     local clients=$CLIENTS
282     [ -z $clients ] && clients=$(hostname)
283
284     local num_clients=$(get_node_count ${clients//,/ })
285
286     local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
287     echo "+ $ior_blockSize * 1024 * 1024 * $num_clients * $ior_THREADS "
288     if [ $((space / 2)) -le $(( ior_blockSize * 1024 * 1024 * num_clients * ior_THREADS)) ]; then
289         echo "+ $space * 9/10 / 1024 / 1024 / $num_clients / $ior_THREADS"
290         ior_blockSize=$(( space /2 /1024 /1024 / num_clients / ior_THREADS ))
291         [ $ior_blockSize = 0 ] && \
292             skip_env "Need free space more than ($num_clients * $ior_THREADS )Gb: $((num_clients*ior_THREADS *1024 *1024*2)), have $space" && return
293
294         echo "free space=$space, Need: $num_clients x $ior_THREADS x $ior_blockSize Gb (blockSize reduced to $ior_blockSize Gb)"
295     fi
296  
297     generate_machine_file $clients $MACHINEFILE || \
298         error "can not generate machinefile $MACHINEFILE"
299
300     print_opts IOR ior_THREADS ior_DURATION MACHINEFILE
301
302     local testdir=$DIR/d0.ior
303     mkdir -p $testdir
304     # mpi_run uses mpiuser
305     chmod 0777 $testdir
306     if [ "$NFSCLIENT" ]; then
307         setstripe_nfsserver $testdir -c -1 || 
308             { error "setstripe on nfsserver failed" && return 1; } 
309     else
310         $LFS setstripe $testdir -c -1 ||
311             { error "setstripe failed" && return 2; }
312     fi
313     # 
314     # -b N  blockSize -- contiguous bytes to write per task  (e.g.: 8, 4k, 2m, 1g)"
315     # -o S  testFileName
316     # -t N  transferSize -- size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)"
317     # -w    writeFile -- write file"
318     # -r    readFile -- read existing file"
319     # -T    maxTimeDuration -- max time in minutes to run tests"
320     # -k    keepFile -- keep testFile(s) on program exit
321     local cmd="$IOR -a POSIX -b ${ior_blockSize}g -o $testdir/iorData -t 2m -v -w -r -T $ior_DURATION -k"
322
323     echo "+ $cmd"
324     mpi_run -np $((num_clients * $ior_THREADS)) -machinefile ${MACHINEFILE} $cmd
325
326     local rc=$?
327     if [ $rc != 0 ] ; then
328         error "ior failed! $rc"
329     fi
330     rm -rf $testdir
331 }
332 run_test ior "ior"
333  
334 test_cascading_rw() {
335     if [ "$NFSCLIENT" ]; then
336         skip "skipped for NFSCLIENT mode"
337         return
338     fi
339
340     [ x$CASC_RW = x ] &&
341         { skip_env "cascading_rw not found" && return; }
342
343     local clients=$CLIENTS
344     [ -z $clients ] && clients=$(hostname)
345
346     num_clients=$(get_node_count ${clients//,/ })
347
348     # FIXME
349     # Need space estimation here.
350
351     generate_machine_file $clients $MACHINEFILE || \
352         error "can not generate machinefile $MACHINEFILE"
353
354     print_opts CASC_RW clients casc_THREADS casc_REP MACHINEFILE
355
356     local testdir=$DIR/d0.cascading_rw
357     mkdir -p $testdir
358     # mpi_run uses mpiuser
359     chmod 0777 $testdir
360
361     # -g: debug mode 
362     # -n: repeat test # times
363
364     local cmd="$CASC_RW -g -d $testdir -n $casc_REP"
365
366     echo "+ $cmd"
367     mpi_run -np $((num_clients * $casc_THREADS)) -machinefile ${MACHINEFILE} $cmd
368
369     local rc=$?
370     if [ $rc != 0 ] ; then
371         error "cascading_rw failed! $rc"
372     fi
373     rm -rf $testdir
374 }
375 run_test cascading_rw "cascading_rw"
376
377 test_write_append_truncate() {
378     if [ "$NFSCLIENT" ]; then
379         skip "skipped for NFSCLIENT mode"
380         return
381     fi
382
383     # location is lustre/tests dir 
384     if ! which write_append_truncate > /dev/null 2>&1 ; then
385         skip_env "write_append_truncate not found"
386         return
387     fi
388
389     local clients=$CLIENTS
390     [ -z $clients ] && clients=$(hostname)
391
392     local num_clients=$(get_node_count ${clients//,/ })
393
394     # FIXME
395     # Need space estimation here.
396
397     generate_machine_file $clients $MACHINEFILE || \
398         error "can not generate machinefile $MACHINEFILE"
399
400     local testdir=$DIR/d0.write_append_truncate
401     local file=$testdir/f0.wat
402
403     print_opts clients write_REP write_THREADS MACHINEFILE
404
405     mkdir -p $testdir
406     # mpi_run uses mpiuser
407     chmod 0777 $testdir
408
409     local cmd="write_append_truncate -n $write_REP $file"
410
411     echo "+ $cmd"
412     mpi_run -np $((num_clients * $write_THREADS)) -machinefile ${MACHINEFILE} $cmd
413
414     local rc=$?
415     if [ $rc != 0 ] ; then
416         error "write_append_truncate failed! $rc"
417         return $rc
418     fi
419     rm -rf $testdir
420 }
421 run_test write_append_truncate "write_append_truncate"
422
423 test_write_disjoint() {
424     if [ "$NFSCLIENT" ]; then
425         skip "skipped for NFSCLIENT mode"
426         return
427     fi
428
429     [ x$WRITE_DISJOINT = x ] &&
430         { skip_env "write_disjoint not found" && return; }
431
432     local clients=$CLIENTS
433     [ -z $clients ] && clients=$(hostname)
434
435     local num_clients=$(get_node_count ${clients//,/ })
436
437     # FIXME
438     # Need space estimation here.
439
440     generate_machine_file $clients $MACHINEFILE || \
441         error "can not generate machinefile $MACHINEFILE"
442
443     print_opts WRITE_DISJOINT clients wdisjoint_THREADS wdisjoint_REP MACHINEFILE
444     local testdir=$DIR/d0.write_disjoint
445     mkdir -p $testdir
446     # mpi_run uses mpiuser
447     chmod 0777 $testdir
448
449     local cmd="$WRITE_DISJOINT -f $testdir/file -n $wdisjoint_REP"
450
451     echo "+ $cmd"
452     mpi_run -np $((num_clients * $wdisjoint_THREADS)) -machinefile ${MACHINEFILE} $cmd
453
454     local rc=$?
455     if [ $rc != 0 ] ; then
456         error "write_disjoint failed! $rc"
457     fi
458     rm -rf $testdir
459 }
460 run_test write_disjoint "write_disjoint"
461
462 test_parallel_grouplock() {
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