Whamcloud - gitweb
b=18801
[fs/lustre-release.git] / lustre / tests / large-scale.sh
1 #!/bin/bash
2
3 set -e
4
5 # bug number:
6 ALWAYS_EXCEPT="$LARGE_SCALE_EXCEPT"
7
8 SAVE_PWD=$PWD
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 SETUP=${SETUP:-""}
12 CLEANUP=${CLEANUP:-""}
13 . $LUSTRE/tests/test-framework.sh
14
15 init_test_env $@
16
17 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18
19 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
20
21 [ -n "$CLIENTS" ] || { skip "$0: Need two or more clients" && exit 0; }
22 [ $CLIENTCOUNT -ge 2 ] || \
23     { skip "$0: Need two or more clients, have $CLIENTCOUNT" && exit 0; }
24
25 #
26 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
27
28 MOUNT_2=""
29 build_test_filter
30
31 check_and_setup_lustre
32 rm -rf $DIR/[df][0-9]*
33
34 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
35
36 # VBR scale tests
37 check_vbr () {
38     do_nodes $CLIENTS "$LCTL get_param mdc.*.connect_flags | grep version_recovery" 
39 }
40
41 check_vbr || \
42     { skip "$0: no version_recovery" && exit 0; }
43
44 FAKE_NUM_MAX=${FAKE_NUM_MAX:-1000}
45 [ "$SLOW" = "no" ] && FAKE_NUM_MAX=100
46
47 do_and_time () {
48    local cmd=$1
49
50    local start_ts=`date +%s`
51
52    $cmd
53
54    local current_ts=`date +%s`
55    ELAPSED=`expr $current_ts - $start_ts`
56    echo "===== START $start_ts CURRENT $current_ts"
57 }
58
59 delete_fake_exports () {
60     NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
61
62     OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
63     NEW_AGE=0
64     do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
65     sleep $((NEW_AGE + 3))
66     EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
67     [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
68
69     do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
70     do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
71 }
72
73 test_1b() {
74     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
75
76     local FAKE_NUM
77     local NUM
78
79     for FAKE_NUM in 10 $FAKE_NUM_MAX; do
80         zconf_umount_clients $CLIENTS $DIR
81         zconf_mount $CLIENT1 $DIR
82
83         NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
84
85         log "===== CREATE FAKE EXPORTS: $FAKE_NUM ( were $NUM )"
86         create_fake_exports mds $FAKE_NUM
87         NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
88         [ $NUM -lt $FAKE_NUM ] && error "fake exports $NUM -ne $FAKE_NUM"
89         echo "===== STALE EXPORTS: FAKE_NUM=$FAKE_NUM NUM=$NUM"
90         do_and_time "zconf_mount_clients $CLIENTS $DIR"
91         echo "==== $TESTNAME ===== CONNECTION TIME $ELAPSED: FAKE_NUM=$FAKE_NUM CLIENTCOUNT=$CLIENTCOUNT"
92
93         # do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
94         delete_fake_exports
95     done
96
97     return 0
98 }
99 run_test 1b "VBR: connect $CLIENTCOUNT clients with delayed exports"
100
101 # Sigh. One more function for mds failover
102 # fail fn does not do df on all clients
103 fail_mds () {
104     facet_failover mds
105     client_df
106 }
107
108 test_1c() {
109     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
110
111     zconf_mount_clients $CLIENTS $DIR
112
113     # sanity mds fail (to exclude the recults on fresh formatted fs)
114     facet_failover mds
115
116     local current_ts
117     local elapsed
118     local FAKE_NUM
119     local NUM
120
121     for FAKE_NUM in 10 $FAKE_NUM_MAX; do
122
123         NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
124
125         log "===== CREATE FAKE EXPORTS: $FAKE_NUM ( were $NUM )"
126         create_fake_exports mds $FAKE_NUM
127         NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
128         [ $NUM -lt $FAKE_NUM ] && error "fake exports $NUM -ne $FAKE_NUM"
129         echo "===== STALE EXPORTS: FAKE_NUM=$FAKE_NUM NUM=$NUM"
130
131         replay_barrier mds
132         do_nodes $CLIENTS "createmany -o $DIR/$tfile-\\\$(hostname)" 25
133         # XXX For FAILURE_MODE=HARD it is better to exclude
134         # shutdown_facet and reboot_facet time 
135         fail_mds
136
137         local current_ts=`date +%s`
138         local elapsed=`expr $current_ts - $RECOVERY_START_TIME`
139
140         do_nodes $CLIENTS "unlinkmany $DIR/$tfile-\\\$(hostname) 25"
141         echo "==== $TESTNAME ===== RECOVERY TIME $elapsed: FAKE_NUM=$FAKE_NUM CLIENTCOUNT=$CLIENTCOUNT"
142
143         # do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
144         delete_fake_exports
145     done
146
147     return 0
148 }
149 run_test 1c "VBR: recovery $CLIENTCOUNT clients with delayed exports"
150
151 test_1d() {
152     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
153
154     local FAKE_NUM
155     local NUM
156
157     for FAKE_NUM in 10 $FAKE_NUM_MAX; do
158         zconf_umount_clients $CLIENTS $DIR
159         zconf_mount $CLIENT1 $DIR
160
161         NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
162
163         log "===== CREATE FAKE EXPORTS: $FAKE_NUM ( were $NUM )"
164         create_fake_exports mds $FAKE_NUM
165         NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
166         [ $NUM -lt $FAKE_NUM ] && error "fake exports $NUM -lt $FAKE_NUM"
167         echo "===== STALE EXPORTS: FAKE_NUM=$FAKE_NUM NUM=$NUM"
168
169         OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
170         echo OLD_AGE=$OLD_AGE
171         NEW_AGE=10
172         do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
173         sleep $((NEW_AGE + 3))
174         EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
175         [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
176
177         do_and_time "zconf_mount_clients $CLIENTS $DIR"
178         echo "==== $TESTNAME===== CONNECTION TIME $ELAPSED: expired FAKE_NUM=$FAKE_NUM CLIENTCOUNT=$CLIENTCOUNT"
179
180         do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
181     done
182
183     return 0
184 }
185 run_test 1d "VBR: expire exports, connect $CLIENTCOUNT clients"
186 # VBR scale tests end
187
188 test_3a() {
189     assert_env CLIENTS MDSRATE MPIRUN
190
191     local -a nodes=(${CLIENTS//,/ })
192
193     # INCREMENT is a number of clients 
194     # a half of clients by default
195     increment=${INCREMENT:-$(( CLIENTCOUNT / 2 ))}
196
197     machinefile=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
198     local LOG=$TMP/${TESTSUITE}_$tfile
199
200     local var=mds_svc
201     local procfile="*.${!var}.recovery_status"
202     local iters=${ITERS:-3}
203     local nfiles=${NFILES:-50000}
204     local nthreads=${THREADS_PER_CLIENT:-3}
205
206     local IFree=$(inodes_available)
207     [ $IFree -gt $nfiles ] || nfiles=$IFree
208
209     local dir=$DIR/$tdir
210     mkdir -p $dir
211     chmod 0777 $dir
212
213     local pid
214     local list
215     local -a res
216
217     local num=$increment
218
219     while [ $num -le $CLIENTCOUNT ]; do
220         list=$(comma_list ${nodes[@]:0:$num}) 
221
222         generate_machine_file $list $machinefile ||
223             { error "can not generate machinefile"; exit 1; }
224
225         for i in $(seq $iters); do
226             mdsrate_cleanup $num $machinefile $nfiles $dir 'f%%d' --ignore
227
228             COMMAND="${MDSRATE} --create --nfiles $nfiles --dir $dir --filefmt 'f%%d'"
229             mpi_run -np $((num * nthreads)) -machinefile $machinefile ${COMMAND} | tee ${LOG} &
230
231             pid=$!
232             echo "pid=$pid"
233
234             # 2 threads 100000 creates 117 secs
235             sleep 20
236
237             log "$i : Starting failover on mds"
238             facet_failover mds
239             if ! wait_recovery_complete mds $((TIMEOUT * 10)); then
240                 echo "mds recovery is not completed!"
241                 kill -9 $pid
242                 exit 7
243             fi
244
245             duration=$(do_facet mds lctl get_param -n $procfile | grep recovery_duration)
246             
247             res=( "${res[@]}" "$num" )
248             res=( "${res[@]}" "$duration" )
249             echo "RECOVERY TIME: NFILES=$nfiles number of clients: $num  $duration"
250             wait $pid
251
252         done
253         num=$((num + increment))
254     done
255
256     mdsrate_cleanup $num $machinefile $nfiles $dir 'f%%d' --ignore
257
258     i=0
259     while [ $i -lt ${#res[@]} ]; do
260         echo "RECOVERY TIME: NFILES=$nfiles number of clients: ${res[i]}  ${res[i+1]}"
261         i=$((i+2))
262     done
263 }
264
265 run_test 3a "recovery time, $CLIENTCOUNT clients"
266
267 equals_msg `basename $0`: test complete, cleaning up
268 check_and_cleanup_lustre
269 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true