Whamcloud - gitweb
LU-15152 tests: auster reports wrong testsuite status
[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
17 assert_env CLIENTS MDSRATE SINGLECLIENT MPIRUN
18
19 # Do not use name [df][0-9]* to avoid cleanup by rm, bug 18045
20 BASEDIR=$MOUNT/mdsrate
21 TESTDIR=$BASEDIR/stat
22
23 # Requirements
24 NUM_FILES=${NUM_FILES:-1000000}
25 TIME_PERIOD=${TIME_PERIOD:-600}                        # seconds
26
27 LOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
28 CLIENT=$SINGLECLIENT
29 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
30 NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
31
32 rm -f $LOG
33
34 [ ! -x ${MDSRATE} ] && error "${MDSRATE} not built."
35
36 log "===== $0 ====== "
37
38 check_and_setup_lustre
39
40 MDSRATE_ENABLE_DNE=${MDSRATE_ENABLE_DNE:-false}
41 if $MDSRATE_ENABLE_DNE; then
42         test_mkdir $BASEDIR
43         mdtcount_opt="--mdtcount $MDSCOUNT"
44 else
45         mkdir $BASEDIR
46 fi
47 if $VERBOSE; then
48         debug_opt="--debug"
49 fi
50 chmod 0777 $BASEDIR
51 mdsrate_STRIPEPARAMS=${mdsrate_STRIPEPARAMS:-${fs_STRIPEPARAMS:-"-i 0 -c 1"}}
52 setstripe_getstripe $BASEDIR $mdsrate_STRIPEPARAMS
53
54 IFree=$(mdsrate_inodes_available)
55 if [ $IFree -lt $NUM_FILES ]; then
56     NUM_FILES=$IFree
57 fi
58
59 generate_machine_file $NODES_TO_USE $MACHINEFILE ||
60         error "can not generate machinefile"
61
62 p="$TMP/$TESTSUITE-$TESTNAME.parameters"
63 save_lustre_params $(get_facets MDS) mdt.*.enable_remote_dir_gid > $p
64 do_nodes $(comma_list $(mdts_nodes)) \
65         $LCTL set_param mdt.*.enable_remote_dir_gid=-1
66
67 if [ -n "$NOCREATE" ]; then
68     echo "NOCREATE=$NOCREATE  => no file creation."
69 else
70     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d' --ignore
71
72     log "===== $0 Test preparation: creating ${NUM_FILES} files."
73
74         COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod --dir ${TESTDIR}
75                 --nfiles ${NUM_FILES} --filefmt 'f%%d'
76                 $mdtcount_opt $debug_opt"
77         echo "+" ${COMMAND}
78
79     NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
80     NUM_THREADS=$((NUM_CLIENTS * MDSCOUNT))
81     if [ $NUM_CLIENTS -gt 50 ]; then
82         NUM_THREADS=$NUM_CLIENTS
83     fi
84
85         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np ${NUM_THREADS} \
86                 ${COMMAND} 2>&1
87
88         if [ ${PIPESTATUS[0]} != 0 ]; then
89                 error_noexit "mdsrate file creation failed, aborting"
90                 restore_lustre_params < $p
91                 mdsrate_cleanup $NUM_THREADS $MACHINEFILE $NUM_FILES \
92                                 $TESTDIR 'f%%d' --ignore
93                 exit 1
94         fi
95 fi
96
97 COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --stat --time ${TIME_PERIOD}
98         --dir ${TESTDIR} --nfiles ${NUM_FILES} --filefmt 'f%%d'"
99
100 # 1
101 if [ -n "$NOSINGLE" ]; then
102     echo "NO Test for stats on a single client."
103 else
104     log "===== $0 ### 1 NODE STAT ###"
105     echo "+" ${COMMAND}
106
107         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np 1 ${COMMAND} |
108                 tee ${LOG}
109
110         if [ ${PIPESTATUS[0]} != 0 ]; then
111                 [ -f $LOG ] && sed -e "s/^/log: /" $LOG
112                 error_noexit "mdsrate stat on single client failed, aborting"
113                 restore_lustre_params < $p
114                 mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES \
115                                 $TESTDIR 'f%%d' --ignore
116                 exit 1
117         fi
118 fi
119
120 # 2
121 [ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
122 if [ -n "$NOMULTI" ]; then
123     echo "NO test for stats on multiple nodes."
124 else
125     log "===== $0 ### ${NUM_CLIENTS} NODES STAT ###"
126     echo "+" ${COMMAND}
127
128         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np ${NUM_CLIENTS} \
129                 ${COMMAND} | tee ${LOG}
130
131         if [ ${PIPESTATUS[0]} != 0 ]; then
132                 [ -f $LOG ] && sed -e "s/^/log: /" $LOG
133                 error_noexit "mdsrate stat on multiple nodes failed, aborting"
134                 restore_lustre_params < $p
135                 mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES \
136                                 $TESTDIR 'f%%d' --ignore
137                 exit 1
138         fi
139 fi
140
141 complete $SECONDS
142 restore_lustre_params < $p
143 mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d'
144 rmdir $BASEDIR || true
145 rm -f $MACHINEFILE
146 check_and_cleanup_lustre
147 #rm -f $LOG
148
149 exit 0