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