]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/mon/pool_ops.sh
import quincy beta 17.1.0
[ceph.git] / ceph / qa / workunits / mon / pool_ops.sh
1 #!/usr/bin/env bash
2
3 set -ex
4
5 function expect_false()
6 {
7 set -x
8 if "$@"; then return 1; else return 0; fi
9 }
10
11 function get_config_value_or_die()
12 {
13 local pool_name config_opt raw val
14
15 pool_name=$1
16 config_opt=$2
17
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"
21 exit 1
22 fi
23
24 raw=`echo $raw | sed -e 's/[{} "]//g'`
25 val=`echo $raw | cut -f2 -d:`
26
27 echo "$val"
28 return 0
29 }
30
31 function expect_config_value()
32 {
33 local pool_name config_opt expected_val val
34 pool_name=$1
35 config_opt=$2
36 expected_val=$3
37
38 val=$(get_config_value_or_die $pool_name $config_opt)
39
40 if [[ "$val" != "$expected_val" ]]; then
41 echo "expected '$expected_val', got '$val'"
42 exit 1
43 fi
44 }
45
46 # pg_num min/max
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
62
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
67
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
71
72 ceph osd pool create foo 123 # idempotent
73
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
82
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
89
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
93
94 # idempotent
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
98
99 # non-existent pool
100 ceph osd pool delete fuggg fuggg --yes-i-really-really-mean-it
101
102 echo OK
103
104