Whamcloud - gitweb
b=18551 cleanup lnet_selftest module after test
[fs/lustre-release.git] / lustre / tests / mdsrate-stat-small.sh
1 #!/bin/bash
2 #
3 # This test was used in a set of CMD3 tests (cmd3-7 test).
4
5 # File attribute retrieval rate for small file creation
6 # 3200 ops/sec for single node 29,000 ops/sec aggregate
7
8 # In a dir containing 10 million non-striped files, the mdsrate Test Program
9 # will perform directory ordered stat's (readdir) for 10 minutes. This test
10 # will be run from a single node for #1 and from all nodes for #2
11 # aggregate test to measure stat performance.
12
13 LUSTRE=${LUSTRE:-`dirname $0`/..}
14 . $LUSTRE/tests/test-framework.sh
15 init_test_env $@
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17
18 assert_env CLIENTS MDSRATE SINGLECLIENT MPIRUN
19
20 MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
21 # Do not use name [df][0-9]* to avoid cleanup by rm, bug 18045
22 BASEDIR=$MOUNT/mdsrate
23 TESTDIR=$BASEDIR/stat
24
25 # Requirements
26 NUM_FILES=${NUM_FILES:-1000000}
27 TIME_PERIOD=${TIME_PERIOD:-600}                        # seconds
28
29 LOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
30 CLIENT=$SINGLECLIENT
31 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
32 NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
33
34 rm -f $LOG
35
36 [ ! -x ${MDSRATE} ] && error "${MDSRATE} not built."
37
38 log "===== $0 ====== " 
39
40 check_and_setup_lustre
41
42 mkdir -p $BASEDIR
43 chmod 0777 $BASEDIR
44 $LFS setstripe $BASEDIR -i 0 -c 1
45 get_stripe $BASEDIR
46
47 IFree=$(mdsrate_inodes_available)
48 if [ $IFree -lt $NUM_FILES ]; then
49     NUM_FILES=$IFree
50 fi
51
52 generate_machine_file $NODES_TO_USE $MACHINEFILE || error "can not generate machinefile"
53
54 if [ -n "$NOCREATE" ]; then
55     echo "NOCREATE=$NOCREATE  => no file creation."
56 else
57     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d' --ignore
58
59     log "===== $0 Test preparation: creating ${NUM_FILES} files."
60
61     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod --dir ${TESTDIR}
62                         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
63     echo "+" ${COMMAND}
64
65     NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
66     NUM_THREADS=$((NUM_CLIENTS * MDSCOUNT))
67     if [ $NUM_CLIENTS -gt 50 ]; then
68         NUM_THREADS=$NUM_CLIENTS
69     fi
70
71     mpi_run -np ${NUM_THREADS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1
72     [ ${PIPESTATUS[0]} != 0 ] && error "mdsrate file creation failed, aborting"
73
74 fi
75
76 COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --stat --time ${TIME_PERIOD}
77         --dir ${TESTDIR} --nfiles ${NUM_FILES} --filefmt 'f%%d'"
78
79 # 1
80 if [ -n "$NOSINGLE" ]; then
81     echo "NO Test for stats on a single client."
82 else
83     log "===== $0 ### 1 NODE STAT ###"
84     echo "+" ${COMMAND}
85
86     mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
87     
88     if [ ${PIPESTATUS[0]} != 0 ]; then
89         [ -f $LOG ] && sed -e "s/^/log: /" $LOG
90         error "mdsrate on a single client failed, aborting"
91     fi
92 fi
93
94 # 2
95 [ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
96 if [ -n "$NOMULTI" ]; then
97     echo "NO test for stats on multiple nodes."
98 else
99     log "===== $0 ### ${NUM_CLIENTS} NODES STAT ###"
100     echo "+" ${COMMAND}
101
102     mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
103
104     if [ ${PIPESTATUS[0]} != 0 ]; then
105         [ -f $LOG ] && sed -e "s/^/log: /" $LOG
106         error "mdsrate stats on multiple nodes failed, aborting"
107     fi
108 fi
109
110 equals_msg `basename $0`: test complete, cleaning up
111 mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d'
112 rmdir $BASEDIR || true
113 rm -f $MACHINEFILE
114 check_and_cleanup_lustre
115 #rm -f $LOG
116
117 exit 0