]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: verify weights is influenced by the number of replicas 13083/head
authorLoic Dachary <ldachary@redhat.com>
Tue, 24 Jan 2017 12:08:32 +0000 (13:08 +0100)
committerLoic Dachary <ldachary@redhat.com>
Tue, 24 Jan 2017 14:14:45 +0000 (15:14 +0100)
Refs: http://tracker.ceph.com/issues/15653

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/crush/CMakeLists.txt
src/test/crush/crush_weights.sh [new file with mode: 0755]

index fc96c9a271c375618740f98a4dd854227d66213f..f59237775b39d951553dd820b008ef3ccb89dbd8 100644 (file)
@@ -12,3 +12,5 @@ add_executable(unittest_crush
   )
 add_ceph_unittest(unittest_crush ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest_crush)
 target_link_libraries(unittest_crush global m ${BLKID_LIBRARIES})
+
+add_ceph_test(crush_weights.sh ${CMAKE_CURRENT_SOURCE_DIR}/crush_weights.sh)
diff --git a/src/test/crush/crush_weights.sh b/src/test/crush/crush_weights.sh
new file mode 100755 (executable)
index 0000000..52c0f20
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+source $(dirname $0)/../detect-build-env-vars.sh
+source $CEPH_ROOT/qa/workunits/ceph-helpers.sh
+
+read -r -d '' cm <<'EOF'
+# devices
+device 0 device0
+device 1 device1
+device 2 device2
+device 3 device3
+device 4 device4
+# types
+type 0 osd
+type 1 domain
+type 2 pool
+# buckets
+domain root {
+    id -1        # do not change unnecessarily
+    # weight 5.000
+    alg straw2
+    hash 0    # rjenkins1
+    item device0 weight 10.0
+    item device1 weight 10.0
+    item device2 weight 10.0
+    item device3 weight 10.0
+    item device4 weight 1.000
+}
+# rules
+rule data {
+    ruleset 0
+    type replicated
+    min_size 1
+    max_size 10
+    step take root
+    step choose firstn 0 type osd
+    step emit
+}
+EOF
+
+three=($(echo "$cm" | crushtool -c /dev/fd/0 --test --show-utilization \
+                              --min-x 1 --max-x 1000000 --num-rep 3 | \
+  grep "device \(0\|4\)" | sed -e 's/^.*stored : \([0-9]\+\).*$/\1/'))
+
+if test $(echo "scale=5; (10 - ${three[0]}/${three[1]}) < .75" | bc) = 1; then
+    echo 3 replicas weights better distributed than they should be. 1>&2
+    exit 1
+fi
+
+one=($(echo "$cm" | crushtool -c /dev/fd/0 --test --show-utilization \
+                              --min-x 1 --max-x 1000000 --num-rep 1 | \
+  grep "device \(0\|4\)" | sed -e 's/^.*stored : \([0-9]\+\).*$/\1/'))
+
+if test $(echo "scale=5; (10 - ${one[0]}/${one[1]}) > .1 || (10 - ${one[0]}/${one[1]}) < -.1" | bc) = 1; then
+    echo 1 replica not distributed as they should be. 1>&2
+    exit 1
+fi