2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2012-07-20 04:56:56 +00:00
|
|
|
|
2017-07-20 22:26:42 +00:00
|
|
|
set -ex
|
2012-07-20 04:56:56 +00:00
|
|
|
|
2014-03-27 19:44:31 +00:00
|
|
|
function expect_false()
|
|
|
|
{
|
|
|
|
set -x
|
|
|
|
if "$@"; then return 1; else return 0; fi
|
|
|
|
}
|
|
|
|
|
2020-04-02 07:01:16 +00:00
|
|
|
function get_config_value_or_die()
|
|
|
|
{
|
|
|
|
local pool_name config_opt raw val
|
|
|
|
|
|
|
|
pool_name=$1
|
|
|
|
config_opt=$2
|
|
|
|
|
|
|
|
raw="`$SUDO ceph osd pool get $pool_name $config_opt 2>/dev/null`"
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
echo "error obtaining config opt '$config_opt' from '$pool_name': $raw"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
raw=`echo $raw | sed -e 's/[{} "]//g'`
|
|
|
|
val=`echo $raw | cut -f2 -d:`
|
|
|
|
|
|
|
|
echo "$val"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
function expect_config_value()
|
|
|
|
{
|
|
|
|
local pool_name config_opt expected_val val
|
|
|
|
pool_name=$1
|
|
|
|
config_opt=$2
|
|
|
|
expected_val=$3
|
|
|
|
|
|
|
|
val=$(get_config_value_or_die $pool_name $config_opt)
|
|
|
|
|
|
|
|
if [[ "$val" != "$expected_val" ]]; then
|
|
|
|
echo "expected '$expected_val', got '$val'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-11-22 21:09:00 +00:00
|
|
|
# pg_num min/max
|
|
|
|
TEST_POOL=testpool1234
|
|
|
|
ceph osd pool create testpool1234 8 --autoscale-mode off
|
|
|
|
ceph osd pool set $TEST_POOL pg_num_min 2
|
|
|
|
ceph osd pool get $TEST_POOL pg_num_min | grep 2
|
|
|
|
ceph osd pool set $TEST_POOL pg_num_max 33
|
|
|
|
ceph osd pool get $TEST_POOL pg_num_max | grep 33
|
2021-11-22 23:46:13 +00:00
|
|
|
expect_false ceph osd pool set $TEST_POOL pg_num_min 9
|
|
|
|
expect_false ceph osd pool set $TEST_POOL pg_num_max 7
|
|
|
|
expect_false ceph osd pool set $TEST_POOL pg_num 1
|
|
|
|
expect_false ceph osd pool set $TEST_POOL pg_num 44
|
2021-11-22 21:09:00 +00:00
|
|
|
ceph osd pool set $TEST_POOL pg_num_min 0
|
|
|
|
expect_false ceph osd pool get $TEST_POOL pg_num_min
|
|
|
|
ceph osd pool set $TEST_POOL pg_num_max 0
|
|
|
|
expect_false ceph osd pool get $TEST_POOL pg_num_max
|
|
|
|
ceph osd pool delete $TEST_POOL $TEST_POOL --yes-i-really-really-mean-it
|
|
|
|
|
2014-03-27 19:57:40 +00:00
|
|
|
# note: we need to pass the other args or ceph_argparse.py will take
|
|
|
|
# 'invalid' that is not replicated|erasure and assume it is the next
|
|
|
|
# argument, which is a string.
|
2021-07-07 14:32:11 +00:00
|
|
|
expect_false ceph osd pool create foo 123 123 invalid foo-profile foo-rule
|
2014-03-27 19:57:40 +00:00
|
|
|
|
|
|
|
ceph osd pool create foo 123 123 replicated
|
|
|
|
ceph osd pool create fooo 123 123 erasure default
|
|
|
|
ceph osd pool create foooo 123
|
2012-07-20 04:56:56 +00:00
|
|
|
|
2012-11-12 20:01:07 +00:00
|
|
|
ceph osd pool create foo 123 # idempotent
|
2012-07-20 04:56:56 +00:00
|
|
|
|
2020-02-12 14:38:29 +00:00
|
|
|
ceph osd pool set foo size 1 --yes-i-really-mean-it
|
2020-04-02 07:01:16 +00:00
|
|
|
expect_config_value "foo" "min_size" 1
|
2013-02-19 23:54:52 +00:00
|
|
|
ceph osd pool set foo size 4
|
2020-04-02 07:01:16 +00:00
|
|
|
expect_config_value "foo" "min_size" 2
|
2013-02-19 23:54:52 +00:00
|
|
|
ceph osd pool set foo size 10
|
2020-04-02 07:01:16 +00:00
|
|
|
expect_config_value "foo" "min_size" 5
|
2014-03-27 19:44:31 +00:00
|
|
|
expect_false ceph osd pool set foo size 0
|
|
|
|
expect_false ceph osd pool set foo size 20
|
2013-02-19 23:54:52 +00:00
|
|
|
|
2013-01-28 22:20:42 +00:00
|
|
|
# should fail due to safety interlock
|
2014-03-27 19:44:31 +00:00
|
|
|
expect_false ceph osd pool delete foo
|
|
|
|
expect_false ceph osd pool delete foo foo
|
|
|
|
expect_false ceph osd pool delete foo foo --force
|
|
|
|
expect_false ceph osd pool delete foo fooo --yes-i-really-mean-it
|
|
|
|
expect_false ceph osd pool delete foo --yes-i-really-mean-it foo
|
2013-01-28 22:20:42 +00:00
|
|
|
|
2014-03-27 19:57:40 +00:00
|
|
|
ceph osd pool delete foooo foooo --yes-i-really-really-mean-it
|
2013-01-28 22:20:42 +00:00
|
|
|
ceph osd pool delete fooo fooo --yes-i-really-really-mean-it
|
2013-01-26 21:45:12 +00:00
|
|
|
ceph osd pool delete foo foo --yes-i-really-really-mean-it
|
2013-01-28 22:20:42 +00:00
|
|
|
|
|
|
|
# idempotent
|
2013-01-26 21:45:12 +00:00
|
|
|
ceph osd pool delete foo foo --yes-i-really-really-mean-it
|
2013-01-28 22:20:42 +00:00
|
|
|
ceph osd pool delete fooo fooo --yes-i-really-really-mean-it
|
|
|
|
ceph osd pool delete fooo fooo --yes-i-really-really-mean-it
|
2012-07-20 04:56:56 +00:00
|
|
|
|
2013-01-28 22:20:42 +00:00
|
|
|
# non-existent pool
|
2013-02-20 16:44:03 +00:00
|
|
|
ceph osd pool delete fuggg fuggg --yes-i-really-really-mean-it
|
2012-07-20 04:56:56 +00:00
|
|
|
|
|
|
|
echo OK
|
|
|
|
|
|
|
|
|