3 # All pairwise combinations of node failures.
6 # Author: Chris Cooper <ccooper@clusterfs.com>
8 # Script fails pair of nodes:
9 # -- in parallel by default
10 # -- in series if SERIAL is set
12 LUSTRE=${LUSTRE:-`dirname $0`/..}
14 CLEANUP=${CLEANUP:-""}
15 . $LUSTRE/tests/test-framework.sh
19 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
21 TESTSUITELOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh)}
22 DEBUGLOG=$TESTSUITELOG.debug
27 echo "--- env ---" >&2
29 echo "--- env ---" >&2
32 [ "$SHARED_DIRECTORY" ] || \
33 { skip "$0: Empty SHARED_DIRECTORY" && exit 0; }
35 [ -n "$CLIENTS" ] || { skip "$0 Need two or more remote clients" && exit 0; }
36 [ $CLIENTCOUNT -ge 3 ] || \
37 { skip "$0 Need two or more remote clients, have $CLIENTCOUNT" && exit 0; }
39 END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
40 LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
42 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
43 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
45 check_timeout || exit 1
49 check_and_setup_lustre
50 rm -rf $DIR/[df][0-9]*
52 # the test node needs to be insulated from a lustre failure as much as possible,
53 # so not even loading the lustre modules is ideal.
55 # -- remove hostname from clients list
56 zconf_umount $(hostname) $MOUNT
57 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
58 NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $(hostname))
60 check_progs_installed $NODES_TO_USE ${CLIENT_LOADS[@]}
62 MDTS=$(get_facets MDS)
63 OSTS=$(get_facets OST)
67 reboot_recover_node () {
68 # item var contains a pair of clients if nodetype=clients
69 # I would prefer to have a list here
72 local timeout=$($LCTL get_param -n timeout)
74 # MDS, OST item contains the facet
76 MDS|OST ) facet_failover $item
77 [ "$SERIAL" ] && wait_recovery_complete $item $((timeout * 4)) || true
79 clients) for c in ${item//,/ }; do
80 # make sure the client loads die
81 do_nodes $c "set -x; test -f $TMP/client-load.pid && \
82 { kill -s TERM \$(cat $TMP/client-load.pid) || true; }"
85 echo "Reintegrating $c"
86 # one client fails; need dk logs from this client only
87 zconf_mount $c $MOUNT || NODES="$c $(mdts_nodes) $(osts_nodes)" error_exit "zconf_mount failed"
89 start_client_loads $item
92 # don't use error (), the logs from all nodes not needed
93 * ) echo "reboot_recover_node: nodetype=$nodetype. Must be one of 'MDS', 'OST', or 'clients'."
100 local excluded=${2:-""}
106 clients) list=$NODES_TO_USE
109 # don't use error (), the logs from all nodes not needed
110 * ) echo "Invalid type=$type. Must be one of 'MDS', 'OST', or 'clients'."
114 [ "$excluded" ] && list=$(exclude_items_from_list $list $excluded)
116 if [ ! "$(echo $list)" ]; then
121 item=$(get_random_entry $list)
122 if [ "$type" = clients ] ; then
123 item="$item $(get_random_entry $(exclude_items_from_list $list $item))"
124 item=$(comma_list $item)
131 # for the two nodetypes specified, chooses a random node(s) from each
132 # class, reboots the nodes sequentially, and then restarts lustre on
139 local client_nodes=""
146 ==== START === $title "
148 item1=$(get_item_type $type1)
150 { echo "type1=$type1 item1 is empty" && return 0; }
151 item2=$(get_item_type $type2 $item1)
153 { echo "type1=$type1 item1=$item1 type2=$type2 item2=$item2 is empty" && return 0; }
155 # Check that our client loads are still running. If any have died,
156 # that means they have died outside of recovery, which is unacceptable.
157 log "==== Checking the clients loads BEFORE failover -- failure NOT OK"
159 # FIXME. need print summary on exit
160 if ! check_client_loads $NODES_TO_USE; then
164 log "Done checking client loads. Failing type1=$type1 item1=$item1 ... "
166 reboot_recover_node $item1 $type1
168 # Hendrix test17 description:
169 # Introduce a failure, wait at
170 # least 5 minutes (for recovery),
172 # failure, and wait another 5
175 # reboot_recover_node waits recovery in according to
177 # We have a "double failures" if SERIAL is not set,
178 # do not need a sleep between failures for "double failures"
180 log " Failing type2=$type2 item2=$item2 ... "
181 reboot_recover_node $item2 $type2
183 # Client loads are allowed to die while in recovery, so we just
185 log "==== Checking the clients loads AFTER failovers -- ERRORS_OK=$ERRORS_OK"
186 restart_client_loads $NODES_TO_USE $ERRORS_OK || return $?
187 log "Done checking / re-Starting client loads. PASS"
191 summary_and_cleanup () {
195 # Having not empty END_RUN_FILE means the failed loads only
196 if [ -s $END_RUN_FILE ]; then
197 echo "Found the END_RUN_FILE file: $END_RUN_FILE"
200 read END_RUN_NODE < $END_RUN_FILE
202 # a client load will end (i.e. fail) if it finds
203 # the end run file. that does not mean that that client load
204 # actually failed though. the first node in the END_RUN_NODE is
205 # the one we are really interested in.
206 if [ -n "$END_RUN_NODE" ]; then
207 var=$(client_var_name $END_RUN_NODE)_load
208 echo "Client load failed on node $END_RUN_NODE"
210 echo "client $END_RUN_NODE load debug output :"
211 local logfile=${TESTSUITELOG}_run_${!var}.sh-${END_RUN_NODE}.debug
212 do_node ${END_RUN_NODE} "set -x; [ -e $logfile ] && cat $logfile " || true
217 echo $(date +'%F %H:%M:%S') Terminating clients loads ...
218 echo "$0" >> $END_RUN_FILE
220 [ $rc -eq 0 ] || result=FAIL
223 Server failover period: $FAILOVER_PERIOD seconds
224 Exited after: $ELAPSED seconds
225 Status: $result: rc=$rc"
227 # make sure the client loads die
228 do_nodes $NODES_TO_USE "set -x; test -f $TMP/client-load.pid && \
229 { kill -s TERM \$(cat $TMP/client-load.pid) || true; }"
231 # and free up the pdshes that started them, if any are still around
232 if [ -n "$CLIENT_LOAD_PIDS" ]; then
233 kill $CLIENT_LOAD_PIDS || true
235 kill -9 $CLIENT_LOAD_PIDS || true
238 if [ $rc -ne 0 ]; then
239 # we are interested in only on failed clients and servers
240 local failedclients=$(cat $END_RUN_FILE | grep -v $0)
241 # FIXME: need ostfailover-s nodes also for FLAVOR=OST
242 local product=$(gather_logs $(comma_list $(osts_nodes) \
243 $(mdts_nodes) $mdsfailover_HOST $failedclients))
244 echo logs files $product
247 [ $rc -eq 0 ] && zconf_mount $(hostname) $MOUNT
251 trap summary_and_cleanup EXIT TERM INT
256 log "-----============= $0 starting =============-----"
262 # Set SERIAL to serialize the failure through a recovery of the first failure.
266 [ "$SERIAL" ] && ERRORS_OK=""
268 FAILOVER_PERIOD=${FAILOVER_PERIOD:-$((60*5))} # 5 minutes
270 # Start client loads.
271 start_client_loads $NODES_TO_USE
272 echo clients load pids:
273 if ! do_nodesv $NODES_TO_USE "cat $TMP/client-load.pid"; then
277 # FIXME: Do we want to have an initial sleep period where the clients
278 # just run before introducing a failure?
279 sleep $FAILOVER_PERIOD
282 failover_pair MDS OST "test 1: failover MDS, then OST =========="
283 sleep $FAILOVER_PERIOD
286 failover_pair MDS clients "test 2: failover MDS, then 2 clients ===="
287 sleep $FAILOVER_PERIOD
290 if [ $MDSCOUNT -gt 1 ]; then
291 failover_pair MDS MDS "test 3: failover MDS, then another MDS =="
292 sleep $FAILOVER_PERIOD
294 skip "$0 : $MDSCOUNT < 2 MDTs, test 3 skipped"
298 if [ $OSTCOUNT -gt 1 ]; then
299 failover_pair OST OST "test 4: failover OST, then another OST =="
300 sleep $FAILOVER_PERIOD
302 skip "$0 : $OSTCOUNT < 2 OSTs, test 4 skipped"
306 failover_pair OST clients "test 5: failover OST, then 2 clients ===="
307 sleep $FAILOVER_PERIOD
310 failover_pair OST MDS "test 6: failover OST, then MDS =========="
311 sleep $FAILOVER_PERIOD
314 failover_pair clients MDS "test 7: failover 2 clients, then MDS ===="
315 sleep $FAILOVER_PERIOD
318 #failover_pair clients OST "test 8: failover 2 clients, then OST ===="
319 sleep $FAILOVER_PERIOD
322 if [ $CLIENTCOUNT -ge 5 ]; then
323 failover_pair clients clients "test 9: failover 2 clients, then 2 different clients =="
324 sleep $FAILOVER_PERIOD
326 log "==== Checking the clients loads AFTER all failovers -- failure NOT OK"
327 if ! check_client_loads $NODES_TO_USE; then
328 log "Client load failed after failover. Exiting"
332 CURRENT_TS=$(date +%s)
333 ELAPSED=$((CURRENT_TS - START_TS))
335 log "Completed successfully in $ELAPSED seconds"