]>
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 | |
29 | ||
30 | ceph osd erasure-code-profile set ec-foo-ssd crush-device-class=ssd m=2 k=2 | |
31 | ceph osd pool create ec-foo 2 erasure ec-foo-ssd | |
32 | ceph osd pool rm ec-foo ec-foo --yes-i-really-really-mean-it | |
33 | ||
7c673cae FG |
34 | ceph osd crush rule ls | grep foo |
35 | ||
36 | ceph osd crush rule rm foo | |
37 | ceph osd crush rule rm foo # idempotent | |
38 | ceph osd crush rule rm bar | |
39 | ||
40 | # can't delete in-use rules, tho: | |
c07f9fc5 | 41 | ceph osd pool create pinning_pool 1 |
31f18b77 | 42 | expect_false ceph osd crush rule rm replicated_rule |
c07f9fc5 | 43 | ceph osd pool rm pinning_pool pinning_pool --yes-i-really-really-mean-it |
7c673cae FG |
44 | |
45 | # build a simple map | |
46 | expect_false ceph osd crush add-bucket foo osd | |
47 | ceph osd crush add-bucket foo root | |
48 | o1=`ceph osd create` | |
49 | o2=`ceph osd create` | |
50 | ceph osd crush add $o1 1 host=host1 root=foo | |
51 | ceph osd crush add $o1 1 host=host1 root=foo # idemptoent | |
52 | ceph osd crush add $o2 1 host=host2 root=foo | |
53 | ceph osd crush add $o2 1 host=host2 root=foo # idempotent | |
54 | ceph osd crush add-bucket bar root | |
55 | ceph osd crush add-bucket bar root # idempotent | |
56 | ceph osd crush link host1 root=bar | |
57 | ceph osd crush link host1 root=bar # idempotent | |
58 | ceph osd crush link host2 root=bar | |
59 | ceph osd crush link host2 root=bar # idempotent | |
60 | ||
61 | ceph osd tree | grep -c osd.$o1 | grep -q 2 | |
62 | ceph osd tree | grep -c host1 | grep -q 2 | |
63 | ceph osd tree | grep -c osd.$o2 | grep -q 2 | |
64 | ceph osd tree | grep -c host2 | grep -q 2 | |
65 | expect_false ceph osd crush rm host1 foo # not empty | |
66 | ceph osd crush unlink host1 foo | |
67 | ceph osd crush unlink host1 foo | |
68 | ceph osd tree | grep -c host1 | grep -q 1 | |
69 | ||
70 | expect_false ceph osd crush rm foo # not empty | |
71 | expect_false ceph osd crush rm bar # not empty | |
72 | ceph osd crush unlink host1 bar | |
73 | ceph osd tree | grep -c host1 | grep -q 1 # now an orphan | |
74 | ceph osd crush rm osd.$o1 host1 | |
75 | ceph osd crush rm host1 | |
76 | ceph osd tree | grep -c host1 | grep -q 0 | |
77 | ||
78 | expect_false ceph osd crush rm bar # not empty | |
79 | ceph osd crush unlink host2 | |
80 | ||
81 | # reference foo and bar with a rule | |
82 | ceph osd crush rule create-simple foo-rule foo host firstn | |
83 | expect_false ceph osd crush rm foo | |
84 | ceph osd crush rule rm foo-rule | |
85 | ||
86 | ceph osd crush rm bar | |
87 | ceph osd crush rm foo | |
88 | ceph osd crush rm osd.$o2 host2 | |
89 | ceph osd crush rm host2 | |
90 | ||
91 | ceph osd crush add-bucket foo host | |
92 | ceph osd crush move foo root=default rack=localrack | |
93 | ||
94 | ceph osd crush create-or-move osd.$o1 1.0 root=default | |
95 | ceph osd crush move osd.$o1 host=foo | |
96 | ceph osd find osd.$o1 | grep host | grep foo | |
97 | ||
98 | ceph osd crush rm osd.$o1 | |
99 | ceph osd crush rm osd.$o2 | |
100 | ||
101 | ceph osd crush rm foo | |
102 | ||
103 | # test reweight | |
104 | o3=`ceph osd create` | |
105 | ceph osd crush add $o3 123 root=default | |
106 | ceph osd tree | grep osd.$o3 | grep 123 | |
107 | ceph osd crush reweight osd.$o3 113 | |
224ce89b | 108 | expect_false ceph osd crush reweight osd.$o3 123456 |
7c673cae FG |
109 | ceph osd tree | grep osd.$o3 | grep 113 |
110 | ceph osd crush rm osd.$o3 | |
111 | ceph osd rm osd.$o3 | |
112 | ||
113 | # test reweight-subtree | |
114 | o4=`ceph osd create` | |
115 | o5=`ceph osd create` | |
116 | ceph osd crush add $o4 123 root=default host=foobaz | |
117 | ceph osd crush add $o5 123 root=default host=foobaz | |
118 | ceph osd tree | grep osd.$o4 | grep 123 | |
119 | ceph osd tree | grep osd.$o5 | grep 123 | |
120 | ceph osd crush reweight-subtree foobaz 155 | |
224ce89b | 121 | expect_false ceph osd crush reweight-subtree foobaz 123456 |
7c673cae FG |
122 | ceph osd tree | grep osd.$o4 | grep 155 |
123 | ceph osd tree | grep osd.$o5 | grep 155 | |
124 | ceph osd crush rm osd.$o4 | |
125 | ceph osd crush rm osd.$o5 | |
126 | ceph osd rm osd.$o4 | |
127 | ceph osd rm osd.$o5 | |
128 | ||
c07f9fc5 FG |
129 | # weight sets |
130 | # make sure we require luminous before testing weight-sets | |
131 | ceph osd set-require-min-compat-client luminous | |
132 | ceph osd crush weight-set dump | |
133 | ceph osd crush weight-set ls | |
134 | expect_false ceph osd crush weight-set reweight fooset osd.0 .9 | |
135 | ceph osd pool create fooset 8 | |
136 | ceph osd pool create barset 8 | |
137 | ceph osd pool set barset size 3 | |
138 | expect_false ceph osd crush weight-set reweight fooset osd.0 .9 | |
139 | ceph osd crush weight-set create fooset flat | |
140 | ceph osd crush weight-set create barset positional | |
141 | ceph osd crush weight-set ls | grep fooset | |
142 | ceph osd crush weight-set ls | grep barset | |
143 | ceph osd crush weight-set dump | |
144 | ceph osd crush weight-set reweight fooset osd.0 .9 | |
145 | expect_false ceph osd crush weight-set reweight fooset osd.0 .9 .9 | |
146 | expect_false ceph osd crush weight-set reweight barset osd.0 .9 | |
147 | ceph osd crush weight-set reweight barset osd.0 .9 .9 .9 | |
148 | ceph osd crush weight-set ls | grep -c fooset | grep -q 1 | |
149 | ceph osd crush weight-set rm fooset | |
150 | ceph osd crush weight-set ls | grep -c fooset | grep -q 0 | |
151 | ceph osd crush weight-set ls | grep barset | |
152 | ceph osd crush weight-set rm barset | |
153 | ceph osd crush weight-set ls | grep -c barset | grep -q 0 | |
154 | ceph osd crush weight-set create-compat | |
155 | ceph osd crush weight-set ls | grep '(compat)' | |
156 | ceph osd crush weight-set rm-compat | |
157 | ||
7c673cae | 158 | echo OK |