]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/mon/crush_ops.sh
update sources to v12.1.1
[ceph.git] / ceph / qa / workunits / mon / crush_ops.sh
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
22 # make sure we're at luminous+ before using crush device classes
23 ceph osd require-osd-release luminous
24 ceph osd crush class create ssd
25 ceph osd crush class create hdd
26 ceph osd crush set-device-class ssd osd.0
27 ceph osd crush set-device-class hdd osd.1
28 ceph osd crush rule create-replicated foo-ssd default host ssd
29 ceph osd crush rule create-replicated foo-hdd default host hdd
30
31 ceph osd erasure-code-profile set ec-foo-ssd crush-device-class=ssd m=2 k=2
32 ceph osd pool create ec-foo 2 erasure ec-foo-ssd
33 ceph osd pool rm ec-foo ec-foo --yes-i-really-really-mean-it
34
35 ceph osd crush rule ls | grep foo
36
37 ceph osd crush rule rm foo
38 ceph osd crush rule rm foo # idempotent
39 ceph osd crush rule rm bar
40
41 # can't delete in-use rules, tho:
42 expect_false ceph osd crush rule rm replicated_rule
43
44 # build a simple map
45 expect_false ceph osd crush add-bucket foo osd
46 ceph osd crush add-bucket foo root
47 o1=`ceph osd create`
48 o2=`ceph osd create`
49 ceph osd crush add $o1 1 host=host1 root=foo
50 ceph osd crush add $o1 1 host=host1 root=foo # idemptoent
51 ceph osd crush add $o2 1 host=host2 root=foo
52 ceph osd crush add $o2 1 host=host2 root=foo # idempotent
53 ceph osd crush add-bucket bar root
54 ceph osd crush add-bucket bar root # idempotent
55 ceph osd crush link host1 root=bar
56 ceph osd crush link host1 root=bar # idempotent
57 ceph osd crush link host2 root=bar
58 ceph osd crush link host2 root=bar # idempotent
59
60 ceph osd tree | grep -c osd.$o1 | grep -q 2
61 ceph osd tree | grep -c host1 | grep -q 2
62 ceph osd tree | grep -c osd.$o2 | grep -q 2
63 ceph osd tree | grep -c host2 | grep -q 2
64 expect_false ceph osd crush rm host1 foo # not empty
65 ceph osd crush unlink host1 foo
66 ceph osd crush unlink host1 foo
67 ceph osd tree | grep -c host1 | grep -q 1
68
69 expect_false ceph osd crush rm foo # not empty
70 expect_false ceph osd crush rm bar # not empty
71 ceph osd crush unlink host1 bar
72 ceph osd tree | grep -c host1 | grep -q 1 # now an orphan
73 ceph osd crush rm osd.$o1 host1
74 ceph osd crush rm host1
75 ceph osd tree | grep -c host1 | grep -q 0
76
77 expect_false ceph osd crush rm bar # not empty
78 ceph osd crush unlink host2
79
80 # reference foo and bar with a rule
81 ceph osd crush rule create-simple foo-rule foo host firstn
82 expect_false ceph osd crush rm foo
83 ceph osd crush rule rm foo-rule
84
85 ceph osd crush rm bar
86 ceph osd crush rm foo
87 ceph osd crush rm osd.$o2 host2
88 ceph osd crush rm host2
89
90 ceph osd crush add-bucket foo host
91 ceph osd crush move foo root=default rack=localrack
92
93 ceph osd crush create-or-move osd.$o1 1.0 root=default
94 ceph osd crush move osd.$o1 host=foo
95 ceph osd find osd.$o1 | grep host | grep foo
96
97 ceph osd crush rm osd.$o1
98 ceph osd crush rm osd.$o2
99
100 ceph osd crush rm foo
101
102 # test reweight
103 o3=`ceph osd create`
104 ceph osd crush add $o3 123 root=default
105 ceph osd tree | grep osd.$o3 | grep 123
106 ceph osd crush reweight osd.$o3 113
107 expect_false ceph osd crush reweight osd.$o3 123456
108 ceph osd tree | grep osd.$o3 | grep 113
109 ceph osd crush rm osd.$o3
110 ceph osd rm osd.$o3
111
112 # test reweight-subtree
113 o4=`ceph osd create`
114 o5=`ceph osd create`
115 ceph osd crush add $o4 123 root=default host=foobaz
116 ceph osd crush add $o5 123 root=default host=foobaz
117 ceph osd tree | grep osd.$o4 | grep 123
118 ceph osd tree | grep osd.$o5 | grep 123
119 ceph osd crush reweight-subtree foobaz 155
120 expect_false ceph osd crush reweight-subtree foobaz 123456
121 ceph osd tree | grep osd.$o4 | grep 155
122 ceph osd tree | grep osd.$o5 | grep 155
123 ceph osd crush rm osd.$o4
124 ceph osd crush rm osd.$o5
125 ceph osd rm osd.$o4
126 ceph osd rm osd.$o5
127
128 echo OK