]> git.proxmox.com Git - ceph.git/blame - ceph/qa/standalone/mon/misc.sh
bump version to 18.2.2-pve1
[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 "
7c673cae 172 CEPH_ARGS+="--mon-host=$MONA,$MONB,$MONC "
31f18b77 173 CEPH_ARGS+="--mon-debug-no-initial-persistent-features "
1e59de90 174 CEPH_ARGS+="--mon-debug-no-require-reef "
7c673cae
FG
175
176 run_mon $dir a --public-addr $MONA || return 1
177 run_mon $dir b --public-addr $MONB || return 1
178 timeout 120 ceph -s > /dev/null || return 1
179
7c673cae 180 # expect monmap to contain 3 monitors (a, b, and c)
9f95a23c 181 jqinput="$(ceph quorum_status --format=json 2>/dev/null)"
7c673cae
FG
182 jq_success "$jqinput" '.monmap.mons | length == 3' || return 1
183 # quorum contains two monitors
184 jq_success "$jqinput" '.quorum | length == 2' || return 1
1e59de90
TL
185 # quorum's monitor features contain kraken, luminous, mimic, nautilus,
186 # octopus, pacific, quincy
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
1e59de90
TL
201 jqfilter='.features.quorum_mon[]|select(. == "reef")'
202 jq_success "$jqinput" "$jqfilter" "reef" || return 1
7c673cae
FG
203
204 # monmap must have no persistent features set, because we
205 # don't currently have a quorum made out of all the monitors
206 # in the monmap.
207 jqfilter='.monmap.features.persistent | length == 0'
208 jq_success "$jqinput" "$jqfilter" || return 1
209
210 # nor do we have any optional features, for that matter.
211 jqfilter='.monmap.features.optional | length == 0'
212 jq_success "$jqinput" "$jqfilter" || return 1
213
224ce89b 214 # validate 'mon feature ls'
7c673cae 215
224ce89b 216 jqinput="$(ceph mon feature ls --format=json 2>/dev/null)"
1e59de90 217 # k l m n o p q are supported
7c673cae
FG
218 jqfilter='.all.supported[] | select(. == "kraken")'
219 jq_success "$jqinput" "$jqfilter" "kraken" || return 1
220 jqfilter='.all.supported[] | select(. == "luminous")'
221 jq_success "$jqinput" "$jqfilter" "luminous" || return 1
11fdf7f2
TL
222 jqfilter='.all.supported[] | select(. == "mimic")'
223 jq_success "$jqinput" "$jqfilter" "mimic" || return 1
224 jqfilter='.all.supported[] | select(. == "nautilus")'
225 jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
f67539c2
TL
226 jqfilter='.all.supported[] | select(. == "octopus")'
227 jq_success "$jqinput" "$jqfilter" "octopus" || return 1
20effc67
TL
228 jqfilter='.all.supported[] | select(. == "pacific")'
229 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
230 jqfilter='.all.supported[] | select(. == "quincy")'
231 jq_success "$jqinput" "$jqfilter" "quincy" || return 1
1e59de90
TL
232 jqfilter='.all.supported[] | select(. == "reef")'
233 jq_success "$jqinput" "$jqfilter" "reef" || return 1
7c673cae
FG
234
235 # start third monitor
236 run_mon $dir c --public-addr $MONC || return 1
237
238 wait_for_quorum 300 3 || return 1
239
240 timeout 300 ceph -s > /dev/null || return 1
241
9f95a23c 242 jqinput="$(ceph quorum_status --format=json 2>/dev/null)"
7c673cae
FG
243 # expect quorum to have all three monitors
244 jqfilter='.quorum | length == 3'
245 jq_success "$jqinput" "$jqfilter" || return 1
7c673cae 246
f67539c2
TL
247 # quorum's monitor features should have p now too
248 jqfilter='.features.quorum_mon[]|select(. == "pacific")'
249 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
250
251 # persistent too
7c673cae
FG
252 jqfilter='.monmap.features.persistent[]|select(. == "kraken")'
253 jq_success "$jqinput" "$jqfilter" "kraken" || return 1
254 jqfilter='.monmap.features.persistent[]|select(. == "luminous")'
255 jq_success "$jqinput" "$jqfilter" "luminous" || return 1
11fdf7f2
TL
256 jqfilter='.monmap.features.persistent[]|select(. == "mimic")'
257 jq_success "$jqinput" "$jqfilter" "mimic" || return 1
258 jqfilter='.monmap.features.persistent[]|select(. == "osdmap-prune")'
259 jq_success "$jqinput" "$jqfilter" "osdmap-prune" || return 1
260 jqfilter='.monmap.features.persistent[]|select(. == "nautilus")'
261 jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
9f95a23c
TL
262 jqfilter='.monmap.features.persistent[]|select(. == "octopus")'
263 jq_success "$jqinput" "$jqfilter" "octopus" || return 1
f67539c2
TL
264 jqfilter='.monmap.features.persistent[]|select(. == "pacific")'
265 jq_success "$jqinput" "$jqfilter" "pacific" || return 1
266 jqfilter='.monmap.features.persistent[]|select(. == "elector-pinging")'
267 jq_success "$jqinput" "$jqfilter" "elector-pinging" || return 1
1e59de90 268 jqfilter='.monmap.features.persistent | length == 10'
f67539c2 269 jq_success "$jqinput" "$jqfilter" || return 1
20effc67
TL
270 jqfilter='.monmap.features.persistent[]|select(. == "quincy")'
271 jq_success "$jqinput" "$jqfilter" "quincy" || return 1
1e59de90
TL
272 jqfilter='.monmap.features.persistent[]|select(. == "reef")'
273 jq_success "$jqinput" "$jqfilter" "reef" || return 1
7c673cae
FG
274
275 CEPH_ARGS=$CEPH_ARGS_orig
276 # that's all folks. thank you for tuning in.
277 teardown $dir || return 1
278}
279
280main misc "$@"
281
282# Local Variables:
283# compile-command: "cd ../.. ; make -j4 && test/mon/misc.sh"
284# End: