]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crimson/seastore: add set/get attrs test
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 8 Apr 2021 10:09:51 +0000 (18:09 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Fri, 23 Apr 2021 03:33:00 +0000 (11:33 +0800)
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/test/crimson/seastore/test_seastore.cc

index 88dcb18f135135d0c102a5d2c94579a4241f9c3d..eb20b965d6110f55776208962c0dc85e6e336eba 100644 (file)
@@ -1,5 +1,5 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
-// vim: ts=8 sw=2 smarttab expandtab
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
 
 #include <string>
 #include <iostream>
@@ -177,6 +177,21 @@ struct seastore_test_t :
       EXPECT_EQ(contents.length(), st.st_size);
     }
 
+    void set_attr_oi(
+      SeaStore &seastore,
+      bufferlist& val) {
+      CTransaction t;
+      t.setattr(cid, oid, OI_ATTR, val);
+      seastore.do_transaction(
+        coll,
+        std::move(t)).get0();
+    }
+
+    SeaStore::attrs_t get_attr_oi(
+      SeaStore &seastore) {
+      return seastore.get_attrs(
+        coll, oid).handle_error(SeaStore::get_attrs_ertr::discard_all{}).get();
+    }
 
     void check_omap_key(
       SeaStore &seastore,
@@ -331,6 +346,23 @@ TEST_F(seastore_test_t, omap_test_simple)
   });
 }
 
+TEST_F(seastore_test_t, attr)
+{
+  run_async([this] {
+    auto& test_obj = get_object(make_oid(0));
+    std::string s("asdfasdfasdf");
+    bufferlist bl;
+    encode(s, bl);
+    test_obj.set_attr_oi(*seastore, bl);
+    auto attrs = test_obj.get_attr_oi(*seastore);
+    std::string s2;
+    bufferlist bl2;
+    bl2.push_back(attrs[OI_ATTR]);
+    decode(s2, bl);
+    EXPECT_EQ(s, s2);
+  });
+}
+
 TEST_F(seastore_test_t, omap_test_iterator)
 {
   run_async([this] {