5 function expect_false
()
8 if "$@"; then return 1; else return 0; fi
11 function get_config_value_or_die
()
13 local pool_name config_opt raw val
18 raw
="`$SUDO ceph osd pool get $pool_name $config_opt 2>/dev/null`"
19 if [[ $?
-ne 0 ]]; then
20 echo "error obtaining config opt '$config_opt' from '$pool_name': $raw"
24 raw
=`echo $raw | sed -e 's/[{} "]//g'`
25 val
=`echo $raw | cut -f2 -d:`
31 function expect_config_value
()
33 local pool_name config_opt expected_val val
38 val
=$
(get_config_value_or_die
$pool_name $config_opt)
40 if [[ "$val" != "$expected_val" ]]; then
41 echo "expected '$expected_val', got '$val'"
47 TEST_POOL
=testpool1234
48 ceph osd pool create testpool1234
8 --autoscale-mode off
49 ceph osd pool
set $TEST_POOL pg_num_min
2
50 ceph osd pool get
$TEST_POOL pg_num_min |
grep 2
51 ceph osd pool
set $TEST_POOL pg_num_max
33
52 ceph osd pool get
$TEST_POOL pg_num_max |
grep 33
53 expect_false ceph osd pool
set $TEST_POOL pg_num_min
9
54 expect_false ceph osd pool
set $TEST_POOL pg_num_max
7
55 expect_false ceph osd pool
set $TEST_POOL pg_num
1
56 expect_false ceph osd pool
set $TEST_POOL pg_num
44
57 ceph osd pool
set $TEST_POOL pg_num_min
0
58 expect_false ceph osd pool get
$TEST_POOL pg_num_min
59 ceph osd pool
set $TEST_POOL pg_num_max
0
60 expect_false ceph osd pool get
$TEST_POOL pg_num_max
61 ceph osd pool delete
$TEST_POOL $TEST_POOL --yes-i-really-really-mean-it
63 # note: we need to pass the other args or ceph_argparse.py will take
64 # 'invalid' that is not replicated|erasure and assume it is the next
65 # argument, which is a string.
66 expect_false ceph osd pool create foo
123 123 invalid foo-profile foo-rule
68 ceph osd pool create foo
123 123 replicated
69 ceph osd pool create fooo
123 123 erasure default
70 ceph osd pool create foooo
123
72 ceph osd pool create foo
123 # idempotent
74 ceph osd pool
set foo size
1 --yes-i-really-mean-it
75 expect_config_value
"foo" "min_size" 1
76 ceph osd pool
set foo size
4
77 expect_config_value
"foo" "min_size" 2
78 ceph osd pool
set foo size
10
79 expect_config_value
"foo" "min_size" 5
80 expect_false ceph osd pool
set foo size
0
81 expect_false ceph osd pool
set foo size
20
83 # should fail due to safety interlock
84 expect_false ceph osd pool delete foo
85 expect_false ceph osd pool delete foo foo
86 expect_false ceph osd pool delete foo foo
--force
87 expect_false ceph osd pool delete foo fooo
--yes-i-really-mean-it
88 expect_false ceph osd pool delete foo
--yes-i-really-mean-it foo
90 ceph osd pool delete foooo foooo
--yes-i-really-really-mean-it
91 ceph osd pool delete fooo fooo
--yes-i-really-really-mean-it
92 ceph osd pool delete foo foo
--yes-i-really-really-mean-it
95 ceph osd pool delete foo foo
--yes-i-really-really-mean-it
96 ceph osd pool delete fooo fooo
--yes-i-really-really-mean-it
97 ceph osd pool delete fooo fooo
--yes-i-really-really-mean-it
100 ceph osd pool delete fuggg fuggg
--yes-i-really-really-mean-it