2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-02-13 17:18:43 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
|
2015-05-16 13:36:25 +00:00
|
|
|
# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
|
2014-02-13 17:18:43 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2017-07-21 02:54:48 +00:00
|
|
|
source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
|
2014-02-13 17:18:43 +00:00
|
|
|
|
|
|
|
function run() {
|
|
|
|
local dir=$1
|
2015-05-16 13:36:25 +00:00
|
|
|
shift
|
2014-02-13 17:18:43 +00:00
|
|
|
|
2015-10-27 03:48:23 +00:00
|
|
|
export CEPH_MON="127.0.0.1:7102" # git grep '\<7102\>' : there must be only one
|
2014-02-13 17:18:43 +00:00
|
|
|
export CEPH_ARGS
|
|
|
|
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
|
2014-10-18 20:15:41 +00:00
|
|
|
CEPH_ARGS+="--mon-host=$CEPH_MON "
|
2014-02-13 17:18:43 +00:00
|
|
|
|
2015-05-16 13:36:25 +00:00
|
|
|
local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
|
|
|
|
for func in $funcs ; do
|
|
|
|
$func $dir || return 1
|
2014-02-13 17:18:43 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-05-27 10:04:43 +00:00
|
|
|
TEST_POOL=rbd
|
|
|
|
|
2014-02-13 17:18:43 +00:00
|
|
|
function TEST_osd_pool_get_set() {
|
2015-05-16 13:36:25 +00:00
|
|
|
local dir=$1
|
|
|
|
|
|
|
|
setup $dir || return 1
|
|
|
|
run_mon $dir a || return 1
|
2017-07-31 23:17:16 +00:00
|
|
|
create_pool $TEST_POOL 8
|
2015-05-16 13:36:25 +00:00
|
|
|
|
|
|
|
local flag
|
2017-01-20 20:14:31 +00:00
|
|
|
for flag in nodelete nopgchange nosizechange write_fadvise_dontneed noscrub nodeep-scrub; do
|
2015-11-27 06:23:55 +00:00
|
|
|
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
|
2015-01-19 14:41:05 +00:00
|
|
|
# check that setting false twice does not toggle to true (bug)
|
2015-11-27 06:23:55 +00:00
|
|
|
! 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
|
2015-01-19 14:41:05 +00:00
|
|
|
# cleanup
|
2015-11-27 06:23:55 +00:00
|
|
|
ceph osd pool set $TEST_POOL $flag 0 || return 1
|
2015-01-19 14:41:05 +00:00
|
|
|
done
|
2015-01-13 03:47:46 +00:00
|
|
|
|
2015-11-27 06:23:55 +00:00
|
|
|
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}')
|
2018-02-23 05:33:00 +00:00
|
|
|
local expected_min_size=$(expr $size - $size / 2)
|
|
|
|
if [ $min_size -ne $expected_min_size ]; then
|
|
|
|
echo "default min_size is wrong: expected $expected_min_size, got $min_size"
|
|
|
|
return 1
|
|
|
|
fi
|
2015-09-29 06:35:32 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-01-13 03:47:46 +00:00
|
|
|
#replicated pool size restrict in 1 and 10
|
2015-11-27 06:23:55 +00:00
|
|
|
! ceph osd pool set $TEST_POOL 11 || return 1
|
2015-01-13 03:47:46 +00:00
|
|
|
#replicated pool min_size must be between in 1 and size
|
2015-11-27 06:23:55 +00:00
|
|
|
! ceph osd pool set $TEST_POOL min_size $(expr $size + 1) || return 1
|
|
|
|
! ceph osd pool set $TEST_POOL min_size 0 || return 1
|
2015-01-13 03:47:46 +00:00
|
|
|
|
|
|
|
local ecpool=erasepool
|
2017-07-31 23:17:16 +00:00
|
|
|
create_pool $ecpool 12 12 erasure default || return 1
|
2015-01-13 03:47:46 +00:00
|
|
|
#erasue pool size=k+m, min_size=k
|
2015-11-27 06:23:55 +00:00
|
|
|
local size=$(ceph osd pool get $ecpool size|awk '{print $2}')
|
2016-06-09 21:09:58 +00:00
|
|
|
local min_size=$(ceph osd pool get $ecpool min_size|awk '{print $2}')
|
|
|
|
local k=$(expr $min_size - 1) # default min_size=k+1
|
2015-01-13 03:47:46 +00:00
|
|
|
#erasure pool size can't change
|
2015-11-27 06:23:55 +00:00
|
|
|
! ceph osd pool set $ecpool size $(expr $size + 1) || return 1
|
2015-01-13 03:47:46 +00:00
|
|
|
#erasure pool min_size must be between in k and size
|
2015-11-27 06:23:55 +00:00
|
|
|
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
|
2015-01-13 03:47:46 +00:00
|
|
|
|
2015-05-16 13:36:25 +00:00
|
|
|
teardown $dir || return 1
|
2014-02-13 17:18:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-11 02:21:18 +00:00
|
|
|
function TEST_mon_add_to_single_mon() {
|
|
|
|
local dir=$1
|
|
|
|
|
|
|
|
fsid=$(uuidgen)
|
2015-10-27 03:48:23 +00:00
|
|
|
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
|
2015-08-11 02:21:18 +00:00
|
|
|
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
|
2015-08-12 12:59:01 +00:00
|
|
|
timeout 120 ceph -s > /dev/null || return 1
|
2015-08-11 02:21:18 +00:00
|
|
|
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
|
2018-12-06 20:16:48 +00:00
|
|
|
# make sure mon.b get's it's join request in first, then
|
|
|
|
sleep 2
|
2015-08-11 02:21:18 +00:00
|
|
|
# wait for the quorum
|
2015-08-12 12:59:01 +00:00
|
|
|
timeout 120 ceph -s > /dev/null || return 1
|
2018-12-06 20:16:48 +00:00
|
|
|
ceph mon dump
|
|
|
|
ceph mon dump -f json-pretty
|
2015-08-11 02:21:18 +00:00
|
|
|
local num_mons
|
2017-05-21 08:33:53 +00:00
|
|
|
num_mons=$(ceph mon dump --format=json 2>/dev/null | jq ".mons | length") || return 1
|
2015-08-11 02:21:18 +00:00
|
|
|
[ $num_mons == 2 ] || return 1
|
2015-08-12 12:59:01 +00:00
|
|
|
# no reason to take more than 120 secs to get this submitted
|
|
|
|
timeout 120 ceph mon add b $MONB || return 1
|
2015-08-11 02:21:18 +00:00
|
|
|
teardown $dir || return 1
|
|
|
|
}
|
|
|
|
|
2015-12-07 16:22:02 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-02-14 16:35:01 +00:00
|
|
|
function TEST_mon_features() {
|
|
|
|
local dir=$1
|
|
|
|
setup $dir || return 1
|
|
|
|
|
|
|
|
fsid=$(uuidgen)
|
|
|
|
MONA=127.0.0.1:7127 # git grep '\<7127\>' ; there must be only one
|
|
|
|
MONB=127.0.0.1:7128 # git grep '\<7128\>' ; there must be only one
|
|
|
|
MONC=127.0.0.1:7129 # git grep '\<7129\>' ; there must be only one
|
|
|
|
CEPH_ARGS_orig=$CEPH_ARGS
|
|
|
|
CEPH_ARGS="--fsid=$fsid --auth-supported=none "
|
|
|
|
CEPH_ARGS+="--mon-initial-members=a,b,c "
|
|
|
|
CEPH_ARGS+="--mon-host=$MONA,$MONB,$MONC "
|
2017-06-02 04:11:21 +00:00
|
|
|
CEPH_ARGS+="--mon-debug-no-initial-persistent-features "
|
2018-05-25 22:02:49 +00:00
|
|
|
CEPH_ARGS+="--mon-debug-no-require-nautilus "
|
2017-02-14 16:35:01 +00:00
|
|
|
|
|
|
|
run_mon $dir a --public-addr $MONA || return 1
|
|
|
|
run_mon $dir b --public-addr $MONB || return 1
|
|
|
|
timeout 120 ceph -s > /dev/null || return 1
|
|
|
|
|
|
|
|
# expect monmap to contain 3 monitors (a, b, and c)
|
2019-10-11 14:28:01 +00:00
|
|
|
jqinput="$(ceph quorum_status --format=json 2>/dev/null)"
|
2017-02-14 16:35:01 +00:00
|
|
|
jq_success "$jqinput" '.monmap.mons | length == 3' || return 1
|
|
|
|
# quorum contains two monitors
|
|
|
|
jq_success "$jqinput" '.quorum | length == 2' || return 1
|
2018-05-25 22:02:49 +00:00
|
|
|
# quorum's monitor features contain kraken, luminous, mimic, and nautilus
|
2017-02-14 16:35:01 +00:00
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "kraken")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "kraken" || return 1
|
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "luminous")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "luminous" || return 1
|
2017-09-05 21:57:22 +00:00
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "mimic")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "mimic" || return 1
|
2018-05-25 22:02:49 +00:00
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "nautilus")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
|
2017-02-14 16:35:01 +00:00
|
|
|
|
|
|
|
# monmap must have no persistent features set, because we
|
|
|
|
# don't currently have a quorum made out of all the monitors
|
|
|
|
# in the monmap.
|
|
|
|
jqfilter='.monmap.features.persistent | length == 0'
|
|
|
|
jq_success "$jqinput" "$jqfilter" || return 1
|
|
|
|
|
|
|
|
# nor do we have any optional features, for that matter.
|
|
|
|
jqfilter='.monmap.features.optional | length == 0'
|
|
|
|
jq_success "$jqinput" "$jqfilter" || return 1
|
|
|
|
|
2017-06-22 19:04:36 +00:00
|
|
|
# validate 'mon feature ls'
|
2017-02-14 16:35:01 +00:00
|
|
|
|
2017-06-22 19:04:36 +00:00
|
|
|
jqinput="$(ceph mon feature ls --format=json 2>/dev/null)"
|
2018-05-25 22:02:49 +00:00
|
|
|
# k l m n are supported
|
2017-02-14 16:35:01 +00:00
|
|
|
jqfilter='.all.supported[] | select(. == "kraken")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "kraken" || return 1
|
|
|
|
jqfilter='.all.supported[] | select(. == "luminous")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "luminous" || return 1
|
2017-09-05 21:57:22 +00:00
|
|
|
jqfilter='.all.supported[] | select(. == "mimic")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "mimic" || return 1
|
2018-05-25 22:02:49 +00:00
|
|
|
jqfilter='.all.supported[] | select(. == "nautilus")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
|
2017-02-14 16:35:01 +00:00
|
|
|
|
|
|
|
# start third monitor
|
|
|
|
run_mon $dir c --public-addr $MONC || return 1
|
|
|
|
|
|
|
|
wait_for_quorum 300 3 || return 1
|
|
|
|
|
|
|
|
timeout 300 ceph -s > /dev/null || return 1
|
|
|
|
|
2019-10-11 14:28:01 +00:00
|
|
|
jqinput="$(ceph quorum_status --format=json 2>/dev/null)"
|
2017-02-14 16:35:01 +00:00
|
|
|
# expect quorum to have all three monitors
|
|
|
|
jqfilter='.quorum | length == 3'
|
|
|
|
jq_success "$jqinput" "$jqfilter" || return 1
|
2017-09-05 21:57:22 +00:00
|
|
|
# quorum's monitor features contain k and l and m
|
2017-02-14 16:35:01 +00:00
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "kraken")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "kraken" || return 1
|
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "luminous")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "luminous" || return 1
|
2017-09-05 21:57:22 +00:00
|
|
|
jqfilter='.features.quorum_mon[]|select(. == "mimic")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "mimic" || return 1
|
2017-02-14 16:35:01 +00:00
|
|
|
|
2017-09-05 21:57:22 +00:00
|
|
|
# monmap must have not all k l m persistent
|
2017-02-14 16:35:01 +00:00
|
|
|
# features set.
|
2019-03-22 22:29:18 +00:00
|
|
|
jqfilter='.monmap.features.persistent | length == 6'
|
2017-02-14 16:35:01 +00:00
|
|
|
jq_success "$jqinput" "$jqfilter" || return 1
|
|
|
|
jqfilter='.monmap.features.persistent[]|select(. == "kraken")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "kraken" || return 1
|
|
|
|
jqfilter='.monmap.features.persistent[]|select(. == "luminous")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "luminous" || return 1
|
2017-09-05 21:57:22 +00:00
|
|
|
jqfilter='.monmap.features.persistent[]|select(. == "mimic")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "mimic" || return 1
|
2018-04-10 04:26:53 +00:00
|
|
|
jqfilter='.monmap.features.persistent[]|select(. == "osdmap-prune")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "osdmap-prune" || return 1
|
2018-05-25 22:02:49 +00:00
|
|
|
jqfilter='.monmap.features.persistent[]|select(. == "nautilus")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "nautilus" || return 1
|
2019-03-22 22:29:18 +00:00
|
|
|
jqfilter='.monmap.features.persistent[]|select(. == "octopus")'
|
|
|
|
jq_success "$jqinput" "$jqfilter" "octopus" || return 1
|
2017-02-14 16:35:01 +00:00
|
|
|
|
|
|
|
CEPH_ARGS=$CEPH_ARGS_orig
|
|
|
|
# that's all folks. thank you for tuning in.
|
|
|
|
teardown $dir || return 1
|
|
|
|
}
|
|
|
|
|
2015-05-16 13:36:25 +00:00
|
|
|
main misc "$@"
|
2014-02-13 17:18:43 +00:00
|
|
|
|
|
|
|
# Local Variables:
|
|
|
|
# compile-command: "cd ../.. ; make -j4 && test/mon/misc.sh"
|
|
|
|
# End:
|