Whamcloud - gitweb
LU-13404 utils: fix lfs mirror duplicate file check
[fs/lustre-release.git] / lustre / tests / mdsrate-lookup-10dirs.sh
1 #!/bin/bash
2 #
3 # This test was used in a set of CMD3 tests (cmd3-5 test).
4
5 # Directory lookup retrieval rate 10 directories 1 million files each
6 # 6000 random lookups/sec per client node 62,000 random lookups/sec aggregate
7 #
8 # In 10 dirs containing 1 million files each the mdsrate Test Program will
9 # perform lookups for 10 minutes. This test is run from a single node for
10 # #1 and from all nodes for #2 aggregate test to measure lookup performance.
11 # TEst performs lookups across all 10 directories.
12
13 LUSTRE=${LUSTRE:-`dirname $0`/..}
14 . $LUSTRE/tests/test-framework.sh
15 init_test_env $@
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 assert_env CLIENTS MDSRATE SINGLECLIENT MPIRUN
18
19 MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
20 # Do not use name [df][0-9]* to avoid cleanup by rm, bug 18045
21 BASEDIR=$MOUNT/mdsrate
22
23 # Requirements
24 NUM_DIRS=${NUM_DIRS:-10}
25 NUM_FILES=${NUM_FILES:-1000000}
26 TIME_PERIOD=${TIME_PERIOD:-600}                        # seconds
27
28 LOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
29 CLIENT=$SINGLECLIENT
30 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
31 NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
32
33 rm -f $LOG
34
35 [ ! -x ${MDSRATE} ] && error "${MDSRATE} not built."
36
37 log "===== $0 ====== "
38
39 check_and_setup_lustre
40
41 mkdir -p $BASEDIR
42 chmod 0777 $BASEDIR
43 mdsrate_STRIPEPARAMS=${mdsrate_STRIPEPARAMS:-${fs_STRIPEPARAMS:-"-c 1"}}
44 setstripe_getstripe $BASEDIR $mdsrate_STRIPEPARAMS
45
46 IFree=$(($(mdsrate_inodes_available) - NUM_DIRS))
47 if [ $IFree -lt $((NUM_FILES * NUM_DIRS)) ]; then
48     NUM_FILES=$((IFree / NUM_DIRS))
49 fi
50
51 generate_machine_file $NODES_TO_USE $MACHINEFILE || error "can not generate machinefile"
52
53 DIRfmt="${BASEDIR}/lookup-%d"
54
55 #
56 # Unlink the files created in the directories under $BASEDIR.
57 # FIXME: does it make sense to add the possibility to unlink dirfmt to mdsrate?
58 #
59 mdsrate_cleanup_all() {
60         local i
61         for i in $(seq 0 $NUM_DIRS); do
62                 mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES \
63                                 $BASEDIR/lookup-$i 'f%%d' --ignore
64         done
65 }
66
67 if [ -n "$NOCREATE" ]; then
68     echo "NOCREATE=$NOCREATE  => no file creation."
69 else
70         mdsrate_cleanup_all
71
72     log "===== $0 Test preparation: creating ${NUM_DIRS} dirs with ${NUM_FILES} files."
73
74     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod
75                         --ndirs ${NUM_DIRS} --dirfmt '${DIRfmt}'
76                         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
77
78         echo "+" ${COMMAND}
79         # For files creation we can use -np equal to NUM_DIRS
80         # This is just a test preparation, does not matter how many threads we
81         # use for files creation; we just should be aware that NUM_DIRS is less
82         # than or equal to the number of threads np
83         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np ${NUM_DIRS} \
84                 ${COMMAND} 2>&1
85
86         # No lookup if error occurs on file creation, abort.
87         if [ ${PIPESTATUS[0]} != 0 ]; then
88                 error_noexit "mdsrate file creation failed, aborting"
89                 mdsrate_cleanup_all
90                 exit 1
91         fi
92 fi
93
94 COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --lookup --time ${TIME_PERIOD} ${SEED_OPTION}
95         --ndirs ${NUM_DIRS} --dirfmt '${DIRfmt}'
96         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
97
98 # 1
99 if [ -n "$NOSINGLE" ]; then
100     echo "NO Test for lookups on a single client."
101 else
102         log "===== $0 ### 1 NODE LOOKUPS ###"
103         echo "+" ${COMMAND}
104         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np 1 ${COMMAND} |
105                 tee ${LOG}
106
107         if [ ${PIPESTATUS[0]} != 0 ]; then
108                 [ -f $LOG ] && sed -e "s/^/log: /" $LOG
109                 error_noexit "mdsrate lookup on single client failed, aborting"
110                 mdsrate_cleanup_all
111                 exit 1
112         fi
113 fi
114
115 # 2
116 [ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
117 if [ -n "$NOMULTI" ]; then
118     echo "NO test for lookups on multiple nodes."
119 else
120         log "===== $0 ### ${NUM_CLIENTS} NODES LOOKUPS ###"
121         echo "+" ${COMMAND}
122         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np ${NUM_CLIENTS} \
123                 ${COMMAND} | tee ${LOG}
124
125         if [ ${PIPESTATUS[0]} != 0 ]; then
126                 [ -f $LOG ] && sed -e "s/^/log: /" $LOG
127                 error_noexit "mdsrate lookup on multiple nodes failed, aborting"
128                 mdsrate_cleanup_all
129                 exit 1
130         fi
131 fi
132
133 complete $SECONDS
134 mdsrate_cleanup_all
135 rmdir $BASEDIR || true
136 rm -f $MACHINEFILE
137 check_and_cleanup_lustre
138 #rm -f $LOG
139
140 exit 0