]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/FileStore: getattr() should return 0 if success 5422/head
authorKefu Chai <kchai@redhat.com>
Thu, 30 Jul 2015 14:19:41 +0000 (22:19 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 31 Jul 2015 09:35:31 +0000 (17:35 +0800)
* fix the test of ObjectStore/StoreTest.SimpleCloneTest, the expected
  return value of getattr() should be 0. otherwise it otherwise it fails
  on objectstore backends of "memstore" and "keyvaluestore".
* change FileStore::getattr() to return 0 on success
* tighten related tests in ceph_test_objectstore, to test the return value
  of getattr() using ASSERT_EQ(r, 0) instead of ASSERT_GE(r, 0)

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/os/FileStore.cc
src/test/objectstore/store_test.cc

index a9f4470e140f143068e373ed223f7a5716fd7b24..841de3f39649f93f6911bdac7eeb66e338b94101 100644 (file)
@@ -4072,7 +4072,7 @@ int FileStore::getattr(coll_t cid, const ghobject_t& oid, const char *name, buff
     return -EIO;
   } else {
     tracepoint(objectstore, getattr_exit, r);
-    return r;
+    return r < 0 ? r : 0;
   }
 }
 
index 90c368bef680d74237b0b44cc86f955502283d68..6d1654cd9c919b4953d72b90b0f797e5a1a5dfc7 100644 (file)
@@ -428,24 +428,29 @@ TEST_P(StoreTest, SimpleCloneTest) {
     cerr << "Clone object and rm attr" << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
+
     r = store->read(cid, hoid, 10, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(newdata.contents_equal(large));
+
     newdata.clear();
     r = store->read(cid, hoid2, 10, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(newdata.contents_equal(small));
+
     r = store->getattr(cid, hoid2, "attr2", attr);
-    ASSERT_EQ(r, 5);
+    ASSERT_EQ(r, 0);
     ASSERT_TRUE(attr.contents_equal(small));
+
     attr.clear();
     r = store->getattr(cid, hoid2, "attr3", attr);
-    ASSERT_EQ(r, 6);
+    ASSERT_EQ(r, 0);
     ASSERT_TRUE(attr.contents_equal(xlarge));
+
     attr.clear();
     r = store->getattr(cid, hoid, "attr1", attr);
-    ASSERT_EQ(r, 5);
-    ASSERT_TRUE(attr.contents_equal(small));
+    ASSERT_EQ(r, 0);
+    ASSERT_TRUE(attr.contents_equal(large));
   }
   {
     ObjectStore::Transaction t;
@@ -952,7 +957,7 @@ public:
 
     bufferlist bl;
     r = store->getattr(cid, obj, it->first, bl);
-    ASSERT_TRUE(r >= 0);
+    ASSERT_EQ(r, 0);
     ASSERT_TRUE(it->second.contents_equal(bl));
   }
 
@@ -1650,7 +1655,7 @@ TEST_P(StoreTest, XattrTest) {
   ASSERT_EQ(r, -ENODATA);
 
   r = store->getattr(cid, hoid, "attr3", bp);
-  ASSERT_GE(r, 0);
+  ASSERT_EQ(r, 0);
   bufferlist bl2;
   bl2.push_back(bp);
   ASSERT_TRUE(bl2 == attrs["attr3"]);
@@ -1859,7 +1864,7 @@ TEST_P(StoreTest, MoveRename) {
     ASSERT_TRUE(newdata.contents_equal(data));
     bufferlist newattr;
     r = store->getattr(cid, oid, "attr", newattr);
-    ASSERT_GE(r, 0);
+    ASSERT_EQ(r, 0);
     ASSERT_TRUE(newattr.contents_equal(attr));
     set<string> keys;
     keys.insert("omap_key");