]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph_test_objectstore: zero-length write should not affect object size
authorSage Weil <sage@redhat.com>
Mon, 20 Jun 2016 13:51:56 +0000 (09:51 -0400)
committerIgor Fedotov <ifedotov@mirantis.com>
Mon, 20 Jun 2016 13:59:34 +0000 (16:59 +0300)
Signed-off-by: Sage Weil <sage@redhat.com>
src/test/objectstore/store_test.cc

index f459fff0cf90f18a97c81991c1525b6337fef561..af02b96729bf511a3e851ff0e584ed8073b0695e 100644 (file)
@@ -1974,6 +1974,31 @@ TEST_P(StoreTest, MiscFragmentTests) {
 
 }
 
+TEST_P(StoreTest, ZeroLengthWrite) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid;
+  ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    t.touch(cid, hoid);
+    r = apply_transaction(store, &osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    bufferlist empty;
+    t.write(cid, hoid, 1048576, 0, empty);
+    r = apply_transaction(store, &osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  struct stat stat;
+  r = store->stat(cid, hoid, &stat);
+  ASSERT_EQ(0, r);
+  ASSERT_EQ(0, stat.st_size);
+}
+
 TEST_P(StoreTest, SimpleAttrTest) {
   ObjectStore::Sequencer osr("test");
   int r;