]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/bin/bash -x |
2 | ||
3 | set -e | |
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 | ||
224ce89b WB |
22 | # make sure we're at luminous+ before using crush device classes |
23 | ceph osd require-osd-release luminous | |
d2e6a577 | 24 | ceph osd crush rm-device-class all |
224ce89b WB |
25 | ceph osd crush set-device-class ssd osd.0 |
26 | ceph osd crush set-device-class hdd osd.1 | |
27 | ceph osd crush rule create-replicated foo-ssd default host ssd | |
28 | ceph osd crush rule create-replicated foo-hdd default host hdd | |
b5b8bbf5 FG |
29 | ceph osd crush rule ls-by-class ssd | grep 'foo-ssd' |
30 | ceph osd crush rule ls-by-class ssd | expect_false grep 'foo-hdd' | |
31 | ceph osd crush rule ls-by-class hdd | grep 'foo-hdd' | |
32 | ceph osd crush rule ls-by-class hdd | expect_false grep 'foo-ssd' | |
224ce89b WB |
33 | |
34 | ceph osd erasure-code-profile set ec-foo-ssd crush-device-class=ssd m=2 k=2 | |
35 | ceph osd pool create ec-foo 2 erasure ec-foo-ssd | |
36 | ceph osd pool rm ec-foo ec-foo --yes-i-really-really-mean-it | |
37 | ||
7c673cae FG |
38 | ceph osd crush rule ls | grep foo |
39 | ||
b5b8bbf5 | 40 | ceph osd crush rule rename foo foo-asdf |
181888fb | 41 | ceph osd crush rule rename foo foo-asdf # idempotent |
b5b8bbf5 FG |
42 | ceph osd crush rule rename bar bar-asdf |
43 | ceph osd crush rule ls | grep 'foo-asdf' | |
44 | ceph osd crush rule ls | grep 'bar-asdf' | |
45 | ceph osd crush rule rm foo 2>&1 | grep 'does not exist' | |
46 | ceph osd crush rule rm bar 2>&1 | grep 'does not exist' | |
47 | ceph osd crush rule rename foo-asdf foo | |
181888fb | 48 | ceph osd crush rule rename foo-asdf foo # idempotent |
b5b8bbf5 FG |
49 | ceph osd crush rule rename bar-asdf bar |
50 | ceph osd crush rule ls | expect_false grep 'foo-asdf' | |
51 | ceph osd crush rule ls | expect_false grep 'bar-asdf' | |
7c673cae FG |
52 | ceph osd crush rule rm foo |
53 | ceph osd crush rule rm foo # idempotent | |
54 | ceph osd crush rule rm bar | |
55 | ||
56 | # can't delete in-use rules, tho: | |
c07f9fc5 | 57 | ceph osd pool create pinning_pool 1 |
31f18b77 | 58 | expect_false ceph osd crush rule rm replicated_rule |
c07f9fc5 | 59 | ceph osd pool rm pinning_pool pinning_pool --yes-i-really-really-mean-it |
7c673cae FG |
60 | |
61 | # build a simple map | |
62 | expect_false ceph osd crush add-bucket foo osd | |
63 | ceph osd crush add-bucket foo root | |
64 | o1=`ceph osd create` | |
65 | o2=`ceph osd create` | |
66 | ceph osd crush add $o1 1 host=host1 root=foo | |
67 | ceph osd crush add $o1 1 host=host1 root=foo # idemptoent | |
68 | ceph osd crush add $o2 1 host=host2 root=foo | |
69 | ceph osd crush add $o2 1 host=host2 root=foo # idempotent | |
70 | ceph osd crush add-bucket bar root | |
71 | ceph osd crush add-bucket bar root # idempotent | |
72 | ceph osd crush link host1 root=bar | |
73 | ceph osd crush link host1 root=bar # idempotent | |
74 | ceph osd crush link host2 root=bar | |
75 | ceph osd crush link host2 root=bar # idempotent | |
76 | ||
77 | ceph osd tree | grep -c osd.$o1 | grep -q 2 | |
78 | ceph osd tree | grep -c host1 | grep -q 2 | |
79 | ceph osd tree | grep -c osd.$o2 | grep -q 2 | |
80 | ceph osd tree | grep -c host2 | grep -q 2 | |
81 | expect_false ceph osd crush rm host1 foo # not empty | |
82 | ceph osd crush unlink host1 foo | |
83 | ceph osd crush unlink host1 foo | |
84 | ceph osd tree | grep -c host1 | grep -q 1 | |
85 | ||
86 | expect_false ceph osd crush rm foo # not empty | |
87 | expect_false ceph osd crush rm bar # not empty | |
88 | ceph osd crush unlink host1 bar | |
89 | ceph osd tree | grep -c host1 | grep -q 1 # now an orphan | |
90 | ceph osd crush rm osd.$o1 host1 | |
91 | ceph osd crush rm host1 | |
92 | ceph osd tree | grep -c host1 | grep -q 0 | |
93 | ||
94 | expect_false ceph osd crush rm bar # not empty | |
95 | ceph osd crush unlink host2 | |
96 | ||
97 | # reference foo and bar with a rule | |
98 | ceph osd crush rule create-simple foo-rule foo host firstn | |
99 | expect_false ceph osd crush rm foo | |
100 | ceph osd crush rule rm foo-rule | |
101 | ||
102 | ceph osd crush rm bar | |
103 | ceph osd crush rm foo | |
104 | ceph osd crush rm osd.$o2 host2 | |
105 | ceph osd crush rm host2 | |
106 | ||
107 | ceph osd crush add-bucket foo host | |
108 | ceph osd crush move foo root=default rack=localrack | |
109 | ||
110 | ceph osd crush create-or-move osd.$o1 1.0 root=default | |
111 | ceph osd crush move osd.$o1 host=foo | |
112 | ceph osd find osd.$o1 | grep host | grep foo | |
113 | ||
114 | ceph osd crush rm osd.$o1 | |
115 | ceph osd crush rm osd.$o2 | |
116 | ||
117 | ceph osd crush rm foo | |
118 | ||
119 | # test reweight | |
120 | o3=`ceph osd create` | |
121 | ceph osd crush add $o3 123 root=default | |
122 | ceph osd tree | grep osd.$o3 | grep 123 | |
123 | ceph osd crush reweight osd.$o3 113 | |
224ce89b | 124 | expect_false ceph osd crush reweight osd.$o3 123456 |
7c673cae FG |
125 | ceph osd tree | grep osd.$o3 | grep 113 |
126 | ceph osd crush rm osd.$o3 | |
127 | ceph osd rm osd.$o3 | |
128 | ||
129 | # test reweight-subtree | |
130 | o4=`ceph osd create` | |
131 | o5=`ceph osd create` | |
132 | ceph osd crush add $o4 123 root=default host=foobaz | |
133 | ceph osd crush add $o5 123 root=default host=foobaz | |
134 | ceph osd tree | grep osd.$o4 | grep 123 | |
135 | ceph osd tree | grep osd.$o5 | grep 123 | |
136 | ceph osd crush reweight-subtree foobaz 155 | |
224ce89b | 137 | expect_false ceph osd crush reweight-subtree foobaz 123456 |
7c673cae FG |
138 | ceph osd tree | grep osd.$o4 | grep 155 |
139 | ceph osd tree | grep osd.$o5 | grep 155 | |
140 | ceph osd crush rm osd.$o4 | |
141 | ceph osd crush rm osd.$o5 | |
142 | ceph osd rm osd.$o4 | |
143 | ceph osd rm osd.$o5 | |
144 | ||
c07f9fc5 FG |
145 | # weight sets |
146 | # make sure we require luminous before testing weight-sets | |
147 | ceph osd set-require-min-compat-client luminous | |
148 | ceph osd crush weight-set dump | |
149 | ceph osd crush weight-set ls | |
150 | expect_false ceph osd crush weight-set reweight fooset osd.0 .9 | |
151 | ceph osd pool create fooset 8 | |
152 | ceph osd pool create barset 8 | |
153 | ceph osd pool set barset size 3 | |
154 | expect_false ceph osd crush weight-set reweight fooset osd.0 .9 | |
155 | ceph osd crush weight-set create fooset flat | |
156 | ceph osd crush weight-set create barset positional | |
157 | ceph osd crush weight-set ls | grep fooset | |
158 | ceph osd crush weight-set ls | grep barset | |
159 | ceph osd crush weight-set dump | |
160 | ceph osd crush weight-set reweight fooset osd.0 .9 | |
161 | expect_false ceph osd crush weight-set reweight fooset osd.0 .9 .9 | |
162 | expect_false ceph osd crush weight-set reweight barset osd.0 .9 | |
163 | ceph osd crush weight-set reweight barset osd.0 .9 .9 .9 | |
164 | ceph osd crush weight-set ls | grep -c fooset | grep -q 1 | |
165 | ceph osd crush weight-set rm fooset | |
166 | ceph osd crush weight-set ls | grep -c fooset | grep -q 0 | |
167 | ceph osd crush weight-set ls | grep barset | |
168 | ceph osd crush weight-set rm barset | |
169 | ceph osd crush weight-set ls | grep -c barset | grep -q 0 | |
170 | ceph osd crush weight-set create-compat | |
171 | ceph osd crush weight-set ls | grep '(compat)' | |
172 | ceph osd crush weight-set rm-compat | |
173 | ||
35e4c445 FG |
174 | # weight set vs device classes |
175 | ceph osd pool create cool 2 | |
176 | ceph osd pool create cold 2 | |
177 | ceph osd pool set cold size 2 | |
178 | ceph osd crush weight-set create-compat | |
179 | ceph osd crush weight-set create cool flat | |
180 | ceph osd crush weight-set create cold positional | |
181 | ceph osd crush rm-device-class osd.0 | |
182 | ceph osd crush weight-set reweight-compat osd.0 10.5 | |
183 | ceph osd crush weight-set reweight cool osd.0 11.5 | |
184 | ceph osd crush weight-set reweight cold osd.0 12.5 12.4 | |
185 | ceph osd crush set-device-class fish osd.0 | |
186 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 10\\. | |
187 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 11\\. | |
188 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 12\\. | |
189 | ceph osd crush rm-device-class osd.0 | |
190 | ceph osd crush set-device-class globster osd.0 | |
191 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 10\\. | |
192 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 11\\. | |
193 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 12\\. | |
194 | ceph osd crush weight-set reweight-compat osd.0 7.5 | |
195 | ceph osd crush weight-set reweight cool osd.0 8.5 | |
196 | ceph osd crush weight-set reweight cold osd.0 6.5 6.6 | |
197 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 7\\. | |
198 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 8\\. | |
199 | ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 6\\. | |
200 | ceph osd crush rm-device-class osd.0 | |
201 | ceph osd pool rm cool cool --yes-i-really-really-mean-it | |
202 | ceph osd pool rm cold cold --yes-i-really-really-mean-it | |
203 | ceph osd crush weight-set rm-compat | |
204 | ||
7c673cae | 205 | echo OK |