3 # Copyright (C) 2016 Piotr Dałek <git@predictor.org.pl>
4 # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
6 # Author: Piotr Dałek <git@predictor.org.pl>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Library Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Library Public License for more details.
19 source $
(dirname $0)/..
/detect-build-env-vars.sh
20 source $CEPH_ROOT/qa
/workunits
/ceph-helpers.sh
21 MAX_PROPAGATION_TIME
=30
27 export CEPH_MON
="127.0.0.1:7126" # git grep '\<7126\>' : there must be only one
29 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
30 CEPH_ARGS
+="--mon-host=$CEPH_MON "
33 CEPH_ARGS
+="--osd-fast-fail-on-connection-refused=false "
34 echo "Ensuring old behavior is there..."
35 test_fast_kill
$dir && (echo "OSDs died too early! Old behavior doesn't work." ; return 1)
37 CEPH_ARGS
=$OLD_ARGS"--osd-fast-fail-on-connection-refused=true "
40 CEPH_ARGS
+="--ms_type=simple"
41 echo "Testing simple msgr..."
42 test_fast_kill
$dir ||
return 1
44 CEPH_ARGS
=$OLD_ARGS"--ms_type=async"
45 echo "Testing async msgr..."
46 test_fast_kill
$dir ||
return 1
52 function test_fast_kill
() {
53 # create cluster with 3 osds
54 setup
$dir ||
return 1
55 run_mon
$dir a
--osd_pool_default_size=3 ||
return 1
56 run_mgr
$dir x ||
return 1
58 run_osd
$dir $oi ||
return 1
59 pids
[$oi]=$
(cat $dir/osd.
$oi.pid
)
62 # make some objects so osds to ensure connectivity between osds
63 rados
-p rbd bench
10 write -b 4096 --max-objects 128 --no-cleanup
69 # kill random osd and see if after max MAX_PROPAGATION_TIME, the osd count decreased.
71 while [ $killid -eq $previd ]; do
72 killid
=${pids[$RANDOM%${#pids[@]}]}
77 time_left
=$MAX_PROPAGATION_TIME
80 while [ $time_left -gt 0 ]; do
82 time_left
=$
[$time_left - 1];
84 grep -m 1 -c -F "ms_handle_refused" $dir/osd.
*.log
> /dev
/null
89 down_osds
=$
(ceph osd tree |
grep -c down
)
90 if [ $down_osds -lt $i ]; then
91 # osds not marked down yet, try again in a second
93 elif [ $down_osds -gt $i ]; then
94 echo Too many \
($down_osds\
) osds died
!
101 if [ $down_osds -lt $i ]; then
102 echo Killed the OSD
, yet it is not marked down
108 teardown
$dir ||
return 1
111 main osd-fast-mark-down
"$@"
114 # compile-command: "cd ../.. ; make -j4 && test/osd/osd-fast-mark-down.sh"