]> git.proxmox.com Git - ceph.git/blob - ceph/qa/standalone/osd/osd-markdown.sh
update sources to v12.2.3
[ceph.git] / ceph / qa / standalone / osd / osd-markdown.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2015 Intel <contact@intel.com.com>
4 # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
5 #
6 # Author: Xiaoxi Chen <xiaoxi.chen@intel.com>
7 #
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)
11 # any later version.
12 #
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.
17 #
18
19 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
20
21 function run() {
22 local dir=$1
23 shift
24
25 export CEPH_MON="127.0.0.1:7108" # git grep '\<7108\>' : there must be only one
26 export CEPH_ARGS
27 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
28 CEPH_ARGS+="--mon-host=$CEPH_MON "
29
30 local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
31 for func in $funcs ; do
32 setup $dir || return 1
33 $func $dir || return 1
34 teardown $dir || return 1
35 done
36 }
37
38 function markdown_N_impl() {
39 markdown_times=$1
40 total_time=$2
41 sleeptime=$3
42 for i in `seq 1 $markdown_times`
43 do
44 # check the OSD is UP
45 ceph osd tree
46 ceph osd tree | grep osd.0 |grep up || return 1
47 # mark the OSD down.
48 ceph osd down 0
49 sleep $sleeptime
50 done
51 }
52
53
54 function TEST_markdown_exceed_maxdown_count() {
55 local dir=$1
56
57 run_mon $dir a || return 1
58 run_mgr $dir x || return 1
59 run_osd $dir 0 || return 1
60 run_osd $dir 1 || return 1
61 run_osd $dir 2 || return 1
62
63 create_rbd_pool || return 1
64
65 # 3+1 times within 300s, osd should stay dead on the 4th time
66 local count=3
67 local sleeptime=10
68 local period=300
69 ceph tell osd.0 injectargs '--osd_max_markdown_count '$count'' || return 1
70 ceph tell osd.0 injectargs '--osd_max_markdown_period '$period'' || return 1
71
72 markdown_N_impl $(($count+1)) $period $sleeptime
73 # down N+1 times ,the osd.0 shoud die
74 ceph osd tree | grep down | grep osd.0 || return 1
75 }
76
77 function TEST_markdown_boot() {
78 local dir=$1
79
80 run_mon $dir a || return 1
81 run_mgr $dir x || return 1
82 run_osd $dir 0 || return 1
83 run_osd $dir 1 || return 1
84 run_osd $dir 2 || return 1
85
86 create_rbd_pool || return 1
87
88 # 3 times within 120s, should stay up
89 local count=3
90 local sleeptime=10
91 local period=120
92 ceph tell osd.0 injectargs '--osd_max_markdown_count '$count'' || return 1
93 ceph tell osd.0 injectargs '--osd_max_markdown_period '$period'' || return 1
94
95 markdown_N_impl $count $period $sleeptime
96 #down N times, osd.0 should be up
97 sleep 15 # give osd plenty of time to notice and come back up
98 ceph osd tree | grep up | grep osd.0 || return 1
99 }
100
101 function TEST_markdown_boot_exceed_time() {
102 local dir=$1
103
104 run_mon $dir a || return 1
105 run_mgr $dir x || return 1
106 run_osd $dir 0 || return 1
107 run_osd $dir 1 || return 1
108 run_osd $dir 2 || return 1
109
110 create_rbd_pool || return 1
111
112 # 3+1 times, but over 40s, > 20s, so should stay up
113 local count=3
114 local period=20
115 local sleeptime=10
116 ceph tell osd.0 injectargs '--osd_max_markdown_count '$count'' || return 1
117 ceph tell osd.0 injectargs '--osd_max_markdown_period '$period'' || return 1
118
119 markdown_N_impl $(($count+1)) $period $sleeptime
120 sleep 15 # give osd plenty of time to notice and come back up
121 ceph osd tree | grep up | grep osd.0 || return 1
122 }
123
124 main osd-markdown "$@"
125
126 # Local Variables:
127 # compile-command: "cd ../.. ; make -j4 && test/osd/osd-bench.sh"
128 # End: