Skip to content

Commit

Permalink
mon: test 'mon feature' cli
Browse files Browse the repository at this point in the history
Signed-off-by: Joao Eduardo Luis <joao@suse.de>
  • Loading branch information
jecluis committed Feb 21, 2017
1 parent ae143c4 commit 77a0f45
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions qa/workunits/cephtool/test.sh
Expand Up @@ -1045,6 +1045,12 @@ function test_mon_mon()
[ -s $TEMP_DIR/monmap.$$ ]
# ceph mon tell
ceph mon_status

# test mon features
ceph mon feature list
ceph mon feature set kraken --yes-i-really-mean-it
expect_false ceph mon feature set abcd
expect_false ceph mon feature set abcd --yes-i-really-mean-it
}

function test_mon_osd()
Expand Down
78 changes: 78 additions & 0 deletions src/test/mon/misc.sh
Expand Up @@ -150,6 +150,84 @@ function TEST_no_segfault_for_bad_keyring() {
teardown $dir || return 1
}

function TEST_mon_features() {
local dir=$1
setup $dir || return 1

fsid=$(uuidgen)
MONA=127.0.0.1:7126 # git grep '\<7126\>' ; there must be only one
MONB=127.0.0.1:7127 # git grep '\<7127\>' ; there must be only one
MONC=127.0.0.1:7128 # git grep '\<7128\>' ; 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 "

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)
jqinput="$(ceph mon_status --format=json 2>/dev/null)"
echo $jqinput | jq -e '.monmap.mons | length == 3' || return 1
# quorum contains two monitors
echo $jqinput | jq -e '.quorum | length == 2' || return 1
# quorum's monitor features contain kraken and luminous
jqfilter='.features.quorum_mon[]|select(. == "kraken")'
echo $jqinput | jq -e "$jqfilter" || return 1
jqfilter='.features.quorum_mon[]|select(. == "luminous")'
echo $jqinput | jq -e "$jqfilter" || return 1

# 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'
echo $jqinput | jq -e "$jqfilter" || return 1

# nor do we have any optional features, for that matter.
jqfilter='.monmap.features.optional | length == 0'
echo $jqinput | jq -e "$jqfilter" || return 1

# validate 'mon feature list'

jqinput="$(ceph mon feature list --format=json 2>/dev/null)"
# 'kraken' and 'luminous' are supported
jqfilter='.all.supported[] | select("kraken")'
echo $jqinput | jq -e "$jqfilter" || return 1
jqfilter='.all.supported[] | select("luminous")'
echo $jqinput | jq -e "$jqfilter" || return 1

# 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

jqinput="$(ceph mon_status --format=json 2>/dev/null)"
# expect quorum to have all three monitors
echo $jqinput | jq -e '.quorum | length == 3' || return 1
# quorum's monitor features contain kraken and luminous
jqfilter='.features.quorum_mon[]|select(. == "kraken")'
echo $jqinput | jq -e "$jqfilter" || return 1
jqfilter='.features.quorum_mon[]|select(. == "luminous")'
echo $jqinput | jq -e "$jqfilter" || return 1

# monmap must have no both 'kraken' and 'luminous' persistent
# features set.
jqfilter='.monmap.features.persistent | length == 2'
echo $jqinput | jq -e "$jqfilter" || return 1
jqfilter='.monmap.features.persistent[]|select(. == "kraken")'
echo $jqinput | jq -e "$jqfilter" || return 1
jqfilter='.monmap.features.persistent[]|select(. == "luminous")'
echo $jqinput | jq -e "$jqfilter" || return 1

CEPH_ARGS=$CEPH_ARGS_orig
# that's all folks. thank you for tuning in.
teardown $dir || return 1
}

main misc "$@"

# Local Variables:
Expand Down

0 comments on commit 77a0f45

Please sign in to comment.