]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/mon/crush_ops.sh
11891480a9053a24fbb29edb0450dbb8bff08b8e
[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 ceph osd crush rule ls | grep foo
23
24 ceph osd crush rule rm foo
25 ceph osd crush rule rm foo # idempotent
26 ceph osd crush rule rm bar
27
28 # can't delete in-use rules, tho:
29 expect_false ceph osd crush rule rm replicated_rule
30
31 # build a simple map
32 expect_false ceph osd crush add-bucket foo osd
33 ceph osd crush add-bucket foo root
34 o1=`ceph osd create`
35 o2=`ceph osd create`
36 ceph osd crush add $o1 1 host=host1 root=foo
37 ceph osd crush add $o1 1 host=host1 root=foo # idemptoent
38 ceph osd crush add $o2 1 host=host2 root=foo
39 ceph osd crush add $o2 1 host=host2 root=foo # idempotent
40 ceph osd crush add-bucket bar root
41 ceph osd crush add-bucket bar root # idempotent
42 ceph osd crush link host1 root=bar
43 ceph osd crush link host1 root=bar # idempotent
44 ceph osd crush link host2 root=bar
45 ceph osd crush link host2 root=bar # idempotent
46
47 ceph osd tree | grep -c osd.$o1 | grep -q 2
48 ceph osd tree | grep -c host1 | grep -q 2
49 ceph osd tree | grep -c osd.$o2 | grep -q 2
50 ceph osd tree | grep -c host2 | grep -q 2
51 expect_false ceph osd crush rm host1 foo # not empty
52 ceph osd crush unlink host1 foo
53 ceph osd crush unlink host1 foo
54 ceph osd tree | grep -c host1 | grep -q 1
55
56 expect_false ceph osd crush rm foo # not empty
57 expect_false ceph osd crush rm bar # not empty
58 ceph osd crush unlink host1 bar
59 ceph osd tree | grep -c host1 | grep -q 1 # now an orphan
60 ceph osd crush rm osd.$o1 host1
61 ceph osd crush rm host1
62 ceph osd tree | grep -c host1 | grep -q 0
63
64 expect_false ceph osd crush rm bar # not empty
65 ceph osd crush unlink host2
66
67 # reference foo and bar with a rule
68 ceph osd crush rule create-simple foo-rule foo host firstn
69 expect_false ceph osd crush rm foo
70 ceph osd crush rule rm foo-rule
71
72 ceph osd crush rm bar
73 ceph osd crush rm foo
74 ceph osd crush rm osd.$o2 host2
75 ceph osd crush rm host2
76
77 ceph osd crush add-bucket foo host
78 ceph osd crush move foo root=default rack=localrack
79
80 ceph osd crush create-or-move osd.$o1 1.0 root=default
81 ceph osd crush move osd.$o1 host=foo
82 ceph osd find osd.$o1 | grep host | grep foo
83
84 ceph osd crush rm osd.$o1
85 ceph osd crush rm osd.$o2
86
87 ceph osd crush rm foo
88
89 # test reweight
90 o3=`ceph osd create`
91 ceph osd crush add $o3 123 root=default
92 ceph osd tree | grep osd.$o3 | grep 123
93 ceph osd crush reweight osd.$o3 113
94 ceph osd tree | grep osd.$o3 | grep 113
95 ceph osd crush rm osd.$o3
96 ceph osd rm osd.$o3
97
98 # test reweight-subtree
99 o4=`ceph osd create`
100 o5=`ceph osd create`
101 ceph osd crush add $o4 123 root=default host=foobaz
102 ceph osd crush add $o5 123 root=default host=foobaz
103 ceph osd tree | grep osd.$o4 | grep 123
104 ceph osd tree | grep osd.$o5 | grep 123
105 ceph osd crush reweight-subtree foobaz 155
106 ceph osd tree | grep osd.$o4 | grep 155
107 ceph osd tree | grep osd.$o5 | grep 155
108 ceph osd crush rm osd.$o4
109 ceph osd crush rm osd.$o5
110 ceph osd rm osd.$o4
111 ceph osd rm osd.$o5
112
113 echo OK