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