]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon, crush: add some tests to build a DAG via the cli
authorSage Weil <sage@inktank.com>
Fri, 22 Mar 2013 19:32:47 +0000 (12:32 -0700)
committerSage Weil <sage@inktank.com>
Fri, 22 Mar 2013 22:15:38 +0000 (15:15 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
qa/workunits/mon/crush_ops.sh
src/crush/CrushWrapper.cc

index 735646b5ca0af9bcbdcfad4f04d67d49b9e789f9..05bc87108df223c93caa22edf0dd82a7fbcd19d1 100755 (executable)
@@ -3,6 +3,8 @@
 set -e
 
 ceph osd crush dump
+
+# rules
 ceph osd crush rule dump
 ceph osd crush rule ls
 ceph osd crush rule list
@@ -20,4 +22,41 @@ ceph osd crush rule rm bar
 # can't delete in-use rules, tho:
 ceph osd crush rule rm data && exit 1 || true
 
+# build a simple map
+ceph osd crush add-bucket foo root
+o1=`ceph osd create`
+o2=`ceph osd create`
+ceph osd crush add $o1 1 host=host1 root=foo
+ceph osd crush add $o2 1 host=host2 root=foo
+ceph osd crush add-bucket bar root
+ceph osd crush link host1 root=bar
+ceph osd crush link host2 root=bar
+
+ceph osd tree | grep -c osd.$o1 | grep -q 2
+ceph osd tree | grep -c host1 | grep -q 2
+ceph osd tree | grep -c osd.$o2 | grep -q 2
+ceph osd tree | grep -c host2 | grep -q 2
+ceph osd crush rm host1 foo && exit 1 || true   # not empty
+ceph osd crush unlink host1 foo
+ceph osd crush unlink host1 foo && exit 1 || true # not there anymore
+ceph osd tree | grep -c host1 | grep -q 1
+
+ceph osd crush rm foo && exit 1 || true
+ceph osd crush rm bar && exit 1 || true
+ceph osd crush unlink host1 bar
+ceph osd tree | grep -c host1 | grep -q 1   # now an orphan
+ceph osd crush rm osd.1 host1
+ceph osd crush rm host1
+ceph osd tree | grep -c host1 | grep -q 0
+
+ceph osd crush rm bar && exit 1 || true
+ceph osd crush unlink host2
+ceph osd crush rm bar
+ceph osd crush rm foo
+ceph osd crush rm osd.$o2 host2
+ceph osd crush rm host2
+ceph osd crush rm osd.$o1
+ceph osd crush rm osd.$o2
+ceph osd crush rm osd.$o2 && exti 1 || true
+
 echo OK
index a2aab0a8dfc7ee25b6c062d1d25a33e57d3f2ff1..a9258287d79698474584ec2cb16c0695a93690c2 100644 (file)
@@ -54,12 +54,6 @@ bool CrushWrapper::_maybe_remove_last_instance(CephContext *cct, int item, bool
 {
   // last instance?
   if (_search_item_exists(item)) {
-    if (name_map.count(item)) {
-      ldout(cct, 5) << "_maybe_remove_last_instance removing name for item " << item << dendl;
-      name_map.erase(item);
-      have_rmaps = false;
-      return true;
-    }
     return false;
   }