]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add a test to exercise ceph-monstore-update-crush.sh
authorKefu Chai <kchai@redhat.com>
Fri, 19 Jun 2015 15:15:58 +0000 (23:15 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 17 Jul 2015 11:15:44 +0000 (19:15 +0800)
Fixes: #11815
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/mon/osd-crush.sh

index 0a42b6474f34d9e3e9c51fbd2d407d99affa16e7..748f15730b0465cdb063e2bb7c492e5b49de0294 100755 (executable)
@@ -237,6 +237,47 @@ function TEST_crush_tree() {
         $XMLSTARLET val -e -r test/mon/osd-crush-tree.rng - || return 1
 }
 
+# NB: disable me if i am too time consuming
+function TEST_crush_repair_faulty_crushmap() {
+    local dir=$1
+    fsid=$(uuidgen)
+    MONA=127.0.0.1:7113
+    MONB=127.0.0.1:7114
+    MONC=127.0.0.1:7115
+    CEPH_ARGS_orig=$CEPH_ARGS
+    CEPH_ARGS="--fsid=$fsid --auth-supported=none "
+    CEPH_ARGS+="--mon-initial-members=a,b,c "
+    CEPH_ARGS+="--mon-host=$MONA,$MONB,$MONC "
+    run_mon $dir a --public-addr $MONA || return 1
+    run_mon $dir b --public-addr $MONB || return 1
+    run_mon $dir c --public-addr $MONC || return 1
+
+    local empty_map=$dir/empty_map
+    :> $empty_map.txt
+    ./crushtool -c $empty_map.txt -o $empty_map.map || return 1
+
+    local crushtool_path_old=`ceph-conf --show-config-value crushtool`
+    ceph tell mon.* injectargs --crushtool "true"
+
+    ceph osd setcrushmap -i $empty_map.map || return 1
+    # should be an empty crush map without any buckets
+    ! test $(ceph osd crush dump --format=xml | \
+           $XMLSTARLET sel -t -m "//buckets/bucket" -v .) || return 1
+    # bring them down, the "ceph" commands will try to hunt for other monitor in
+    # vain, after mon.a is offline
+    kill_daemons $dir || return 1
+    # rewrite the monstore with the good crush map,
+    ./tools/ceph-monstore-update-crush.sh --rewrite $dir/a || return 1
+
+    run_mon $dir a --public-addr $MONA || return 1
+    run_mon $dir b --public-addr $MONB || return 1
+    run_mon $dir c --public-addr $MONC || return 1
+    # the buckets are back
+    test $(ceph osd crush dump --format=xml | \
+           $XMLSTARLET sel -t -m "//buckets/bucket" -v .) || return 1
+    CEPH_ARGS=$CEPH_ARGS_orig
+}
+
 main osd-crush "$@"
 
 # Local Variables: