]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/store_test: add an additional bluestore test case to verify for exceeding blob...
authorIgor Fedotov <ifedotov@mirantis.com>
Wed, 15 Jun 2016 14:05:41 +0000 (17:05 +0300)
committerIgor Fedotov <ifedotov@mirantis.com>
Wed, 15 Jun 2016 14:05:41 +0000 (17:05 +0300)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/test/objectstore/store_test.cc

index ff3191b01faead4fa0dd8a626044ba6aa788a26a..7fa854c4222a4b77a4b5e674f3309cc957d74dfd 100644 (file)
@@ -2698,6 +2698,7 @@ public:
   static const unsigned max_attr_name_len = 100;
   static const unsigned max_attr_value_len = 1024 * 4;
   coll_t cid;
+  unsigned write_alignment;
   unsigned max_object_len, max_write_len;
   unsigned in_flight;
   map<ghobject_t, Object, ghobject_t::BitwiseComparator> contents;
@@ -2840,10 +2841,11 @@ public:
                         ObjectStore::Sequencer *osr,
                         coll_t cid,
                         unsigned max_size,
-                        unsigned max_write)
-    : cid(cid), max_object_len(max_size), max_write_len(max_write),
-      in_flight(0), object_gen(gen), rng(rng), store(store), osr(osr),
-      lock("State lock") {}
+                        unsigned max_write,
+                        unsigned alignment)
+    : cid(cid), write_alignment(alignment), max_object_len(max_size),
+      max_write_len(max_write), in_flight(0), object_gen(gen),
+      rng(rng), store(store), osr(osr), lock("State lock") {}
 
   int init() {
     ObjectStore::Transaction t;
@@ -2869,6 +2871,9 @@ public:
     t.remove_collection(cid);
     apply_transaction(store, osr, std::move(t));
   }
+  void statfs(store_statfs_t& stat) {
+    store->statfs(&stat);
+  }
 
   ghobject_t get_uniform_random_object() {
     while (in_flight >= max_in_flight || available_objects.empty())
@@ -3155,6 +3160,10 @@ public:
     uint64_t offset = u1(*rng);
     uint64_t len = u2(*rng);
     bufferlist bl;
+    if (write_alignment) {
+      offset = ROUND_UP_TO(offset, write_alignment);
+      len = ROUND_UP_TO(len, write_alignment);
+    }
 
     filled_byte_array(bl, len);
 
@@ -3244,6 +3253,10 @@ public:
 
     boost::uniform_int<> choose(0, max_object_len);
     size_t len = choose(*rng);
+    if (write_alignment) {
+      len = ROUND_UP_TO(len, write_alignment);
+    }
+
     bufferlist bl;
 
     t->truncate(cid, obj, len);
@@ -3383,6 +3396,10 @@ public:
     boost::uniform_int<> u2(0, max_write_len);
     uint64_t offset = u1(*rng);
     uint64_t len = u2(*rng);
+    if (write_alignment) {
+      offset = ROUND_UP_TO(offset, write_alignment);
+      len = ROUND_UP_TO(len, write_alignment);
+    }
 
     if (contents[new_obj].data.length() < offset + len) {
       contents[new_obj].data.append_zero(offset+len-contents[new_obj].data.length());
@@ -3413,7 +3430,7 @@ void doSyntheticTest(boost::scoped_ptr<ObjectStore>& store)
   gen_type rng(time(NULL));
   coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
 
-  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 400*1024, 40*1024);
+  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 400*1024, 40*1024, 0);
   test_obj.init();
   for (int i = 0; i < 1000; ++i) {
     if (!(i % 500)) cerr << "seeding object " << i << std::endl;
@@ -3491,7 +3508,7 @@ TEST_P(StoreTest, AttrSynthetic) {
   gen_type rng(time(NULL));
   coll_t cid(spg_t(pg_t(0,447),shard_id_t::NO_SHARD));
 
-  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 40*1024, 4*1024);
+  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 40*1024, 4*1024, 0);
   test_obj.init();
   for (int i = 0; i < 500; ++i) {
     if (!(i % 10)) cerr << "seeding object " << i << std::endl;
@@ -4544,46 +4561,85 @@ int main(int argc, char **argv) {
   return r;
 }
 
-void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store)
+void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store,
+                        unsigned max_objects,
+                        unsigned max_ops,
+                        unsigned max_object_size,
+                        unsigned max_write_size,
+                        unsigned write_alignment,
+                        store_statfs_t* res_stat)
 {
   ObjectStore::Sequencer osr("test");
   MixedGenerator gen(555);
   gen_type rng(time(NULL));
   coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
 
-  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 4*1024*1024, 4096);
+  SyntheticWorkloadState test_obj(store.get(),
+                                  &gen,
+                                  &rng,
+                                  &osr,
+                                  cid,
+                                  max_object_size,
+                                  max_write_size,
+                                  write_alignment);
   test_obj.init();
-  const int max_objects = 1;
-  for (int i = 0; i < max_objects; ++i) {
+  for (unsigned i = 0; i < max_objects; ++i) {
     if (!(i % 500)) cerr << "seeding object " << i << std::endl;
     test_obj.touch();
   }
-  for (int i = 0; i < 1000; ++i) {
-    if (!(i % 1000)) {
+  for (unsigned i = 0; i < max_ops; ++i) {
+    if (!(i % 200)) {
       cerr << "Op " << i << std::endl;
       test_obj.print_internal_state();
     }
     test_obj.write();
   }
   test_obj.wait_for_done();
+  if (res_stat) {
+    test_obj.statfs(*res_stat);
+  }
   test_obj.shutdown();
 }
 
 TEST_P(StoreTest, Many4KWritesTest) {
-  g_ceph_context->_conf->apply_changes(NULL);
-  doMany4KWritesTest(store);
+  if (string(GetParam()) != "bluestore")
+    return;
+  store_statfs_t res_stat;
+  unsigned max_object = 4*1024*1024;
+
+  doMany4KWritesTest(store, 1, 1000, 4*1024*1024, 4*1024, 0, &res_stat);
+
+  ASSERT_LE(res_stat.stored, max_object);
+  ASSERT_EQ(res_stat.allocated, max_object);
 }
 
 TEST_P(StoreTest, Many4KWritesNoCSumTest) {
+  if (string(GetParam()) != "bluestore")
+    return;
   g_conf->set_val("bluestore_csum", "false");
   g_conf->set_val("bluestore_csum_type", "none");
   g_ceph_context->_conf->apply_changes(NULL);
-  doMany4KWritesTest(store);
+  store_statfs_t res_stat;
+  unsigned max_object = 4*1024*1024;
 
+  doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0, &res_stat );
+
+  ASSERT_LE(res_stat.stored, max_object);
+  ASSERT_EQ(res_stat.allocated, max_object);
   g_conf->set_val("bluestore_csum", "true");
   g_conf->set_val("bluestore_csum_type", "crc32c");
 }
 
+TEST_P(StoreTest, TooManyBlobsTest) {
+  if (string(GetParam()) != "bluestore")
+    return;
+  store_statfs_t res_stat;
+  unsigned max_object = 4*1024*1024;
+  doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0, &res_stat);
+  ASSERT_LE(res_stat.stored, max_object);
+  ASSERT_EQ(res_stat.allocated, max_object);
+}
+
 /*
  * Local Variables:
  * compile-command: "cd ../.. ; make ceph_test_objectstore &&