blob: 1b8a88b3e62cc620333a52405253b796b2e86689 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
#!/bin/bash
#
# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
#
# Author: Loic Dachary <loic@dachary.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library Public License for more details.
#
source $(dirname $0)/../detect-build-env-vars.sh
source $CEPH_ROOT/qa/workunits/ceph-helpers.sh
function run() {
local dir=$1
shift
export CEPH_MON="127.0.0.1:7102" # git grep '\<7102\>' : there must be only one
export CEPH_ARGS
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
for func in $funcs ; do
$func $dir || return 1
done
}
TEST_POOL=rbd
function TEST_osd_pool_get_set() {
local dir=$1
setup $dir || return 1
run_mon $dir a || return 1
local flag
for flag in hashpspool nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
if [ $flag = hashpspool ]; then
ceph osd dump | grep 'pool ' | grep $flag || return 1
else
! ceph osd dump | grep 'pool ' | grep $flag || return 1
fi
ceph osd pool set $TEST_POOL $flag 0 || return 1
! ceph osd dump | grep 'pool ' | grep $flag || return 1
ceph osd pool set $TEST_POOL $flag 1 || return 1
ceph osd dump | grep 'pool ' | grep $flag || return 1
ceph osd pool set $TEST_POOL $flag false || return 1
! ceph osd dump | grep 'pool ' | grep $flag || return 1
ceph osd pool set $TEST_POOL $flag false || return 1
# check that setting false twice does not toggle to true (bug)
! ceph osd dump | grep 'pool ' | grep $flag || return 1
ceph osd pool set $TEST_POOL $flag true || return 1
ceph osd dump | grep 'pool ' | grep $flag || return 1
# cleanup
ceph osd pool set $TEST_POOL $flag 0 || return 1
done
local size=$(ceph osd pool get $TEST_POOL size|awk '{print $2}')
local min_size=$(ceph osd pool get $TEST_POOL min_size|awk '{print $2}')
ceph osd pool set $TEST_POOL scrub_min_interval 123456 || return 1
ceph osd dump | grep 'pool ' | grep 'scrub_min_interval 123456' || return 1
ceph osd pool set $TEST_POOL scrub_min_interval 0 || return 1
ceph osd dump | grep 'pool ' | grep 'scrub_min_interval' && return 1
ceph osd pool set $TEST_POOL scrub_max_interval 123456 || return 1
ceph osd dump | grep 'pool ' | grep 'scrub_max_interval 123456' || return 1
ceph osd pool set $TEST_POOL scrub_max_interval 0 || return 1
ceph osd dump | grep 'pool ' | grep 'scrub_max_interval' && return 1
ceph osd pool set $TEST_POOL deep_scrub_interval 123456 || return 1
ceph osd dump | grep 'pool ' | grep 'deep_scrub_interval 123456' || return 1
ceph osd pool set $TEST_POOL deep_scrub_interval 0 || return 1
ceph osd dump | grep 'pool ' | grep 'deep_scrub_interval' && return 1
#replicated pool size restrict in 1 and 10
! ceph osd pool set $TEST_POOL 11 || return 1
#replicated pool min_size must be between in 1 and size
! ceph osd pool set $TEST_POOL min_size $(expr $size + 1) || return 1
! ceph osd pool set $TEST_POOL min_size 0 || return 1
local ecpool=erasepool
ceph osd pool create $ecpool 12 12 erasure default || return 1
#erasue pool size=k+m, min_size=k
local size=$(ceph osd pool get $ecpool size|awk '{print $2}')
local k=$(ceph osd pool get $ecpool min_size|awk '{print $2}')
#erasure pool size can't change
! ceph osd pool set $ecpool size $(expr $size + 1) || return 1
#erasure pool min_size must be between in k and size
ceph osd pool set $ecpool min_size $(expr $k + 1) || return 1
! ceph osd pool set $ecpool min_size $(expr $k - 1) || return 1
! ceph osd pool set $ecpool min_size $(expr $size + 1) || return 1
teardown $dir || return 1
}
function TEST_mon_add_to_single_mon() {
local dir=$1
fsid=$(uuidgen)
MONA=127.0.0.1:7117 # git grep '\<7117\>' : there must be only one
MONB=127.0.0.1:7118 # git grep '\<7118\>' : there must be only one
CEPH_ARGS_orig=$CEPH_ARGS
CEPH_ARGS="--fsid=$fsid --auth-supported=none "
CEPH_ARGS+="--mon-initial-members=a "
CEPH_ARGS+="--mon-host=$MONA "
setup $dir || return 1
run_mon $dir a --public-addr $MONA || return 1
# wait for the quorum
timeout 120 ceph -s > /dev/null || return 1
run_mon $dir b --public-addr $MONB || return 1
teardown $dir || return 1
setup $dir || return 1
run_mon $dir a --public-addr $MONA || return 1
# without the fix of #5454, mon.a will assert failure at seeing the MMonJoin
# from mon.b
run_mon $dir b --public-addr $MONB || return 1
# wait for the quorum
timeout 120 ceph -s > /dev/null || return 1
local num_mons
num_mons=$(ceph mon dump --format=xml 2>/dev/null | $XMLSTARLET sel -t -v "count(//mons/mon)") || return 1
[ $num_mons == 2 ] || return 1
# no reason to take more than 120 secs to get this submitted
timeout 120 ceph mon add b $MONB || return 1
teardown $dir || return 1
}
function TEST_no_segfault_for_bad_keyring() {
local dir=$1
setup $dir || return 1
# create a client.admin key and add it to ceph.mon.keyring
ceph-authtool --create-keyring $dir/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
ceph-authtool --create-keyring $dir/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *'
ceph-authtool $dir/ceph.mon.keyring --import-keyring $dir/ceph.client.admin.keyring
CEPH_ARGS_TMP="--fsid=$(uuidgen) --mon-host=127.0.0.1:7102 --auth-supported=cephx "
CEPH_ARGS_orig=$CEPH_ARGS
CEPH_ARGS="$CEPH_ARGS_TMP --keyring=$dir/ceph.mon.keyring "
run_mon $dir a
# create a bad keyring and make sure no segfault occurs when using the bad keyring
echo -e "[client.admin]\nkey = BQAUlgtWoFePIxAAQ9YLzJSVgJX5V1lh5gyctg==" > $dir/bad.keyring
CEPH_ARGS="$CEPH_ARGS_TMP --keyring=$dir/bad.keyring"
ceph osd dump 2> /dev/null
# 139(11|128) means segfault and core dumped
[ $? -eq 139 ] && return 1
CEPH_ARGS=$CEPH_ARGS_orig
teardown $dir || return 1
}
main misc "$@"
# Local Variables:
# compile-command: "cd ../.. ; make -j4 && test/mon/misc.sh"
# End:
|