]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/mon/pool_ops.sh
import 15.2.2 octopus source
[ceph.git] / ceph / qa / workunits / mon / pool_ops.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae 2
11fdf7f2 3set -ex
7c673cae
FG
4
5function expect_false()
6{
7 set -x
8 if "$@"; then return 1; else return 0; fi
9}
10
1911f103
TL
11function 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
31function 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
7c673cae
FG
46# note: we need to pass the other args or ceph_argparse.py will take
47# 'invalid' that is not replicated|erasure and assume it is the next
48# argument, which is a string.
49expect_false ceph osd pool create foo 123 123 invalid foo-profile foo-ruleset
50
51ceph osd pool create foo 123 123 replicated
52ceph osd pool create fooo 123 123 erasure default
53ceph osd pool create foooo 123
54
55ceph osd pool create foo 123 # idempotent
56
57ceph osd pool set foo size 1
1911f103 58expect_config_value "foo" "min_size" 1
7c673cae 59ceph osd pool set foo size 4
1911f103 60expect_config_value "foo" "min_size" 2
7c673cae 61ceph osd pool set foo size 10
1911f103 62expect_config_value "foo" "min_size" 5
7c673cae
FG
63expect_false ceph osd pool set foo size 0
64expect_false ceph osd pool set foo size 20
65
eafe8130
TL
66ceph osd pool set foo size 3
67ceph osd getcrushmap -o crush
68crushtool -d crush -o crush.txt
69sed -i 's/max_size 10/max_size 3/' crush.txt
70crushtool -c crush.txt -o crush.new
71ceph osd setcrushmap -i crush.new
72expect_false ceph osd pool set foo size 4
73ceph osd setcrushmap -i crush
74rm -f crush crush.txt crush.new
75
7c673cae
FG
76# should fail due to safety interlock
77expect_false ceph osd pool delete foo
78expect_false ceph osd pool delete foo foo
79expect_false ceph osd pool delete foo foo --force
80expect_false ceph osd pool delete foo fooo --yes-i-really-mean-it
81expect_false ceph osd pool delete foo --yes-i-really-mean-it foo
82
83ceph osd pool delete foooo foooo --yes-i-really-really-mean-it
84ceph osd pool delete fooo fooo --yes-i-really-really-mean-it
85ceph osd pool delete foo foo --yes-i-really-really-mean-it
86
87# idempotent
88ceph osd pool delete foo foo --yes-i-really-really-mean-it
89ceph osd pool delete fooo fooo --yes-i-really-really-mean-it
90ceph osd pool delete fooo fooo --yes-i-really-really-mean-it
91
92# non-existent pool
93ceph osd pool delete fuggg fuggg --yes-i-really-really-mean-it
94
95echo OK
96
97