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 "
32 # Disable device auto class feature for this testing,
33 # as it will automatically make root clones based on new class types
34 # and hence affect the down osd counting.
37 # ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY
38 # -4 3.00000 root default~hdd
39 # -3 3.00000 host gitbuilder-ceph-rpm-centos7-amd64-basic~hdd
40 # 0 1.00000 osd.0 down 1.00000 1.00000
41 # 1 1.00000 osd.1 up 1.00000 1.00000
42 # 2 1.00000 osd.2 up 1.00000 1.00000
43 # -1 3.00000 root default
44 # -2 3.00000 host gitbuilder-ceph-rpm-centos7-amd64-basic
45 # 0 1.00000 osd.0 down 1.00000 1.00000
46 # 1 1.00000 osd.1 up 1.00000 1.00000
47 # 2 1.00000 osd.2 up 1.00000 1.00000
49 CEPH_ARGS
+="--osd-class-update-on-start=false "
52 CEPH_ARGS
+="--osd-fast-fail-on-connection-refused=false "
53 echo "Ensuring old behavior is there..."
54 test_fast_kill
$dir && (echo "OSDs died too early! Old behavior doesn't work." ; return 1)
56 CEPH_ARGS
=$OLD_ARGS"--osd-fast-fail-on-connection-refused=true "
59 CEPH_ARGS
+="--ms_type=simple"
60 echo "Testing simple msgr..."
61 test_fast_kill
$dir ||
return 1
63 CEPH_ARGS
=$OLD_ARGS"--ms_type=async"
64 echo "Testing async msgr..."
65 test_fast_kill
$dir ||
return 1
71 function test_fast_kill
() {
72 # create cluster with 3 osds
73 setup
$dir ||
return 1
74 run_mon
$dir a
--osd_pool_default_size=3 ||
return 1
75 run_mgr
$dir x ||
return 1
77 run_osd
$dir $oi ||
return 1
78 pids
[$oi]=$
(cat $dir/osd.
$oi.pid
)
81 # make some objects so osds to ensure connectivity between osds
82 rados
-p rbd bench
10 write -b 4096 --max-objects 128 --no-cleanup
88 # kill random osd and see if after max MAX_PROPAGATION_TIME, the osd count decreased.
90 while [ $killid -eq $previd ]; do
91 killid
=${pids[$RANDOM%${#pids[@]}]}
96 time_left
=$MAX_PROPAGATION_TIME
99 while [ $time_left -gt 0 ]; do
101 time_left
=$
[$time_left - 1];
103 grep -m 1 -c -F "ms_handle_refused" $dir/osd.
*.log
> /dev
/null
104 if [ $?
-ne 0 ]; then
108 down_osds
=$
(ceph osd tree |
grep -c down
)
109 if [ $down_osds -lt $i ]; then
110 # osds not marked down yet, try again in a second
112 elif [ $down_osds -gt $i ]; then
113 echo Too many \
($down_osds\
) osds died
!
120 if [ $down_osds -lt $i ]; then
121 echo Killed the OSD
, yet it is not marked down
127 teardown
$dir ||
return 1
130 main osd-fast-mark-down
"$@"
133 # compile-command: "cd ../.. ; make -j4 && test/osd/osd-fast-mark-down.sh"