]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/crush/crush_weights.sh
update sources to v12.1.2
[ceph.git] / ceph / src / test / crush / crush_weights.sh
1 #!/bin/bash
2
3 source $(dirname $0)/../detect-build-env-vars.sh
4
5 read -r -d '' cm <<'EOF'
6 # devices
7 device 0 device0
8 device 1 device1
9 device 2 device2
10 device 3 device3
11 device 4 device4
12 # types
13 type 0 osd
14 type 1 domain
15 type 2 pool
16 # buckets
17 domain root {
18 id -1 # do not change unnecessarily
19 # weight 5.000
20 alg straw2
21 hash 0 # rjenkins1
22 item device0 weight 10.0
23 item device1 weight 10.0
24 item device2 weight 10.0
25 item device3 weight 10.0
26 item device4 weight 1.000
27 }
28 # rules
29 rule data {
30 ruleset 0
31 type replicated
32 min_size 1
33 max_size 10
34 step take root
35 step choose firstn 0 type osd
36 step emit
37 }
38 EOF
39
40 three=($(echo "$cm" | crushtool -c /dev/fd/0 --test --show-utilization \
41 --min-x 1 --max-x 1000000 --num-rep 3 | \
42 grep "device \(0\|4\)" | sed -e 's/^.*stored : \([0-9]\+\).*$/\1/'))
43
44 if test $(echo "scale=5; (10 - ${three[0]}/${three[1]}) < .75" | bc) = 1; then
45 echo 3 replicas weights better distributed than they should be. 1>&2
46 exit 1
47 fi
48
49 one=($(echo "$cm" | crushtool -c /dev/fd/0 --test --show-utilization \
50 --min-x 1 --max-x 1000000 --num-rep 1 | \
51 grep "device \(0\|4\)" | sed -e 's/^.*stored : \([0-9]\+\).*$/\1/'))
52
53 if test $(echo "scale=5; (10 - ${one[0]}/${one[1]}) > .1 || (10 - ${one[0]}/${one[1]}) < -.1" | bc) = 1; then
54 echo 1 replica not distributed as they should be. 1>&2
55 exit 1
56 fi