]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_objectstore: use a few hash values for objects; clone between them
authorSage Weil <sage@redhat.com>
Thu, 17 Dec 2015 19:15:48 +0000 (14:15 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:23 +0000 (13:07 -0500)
We only guarantee support for clone between objects with the same hash.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/objectstore/store_test.cc

index 6c5aeb175b939191ea2d13eaa63d80e29106f00d..75c71eba55fc1de6436037ac7dba61b56c0419da 100644 (file)
@@ -1468,20 +1468,12 @@ public:
     char buf[100];
     snprintf(buf, sizeof(buf), "OBJ_%u", seq);
     string name(buf);
-
-    /*
-    boost::uniform_int<> true_false(0, 1);
-    if (true_false(*gen)) {
-      // long
-      for (int i = 0; i < 100; ++i) name.append("aaaaa");
-    } else if (true_false(*gen)) {
-      name = "DIR_" + name;
-      }*/
-
-    // hash
-    //boost::binomial_distribution<uint32_t> bin(0xFFFFFF, 0.5);
     ++seq;
-    return ghobject_t(hobject_t(name, string(), rand() & 2 ? CEPH_NOSNAP : rand(), rand() & 0xFF, poolid, ""));
+    return ghobject_t(
+      hobject_t(
+       name, string(), rand() & 2 ? CEPH_NOSNAP : rand(),
+       seq % 16, // use smaller set of hash values so clone can work
+       poolid, ""));
   }
 };
 
@@ -1709,6 +1701,8 @@ public:
     } while (--max && !contents[old_obj].data.length());
     available_objects.erase(old_obj);
     ghobject_t new_obj = object_gen->create_object(rng);
+    // make the hash match
+    new_obj.hobj.set_hash(old_obj.hobj.get_hash());
     available_objects.erase(new_obj);
 
     ObjectStore::Transaction *t = new ObjectStore::Transaction;