]> git.proxmox.com Git - ceph.git/blame - ceph/qa/standalone/mon/misc.sh
import quincy beta 17.1.0
[ceph.git] / ceph / qa / standalone / mon / misc.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2#
3# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
4# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
5#
6# Author: Loic Dachary <loic@dachary.org>
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#
c07f9fc5 18source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
7c673cae
FG
19
20function run() {
21 local dir=$1
22 shift
23
24 export CEPH_MON="127.0.0.1:7102" # git grep '\<7102\>' : there must be only one
25 export CEPH_ARGS
26 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
27 CEPH_ARGS+="--mon-host=$CEPH_MON "
28
29 local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
30 for func in $funcs ; do
31 $func $dir || return 1
32 done
33}
34
35TEST_POOL=rbd
36
37function TEST_osd_pool_get_set() {
38 local dir=$1
39
40 setup $dir || return 1
41 run_mon $dir a || return 1
b5b8bbf5 42 create_pool $TEST_POOL 8
7c673cae
FG
43
44 local flag
45 for flag in nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
46 ceph osd pool set $TEST_POOL $flag 0 || return 1
47 ! ceph osd dump | grep 'pool ' | grep $flag || return 1
48 ceph osd pool set $TEST_POOL $flag 1 || return 1
49 ceph osd dump | grep 'pool ' | grep $flag || return 1
50 ceph osd pool set $TEST_POOL $flag false || return 1
51 ! ceph osd dump | grep 'pool ' | grep $flag || return 1
52 ceph osd pool set $TEST_POOL $flag false || return 1
53 # check that setting false twice does not toggle to true (bug)
54 ! ceph osd dump | grep 'pool ' | grep $flag || return 1
55 ceph osd pool set $TEST_POOL $flag true || return 1
56 ceph osd dump | grep 'pool ' | grep $flag || return 1
57 # cleanup
58 ceph osd pool set $TEST_POOL $flag 0 || return 1
59 done
60
61 local size=$(ceph osd pool get $TEST_POOL size|awk '{print $2}')
62 local min_size=$(ceph osd pool get $TEST_POOL min_size|awk '{print $2}')
11fdf7f2
TL
63 local expected_min_size=$(expr $size - $size / 2)
64 if [ $min_size -ne $expected_min_size ]; then
65 echo "default min_size is wrong: expected $expected_min_size, got $min_size"
66 return 1
67 fi
7c673cae
FG
68
69 ceph osd pool set $TEST_POOL scrub_min_interval 123456 || return 1
70 ceph osd dump | grep 'pool ' | grep 'scrub_min_interval 123456' || return 1
71 ceph osd pool set $TEST_POOL scrub_min_interval 0 || return 1
72 ceph osd dump | grep 'pool ' | grep 'scrub_min_interval' && return 1
73 ceph osd pool set $TEST_POOL scrub_max_interval 123456 || return 1
74 ceph osd dump | grep 'pool ' | grep 'scrub_max_interval 123456' || return 1
75 ceph osd pool set $TEST_POOL scrub_max_interval 0 || return 1
76 ceph osd dump | grep 'pool ' | grep 'scrub_max_interval' && return 1
77 ceph osd pool set $TEST_POOL deep_scrub_interval 123456 || return 1
78 ceph osd dump | grep 'pool ' | grep 'deep_scrub_interval 123456' || return 1
79 ceph osd pool set $TEST_POOL deep_scrub_interval 0 || return 1
80 ceph osd dump | grep 'pool ' | grep 'deep_scrub_interval' && return 1
81
82 #replicated pool size restrict in 1 and 10
83 ! ceph osd pool set $TEST_POOL 11 || return 1
84 #replicated pool min_size must be between in 1 and size
85 ! ceph osd pool set $TEST_POOL min_size $(expr $size + 1) || return 1
86 ! ceph osd pool set $TEST_POOL min_size 0 || return 1
87
88 local ecpool=erasepool
b5b8bbf5 89 create_pool $ecpool 12 12 erasure default || return 1
7c673cae
FG
90 #erasue pool size=k+m, min_size=k
91 local size=$(ceph osd pool get $ecpool size|awk '{print $2}')
92 local min_size=$(ceph osd pool get $ecpool min_size|awk '{print $2}')
93 local k=$(expr $min_size - 1) # default min_size=k+1
94 #erasure pool size can't change
95 ! ceph osd pool set $ecpool size $(expr $size + 1) || return 1
96 #erasure pool min_size must be between in k and size
97 ceph osd pool set $ecpool min_size $(expr $k + 1) || return 1
98 ! ceph osd pool set $ecpool min_size $(expr $k - 1) || return 1
99 ! ceph osd pool set $ecpool min_size $(expr $size + 1) || return 1
100
101 teardown $dir || return 1
102}
103
104function TEST_mon_add_to_single_mon() {
105 local dir=$1
106
107 fsid=$(uuidgen)
108 MONA=127.0.0.1:7117 # git grep '\<7117\>' : there must be only one
109 MONB=127.0.0.1:7118 # git grep '\<7118\>' : there must be only one
110 CEPH_ARGS_orig=$CEPH_ARGS
111 CEPH_ARGS="--fsid=$fsid --auth-supported=none "
112 CEPH_ARGS+="--mon-initial-members=a "
113 CEPH_ARGS+="--mon-host=$MONA "
114
115 setup $dir || return 1
116 run_mon $dir a --public-addr $MONA || return 1
117 # wait for the quorum
118 timeout 120 ceph -s > /dev/null || return 1
119 run_mon $dir b --public-addr $MONB || return 1
120 teardown $dir || return 1
121
122 setup $dir || return 1
123 run_mon $dir a --public-addr $MONA || return 1
124 # without the fix of #5454, mon.a will assert failure at seeing the MMonJoin
125 # from mon.b
126 run_mon $dir b --public-addr $MONB || return 1
11fdf7f2
TL
127 # make sure mon.b get's it's join request in first, then
128 sleep 2
7c673cae
FG
129 # wait for the quorum
130 timeout 120 ceph -s > /dev/null || return 1
11fdf7f2
TL
131 ceph mon dump
132 ceph mon dump -f json-pretty
7c673cae 133 local num_mons
31f18b77 134 num_mons=$(ceph mon dump --format=json 2>/dev/null | jq ".mons | length") || return 1
7c673cae
FG
135 [ $num_mons == 2 ] || return 1
136 # no reason to take more than 120 secs to get this submitted
137 timeout 120 ceph mon add b $MONB || return 1
138 teardown $dir || return 1
139}
140
141function TEST_no_segfault_for_bad_keyring() {
142 local dir=$1
143 setup $dir || return 1
144 # create a client.admin key and add it to ceph.mon.keyring
145 ceph-authtool --create-keyring $dir/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
146 ceph-authtool --create-keyring $dir/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *'
147 ceph-authtool $dir/ceph.mon.keyring --import-keyring $dir/ceph.client.admin.keyring
148 CEPH_ARGS_TMP="--fsid=$(uuidgen) --mon-host=127.0.0.1:7102 --auth-supported=cephx "
149 CEPH_ARGS_orig=$CEPH_ARGS
150 CEPH_ARGS="$CEPH_ARGS_TMP --keyring=$dir/ceph.mon.keyring "
151 run_mon $dir a
152 # create a bad keyring and make sure no segfault occurs when using the bad keyring
153 echo -e "[client.admin]\nkey = BQAUlgtWoFePIxAAQ9YLzJSVgJX5V1lh5gyctg==" > $dir/bad.keyring
154 CEPH_ARGS="$CEPH_ARGS_TMP --keyring=$dir/bad.keyring"
155 ceph osd dump 2> /dev/null
156 # 139(11|128) means segfault and core dumped
157 [ $? -eq 139 ] && return 1
158 CEPH_ARGS=$CEPH_ARGS_orig
159 teardown $dir || return 1
160}
161
7c673cae
FG
162function TEST_mon_features() {
163 local dir=$1
164 setup $dir || return 1
165
166 fsid=$(uuidgen)
167 MONA=127.0.0.1:7127 # git grep '\<7127\>' ; there must be only one
168 MONB=127.0.0.1:7128 # git grep '\<7128\>' ; there must be only one
169 MONC=127.0.0.1:7129 # git grep '\<7129\>' ; there must be only one
170 CEPH_ARGS_orig=$CEPH_ARGS
171 CEPH_ARGS="--fsid=$fsid --auth-supported=none "
172 CEPH_ARGS+="--mon-initial-members=a,b,c "
173 CEPH_ARGS+="--mon-host=$MONA,$MONB,$MONC "
31f18b77 174 CEPH_ARGS+="--mon-debug-no-initial-persistent-features "
20effc67 175 CEPH_ARGS+="--mon-debug-no-require-quincy "
7c673cae
FG
176
177 run_mon $dir a --public-addr $MONA || return 1
178 run_mon $dir b --public-addr $MONB || return 1
179 timeout 120 ceph -s > /dev/null || return 1
180
7c673cae 181 # expect monmap to contain 3 monitors (a, b, and c)
9f95a23c 182 jqinput="$(ceph quorum_status --format=json 2>/dev/null)"
7c673cae
FG
183 jq_success "$jqinput" '.monmap.mons | length == 3' || return 1
184 # quorum contains two monitors
185 jq_success "$jqinput" '.quorum | length == 2' || return 1
20effc67 186 # quorum's monitor features contain kraken, luminous, mimic, nautilus, octopus, pacific
7c673cae
FG
187 jqfilter='.features.quorum_mon[]|select(. == "kraken")'
188 jq_success "$jqinput" "$jqfilter" "kraken" || return 1
189 jqfilter='.features.quorum_mon[]|select(. == "luminous")'
190 jq_success "$jqinput" "$jqfilter" "luminous" || return 1
11fdf7f2
TL
191 jqfilter='.features.quorum_mon[]|select(. == "mimic")'
192 jq_success "$jqinput" "$jqfilter" "mimic" || return 1
193 jqfilter='.features.quorum_mon[]|select(. == "nautilus")'
194 jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
f67539c2
TL
195 jqfilter='.features.quorum_mon[]|select(. == "octopus")'
196 jq_success "$jqinput" "$jqfilter" "octopus" || return 1
20effc67
TL
197 jqfilter='.features.quorum_mon[]|select(. == "pacific")'
198 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
199 jqfilter='.features.quorum_mon[]|select(. == "quincy")'
200 jq_success "$jqinput" "$jqfilter" "quincy" || return 1
7c673cae
FG
201
202 # monmap must have no persistent features set, because we
203 # don't currently have a quorum made out of all the monitors
204 # in the monmap.
205 jqfilter='.monmap.features.persistent | length == 0'
206 jq_success "$jqinput" "$jqfilter" || return 1
207
208 # nor do we have any optional features, for that matter.
209 jqfilter='.monmap.features.optional | length == 0'
210 jq_success "$jqinput" "$jqfilter" || return 1
211
224ce89b 212 # validate 'mon feature ls'
7c673cae 213
224ce89b 214 jqinput="$(ceph mon feature ls --format=json 2>/dev/null)"
20effc67 215 # k l m n o p are supported
7c673cae
FG
216 jqfilter='.all.supported[] | select(. == "kraken")'
217 jq_success "$jqinput" "$jqfilter" "kraken" || return 1
218 jqfilter='.all.supported[] | select(. == "luminous")'
219 jq_success "$jqinput" "$jqfilter" "luminous" || return 1
11fdf7f2
TL
220 jqfilter='.all.supported[] | select(. == "mimic")'
221 jq_success "$jqinput" "$jqfilter" "mimic" || return 1
222 jqfilter='.all.supported[] | select(. == "nautilus")'
223 jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
f67539c2
TL
224 jqfilter='.all.supported[] | select(. == "octopus")'
225 jq_success "$jqinput" "$jqfilter" "octopus" || return 1
20effc67
TL
226 jqfilter='.all.supported[] | select(. == "pacific")'
227 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
228 jqfilter='.all.supported[] | select(. == "quincy")'
229 jq_success "$jqinput" "$jqfilter" "quincy" || return 1
7c673cae
FG
230
231 # start third monitor
232 run_mon $dir c --public-addr $MONC || return 1
233
234 wait_for_quorum 300 3 || return 1
235
236 timeout 300 ceph -s > /dev/null || return 1
237
9f95a23c 238 jqinput="$(ceph quorum_status --format=json 2>/dev/null)"
7c673cae
FG
239 # expect quorum to have all three monitors
240 jqfilter='.quorum | length == 3'
241 jq_success "$jqinput" "$jqfilter" || return 1
7c673cae 242
f67539c2
TL
243 # quorum's monitor features should have p now too
244 jqfilter='.features.quorum_mon[]|select(. == "pacific")'
245 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
246
247 # persistent too
7c673cae
FG
248 jqfilter='.monmap.features.persistent[]|select(. == "kraken")'
249 jq_success "$jqinput" "$jqfilter" "kraken" || return 1
250 jqfilter='.monmap.features.persistent[]|select(. == "luminous")'
251 jq_success "$jqinput" "$jqfilter" "luminous" || return 1
11fdf7f2
TL
252 jqfilter='.monmap.features.persistent[]|select(. == "mimic")'
253 jq_success "$jqinput" "$jqfilter" "mimic" || return 1
254 jqfilter='.monmap.features.persistent[]|select(. == "osdmap-prune")'
255 jq_success "$jqinput" "$jqfilter" "osdmap-prune" || return 1
256 jqfilter='.monmap.features.persistent[]|select(. == "nautilus")'
257 jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
9f95a23c
TL
258 jqfilter='.monmap.features.persistent[]|select(. == "octopus")'
259 jq_success "$jqinput" "$jqfilter" "octopus" || return 1
f67539c2
TL
260 jqfilter='.monmap.features.persistent[]|select(. == "pacific")'
261 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
262 jqfilter='.monmap.features.persistent[]|select(. == "elector-pinging")'
263 jq_success "$jqinput" "$jqfilter" "elector-pinging" || return 1
20effc67 264 jqfilter='.monmap.features.persistent | length == 9'
f67539c2 265 jq_success "$jqinput" "$jqfilter" || return 1
20effc67
TL
266 jqfilter='.monmap.features.persistent[]|select(. == "quincy")'
267 jq_success "$jqinput" "$jqfilter" "quincy" || return 1
7c673cae
FG
268
269 CEPH_ARGS=$CEPH_ARGS_orig
270 # that's all folks. thank you for tuning in.
271 teardown $dir || return 1
272}
273
274main misc "$@"
275
276# Local Variables:
277# compile-command: "cd ../.. ; make -j4 && test/mon/misc.sh"
278# End: