]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/mon/crush_ops.sh
bump version to 18.2.2-pve1
[ceph.git] / ceph / qa / workunits / mon / crush_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 ceph osd crush dump
12
13 # rules
14 ceph osd crush rule dump
15 ceph osd crush rule ls
16 ceph osd crush rule list
17
18 ceph osd crush rule create-simple foo default host
19 ceph osd crush rule create-simple foo default host
20 ceph osd crush rule create-simple bar default host
21
22 ceph osd crush rm-device-class all
23 ceph osd crush set-device-class ssd osd.0
24 ceph osd crush set-device-class hdd osd.1
25 ceph osd crush rule create-replicated foo-ssd default host ssd
26 ceph osd crush rule create-replicated foo-hdd default host hdd
27 ceph osd crush rule ls-by-class ssd | grep 'foo-ssd'
28 ceph osd crush rule ls-by-class ssd | expect_false grep 'foo-hdd'
29 ceph osd crush rule ls-by-class hdd | grep 'foo-hdd'
30 ceph osd crush rule ls-by-class hdd | expect_false grep 'foo-ssd'
31
32 ceph osd erasure-code-profile set ec-foo-ssd crush-device-class=ssd m=2 k=2
33 ceph osd pool create ec-foo 2 erasure ec-foo-ssd
34 ceph osd pool rm ec-foo ec-foo --yes-i-really-really-mean-it
35
36 ceph osd crush rule ls | grep foo
37
38 ceph osd crush rule rename foo foo-asdf
39 ceph osd crush rule rename foo foo-asdf # idempotent
40 ceph osd crush rule rename bar bar-asdf
41 ceph osd crush rule ls | grep 'foo-asdf'
42 ceph osd crush rule ls | grep 'bar-asdf'
43 ceph osd crush rule rm foo 2>&1 | grep 'does not exist'
44 ceph osd crush rule rm bar 2>&1 | grep 'does not exist'
45 ceph osd crush rule rename foo-asdf foo
46 ceph osd crush rule rename foo-asdf foo # idempotent
47 ceph osd crush rule rename bar-asdf bar
48 ceph osd crush rule ls | expect_false grep 'foo-asdf'
49 ceph osd crush rule ls | expect_false grep 'bar-asdf'
50 ceph osd crush rule rm foo
51 ceph osd crush rule rm foo # idempotent
52 ceph osd crush rule rm bar
53
54 # can't delete in-use rules, tho:
55 ceph osd pool create pinning_pool 1
56 expect_false ceph osd crush rule rm replicated_rule
57 ceph osd pool rm pinning_pool pinning_pool --yes-i-really-really-mean-it
58
59 # build a simple map
60 expect_false ceph osd crush add-bucket foo osd
61 ceph osd crush add-bucket foo root
62 o1=`ceph osd create`
63 o2=`ceph osd create`
64 ceph osd crush add $o1 1 host=host1 root=foo
65 ceph osd crush add $o1 1 host=host1 root=foo # idemptoent
66 ceph osd crush add $o2 1 host=host2 root=foo
67 ceph osd crush add $o2 1 host=host2 root=foo # idempotent
68 ceph osd crush add-bucket bar root
69 ceph osd crush add-bucket bar root # idempotent
70 ceph osd crush link host1 root=bar
71 ceph osd crush link host1 root=bar # idempotent
72 ceph osd crush link host2 root=bar
73 ceph osd crush link host2 root=bar # idempotent
74
75 ceph osd tree | grep -c osd.$o1 | grep -q 2
76 ceph osd tree | grep -c host1 | grep -q 2
77 ceph osd tree | grep -c osd.$o2 | grep -q 2
78 ceph osd tree | grep -c host2 | grep -q 2
79 expect_false ceph osd crush rm host1 foo # not empty
80 ceph osd crush unlink host1 foo
81 ceph osd crush unlink host1 foo
82 ceph osd tree | grep -c host1 | grep -q 1
83
84 expect_false ceph osd crush rm foo # not empty
85 expect_false ceph osd crush rm bar # not empty
86 ceph osd crush unlink host1 bar
87 ceph osd tree | grep -c host1 | grep -q 1 # now an orphan
88 ceph osd crush rm osd.$o1 host1
89 ceph osd crush rm host1
90 ceph osd tree | grep -c host1 | grep -q 0
91 expect_false ceph osd tree-from host1
92 ceph osd tree-from host2
93 expect_false ceph osd tree-from osd.$o2
94
95 expect_false ceph osd crush rm bar # not empty
96 ceph osd crush unlink host2
97
98 ceph osd crush add-bucket host-for-test host root=root-for-test rack=rack-for-test
99 ceph osd tree | grep host-for-test
100 ceph osd tree | grep rack-for-test
101 ceph osd tree | grep root-for-test
102 ceph osd crush rm host-for-test
103 ceph osd crush rm rack-for-test
104 ceph osd crush rm root-for-test
105
106 # reference foo and bar with a rule
107 ceph osd crush rule create-simple foo-rule foo host firstn
108 expect_false ceph osd crush rm foo
109 ceph osd crush rule rm foo-rule
110
111 ceph osd crush rm bar
112 ceph osd crush rm foo
113 ceph osd crush rm osd.$o2 host2
114 ceph osd crush rm host2
115
116 ceph osd crush add-bucket foo host
117 ceph osd crush move foo root=default rack=localrack
118
119 ceph osd crush create-or-move osd.$o1 1.0 root=default
120 ceph osd crush move osd.$o1 host=foo
121 ceph osd find osd.$o1 | grep host | grep foo
122
123 ceph osd crush rm osd.$o1
124 ceph osd crush rm osd.$o2
125
126 ceph osd crush rm foo
127
128 # test reweight
129 o3=`ceph osd create`
130 ceph osd crush add $o3 123 root=default
131 ceph osd tree | grep osd.$o3 | grep 123
132 ceph osd crush reweight osd.$o3 113
133 expect_false ceph osd crush reweight osd.$o3 123456
134 ceph osd tree | grep osd.$o3 | grep 113
135 ceph osd crush rm osd.$o3
136 ceph osd rm osd.$o3
137
138 # test reweight-subtree
139 o4=`ceph osd create`
140 o5=`ceph osd create`
141 ceph osd crush add $o4 123 root=default host=foobaz
142 ceph osd crush add $o5 123 root=default host=foobaz
143 ceph osd tree | grep osd.$o4 | grep 123
144 ceph osd tree | grep osd.$o5 | grep 123
145 ceph osd crush reweight-subtree foobaz 155
146 expect_false ceph osd crush reweight-subtree foobaz 123456
147 ceph osd tree | grep osd.$o4 | grep 155
148 ceph osd tree | grep osd.$o5 | grep 155
149 ceph osd crush rm osd.$o4
150 ceph osd crush rm osd.$o5
151 ceph osd rm osd.$o4
152 ceph osd rm osd.$o5
153
154 # weight sets
155 # make sure we require luminous before testing weight-sets
156 ceph osd set-require-min-compat-client luminous
157 ceph osd crush weight-set dump
158 ceph osd crush weight-set ls
159 expect_false ceph osd crush weight-set reweight fooset osd.0 .9
160 ceph osd pool create fooset 8
161 ceph osd pool create barset 8
162 ceph osd pool set barset size 3
163 expect_false ceph osd crush weight-set reweight fooset osd.0 .9
164 ceph osd crush weight-set create fooset flat
165 ceph osd crush weight-set create barset positional
166 ceph osd crush weight-set ls | grep fooset
167 ceph osd crush weight-set ls | grep barset
168 ceph osd crush weight-set dump
169 ceph osd crush weight-set reweight fooset osd.0 .9
170 expect_false ceph osd crush weight-set reweight fooset osd.0 .9 .9
171 expect_false ceph osd crush weight-set reweight barset osd.0 .9
172 ceph osd crush weight-set reweight barset osd.0 .9 .9 .9
173 ceph osd crush weight-set ls | grep -c fooset | grep -q 1
174 ceph osd crush weight-set rm fooset
175 ceph osd crush weight-set ls | grep -c fooset | grep -q 0
176 ceph osd crush weight-set ls | grep barset
177 ceph osd crush weight-set rm barset
178 ceph osd crush weight-set ls | grep -c barset | grep -q 0
179 ceph osd crush weight-set create-compat
180 ceph osd crush weight-set ls | grep '(compat)'
181 ceph osd crush weight-set rm-compat
182
183 # weight set vs device classes
184 ceph osd pool create cool 2
185 ceph osd pool create cold 2
186 ceph osd pool set cold size 2
187 ceph osd crush weight-set create-compat
188 ceph osd crush weight-set create cool flat
189 ceph osd crush weight-set create cold positional
190 ceph osd crush rm-device-class osd.0
191 ceph osd crush weight-set reweight-compat osd.0 10.5
192 ceph osd crush weight-set reweight cool osd.0 11.5
193 ceph osd crush weight-set reweight cold osd.0 12.5 12.4
194 ceph osd crush set-device-class fish osd.0
195 ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 10\\.
196 ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 11\\.
197 ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 12\\.
198 ceph osd crush rm-device-class osd.0
199 ceph osd crush set-device-class globster osd.0
200 ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 10\\.
201 ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 11\\.
202 ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 12\\.
203 ceph osd crush weight-set reweight-compat osd.0 7.5
204 ceph osd crush weight-set reweight cool osd.0 8.5
205 ceph osd crush weight-set reweight cold osd.0 6.5 6.6
206 ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 7\\.
207 ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 8\\.
208 ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 6\\.
209 ceph osd crush rm-device-class osd.0
210 ceph osd pool rm cool cool --yes-i-really-really-mean-it
211 ceph osd pool rm cold cold --yes-i-really-really-mean-it
212 ceph osd crush weight-set rm-compat
213
214 # weight set vs device classes vs move
215 ceph osd crush weight-set create-compat
216 ceph osd crush add-bucket fooo host
217 ceph osd crush move fooo root=default
218 ceph osd crush add-bucket barr rack
219 ceph osd crush move barr root=default
220 ceph osd crush move fooo rack=barr
221 ceph osd crush rm fooo
222 ceph osd crush rm barr
223 ceph osd crush weight-set rm-compat
224
225 # this sequence would crash at one point
226 ceph osd crush weight-set create-compat
227 ceph osd crush add-bucket r1 rack root=default
228 for f in `seq 1 32`; do
229 ceph osd crush add-bucket h$f host rack=r1
230 done
231 for f in `seq 1 32`; do
232 ceph osd crush rm h$f
233 done
234 ceph osd crush rm r1
235 ceph osd crush weight-set rm-compat
236
237 echo OK