Whamcloud - gitweb
LU-15210 tests: fix sanity-lnet to handle duplicate IP
[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
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
22 # Requirements
23 NUM_DIRS=${NUM_DIRS:-10}
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:-"-c 1"}}
52 setstripe_getstripe $BASEDIR $mdsrate_STRIPEPARAMS
53
54 IFree=$(($(mdsrate_inodes_available) - NUM_DIRS))
55 if [ $IFree -lt $((NUM_FILES * NUM_DIRS)) ]; then
56     NUM_FILES=$((IFree / NUM_DIRS))
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 DIRfmt="${BASEDIR}/lookup-%d"
68
69 #
70 # Unlink the files created in the directories under $BASEDIR.
71 # FIXME: does it make sense to add the possibility to unlink dirfmt to mdsrate?
72 #
73 mdsrate_cleanup_all() {
74         local i
75         for i in $(seq 0 $NUM_DIRS); do
76                 mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES \
77                                 $BASEDIR/lookup-$i 'f%%d' --ignore
78         done
79 }
80
81 if [ -n "$NOCREATE" ]; then
82     echo "NOCREATE=$NOCREATE  => no file creation."
83 else
84         mdsrate_cleanup_all
85
86     log "===== $0 Test preparation: creating ${NUM_DIRS} dirs with ${NUM_FILES} files."
87
88         COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod
89                 --ndirs ${NUM_DIRS} --dirfmt '${DIRfmt}'
90                 --nfiles ${NUM_FILES} --filefmt 'f%%d'
91                 $mdtcount_opt $debug_opt"
92
93         echo "+" ${COMMAND}
94         # For files creation we can use -np equal to NUM_DIRS
95         # This is just a test preparation, does not matter how many threads we
96         # use for files creation; we just should be aware that NUM_DIRS is less
97         # than or equal to the number of threads np
98         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np ${NUM_DIRS} \
99                 ${COMMAND} 2>&1
100
101         # No lookup if error occurs on file creation, abort.
102         if [ ${PIPESTATUS[0]} != 0 ]; then
103                 error_noexit "mdsrate file creation failed, aborting"
104                 restore_lustre_params < $p
105                 mdsrate_cleanup_all
106                 exit 1
107         fi
108 fi
109
110 COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --lookup --time ${TIME_PERIOD} ${SEED_OPTION}
111         --ndirs ${NUM_DIRS} --dirfmt '${DIRfmt}'
112         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
113
114 # 1
115 if [ -n "$NOSINGLE" ]; then
116     echo "NO Test for lookups on a single client."
117 else
118         log "===== $0 ### 1 NODE LOOKUPS ###"
119         echo "+" ${COMMAND}
120         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np 1 ${COMMAND} |
121                 tee ${LOG}
122
123         if [ ${PIPESTATUS[0]} != 0 ]; then
124                 [ -f $LOG ] && sed -e "s/^/log: /" $LOG
125                 error_noexit "mdsrate lookup on single client failed, aborting"
126                 restore_lustre_params < $p
127                 mdsrate_cleanup_all
128                 exit 1
129         fi
130 fi
131
132 # 2
133 [ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
134 if [ -n "$NOMULTI" ]; then
135     echo "NO test for lookups on multiple nodes."
136 else
137         log "===== $0 ### ${NUM_CLIENTS} NODES LOOKUPS ###"
138         echo "+" ${COMMAND}
139         mpi_run ${MACHINEFILE_OPTION} ${MACHINEFILE} -np ${NUM_CLIENTS} \
140                 ${COMMAND} | tee ${LOG}
141
142         if [ ${PIPESTATUS[0]} != 0 ]; then
143                 [ -f $LOG ] && sed -e "s/^/log: /" $LOG
144                 error_noexit "mdsrate lookup on multiple nodes failed, aborting"
145                 restore_lustre_params < $p
146                 mdsrate_cleanup_all
147                 exit 1
148         fi
149 fi
150
151 complete $SECONDS
152 restore_lustre_params < $p
153 mdsrate_cleanup_all
154 rmdir $BASEDIR || true
155 rm -f $MACHINEFILE
156 check_and_cleanup_lustre
157 #rm -f $LOG
158
159 exit 0