]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: unittest use const instead of define
authorLoic Dachary <loic@dachary.org>
Fri, 6 Dec 2013 13:39:10 +0000 (14:39 +0100)
committerLoic Dachary <loic@dachary.org>
Fri, 6 Dec 2013 19:40:48 +0000 (20:40 +0100)
And reduce the depth of the hierarchy because three levels of buckets
capture the same cases as four levels.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/crush/TestCrushWrapper.cc

index d85946be9a1aaf2d8156221ad91b9d27d417ec30..b53bdc847c33473198ec65ee4ab1a6d6bf062c60 100644 (file)
@@ -97,13 +97,11 @@ TEST(CrushWrapper, check_item_loc) {
 TEST(CrushWrapper, update_item) {
   CrushWrapper *c = new CrushWrapper;
 
-#define ROOT_TYPE 3
+  const int ROOT_TYPE = 2;
   c->set_type_name(ROOT_TYPE, "root");
-#define RACK_TYPE 2
-  c->set_type_name(RACK_TYPE, "rack");
-#define HOST_TYPE 1
+  const int HOST_TYPE = 1;
   c->set_type_name(HOST_TYPE, "host");
-#define OSD_TYPE 0
+  const int OSD_TYPE = 0;
   c->set_type_name(OSD_TYPE, "osd");
 
   int rootno;
@@ -125,13 +123,11 @@ TEST(CrushWrapper, update_item) {
 TEST(CrushWrapper, insert_item) {
   CrushWrapper *c = new CrushWrapper;
 
-#define ROOT_TYPE 3
+  const int ROOT_TYPE = 2;
   c->set_type_name(ROOT_TYPE, "root");
-#define RACK_TYPE 2
-  c->set_type_name(RACK_TYPE, "rack");
-#define HOST_TYPE 1
+  const int HOST_TYPE = 1;
   c->set_type_name(HOST_TYPE, "host");
-#define OSD_TYPE 0
+  const int OSD_TYPE = 0;
   c->set_type_name(OSD_TYPE, "osd");
 
   int rootno;
@@ -144,7 +140,7 @@ TEST(CrushWrapper, insert_item) {
   // invalid names anywhere in loc trigger an error
   {
     map<string,string> loc;
-    loc["rack"] = "\001";
+    loc["host"] = "\001";
     EXPECT_EQ(-EINVAL, c->insert_item(g_ceph_context, item, 1.0,
                                      "osd." + stringify(item), loc));
   }
@@ -166,7 +162,7 @@ TEST(CrushWrapper, insert_item) {
     std::string name = "NAME";
     map<string,string> loc;
     loc["root"] = "default";
-    loc["rack"] = name;
+    loc["host"] = name;
 
     item++;
     EXPECT_EQ(0, c->insert_item(g_ceph_context, item, 1.0,
@@ -177,7 +173,7 @@ TEST(CrushWrapper, insert_item) {
     std::string name = "ITEM_WITHOUT_BUCKET";
     map<string,string> loc;
     loc["root"] = "default";
-    loc["rack"] = name;
+    loc["host"] = name;
     item++;
     c->set_item_name(item, name);
 
@@ -188,12 +184,12 @@ TEST(CrushWrapper, insert_item) {
   // 
   //   When there is:
   //
-  //   default --> rack0 --> item
+  //   default --> host0 --> item
   //
   //   Trying to insert the same item higher in the hirarchy will fail
   //   because it would create a loop.
   //
-  //   default --> rack0 --> item
+  //   default --> host0 --> item
   //           |
   //           +-> item 
   //
@@ -202,7 +198,7 @@ TEST(CrushWrapper, insert_item) {
     {
       map<string,string> loc;
       loc["root"] = "default";
-      loc["rack"] = "rack0";
+      loc["host"] = "host0";
 
       EXPECT_EQ(0, c->insert_item(g_ceph_context, item, 1.0,
                                  "osd." + stringify(item), loc));
@@ -218,16 +214,16 @@ TEST(CrushWrapper, insert_item) {
   // 
   //   When there is:
   //
-  //   default --> rack0
+  //   default --> host0
   //
-  //   Trying to insert default under rack0 must fail
+  //   Trying to insert default under host0 must fail
   //   because it would create a loop.
   //
-  //   default --> rack0 --> default
+  //   default --> host0 --> default
   //
   {
     map<string,string> loc;
-    loc["rack"] = "rack0";
+    loc["host"] = "host0";
 
     EXPECT_EQ(-ELOOP, c->insert_item(g_ceph_context, rootno, 1.0,
                                     "default", loc));
@@ -241,8 +237,8 @@ TEST(CrushWrapper, insert_item) {
     c->set_item_name(osdno, "myosd");
     map<string,string> loc;
     loc["root"] = "default";
-    // wrongfully pretend the osd is of type rack
-    loc["rack"] = "myosd";
+    // wrongfully pretend the osd is of type host
+    loc["host"] = "myosd";
 
     item++;
     EXPECT_EQ(-EINVAL, c->insert_item(g_ceph_context, item, 1.0,
@@ -301,7 +297,7 @@ TEST(CrushWrapper, is_valid_crush_loc) {
   }
   {
     map<string,string> loc;
-    loc["rack"] = "\003";
+    loc["host"] = "\003";
     EXPECT_FALSE(CrushWrapper::is_valid_crush_loc(g_ceph_context, loc));
   }
 }