]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_rados_io_pp: Add cxx test for append zero test 55008/head
authorNitzanMordhai <nmordech@redhat.com>
Tue, 26 Dec 2023 10:22:19 +0000 (10:22 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Sun, 19 May 2024 05:03:15 +0000 (05:03 +0000)
1. adding allow_ec_overwrite option for cxx test
2. adding new test for crc failuer check with append zero length

Fixes: https://tracker.ceph.com/issues/53240
Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
src/test/librados/io_cxx.cc
src/test/librados/test_cxx.cc
src/test/librados/test_cxx.h
src/test/librados/testcase_cxx.cc
src/test/librados/testcase_cxx.h

index f20518111010857d3f3486e6154fa5ea9796dbbb..35568a8ba317b98ef4be2bd596bff40d5c059422 100644 (file)
@@ -495,6 +495,18 @@ TEST_F(LibRadosIoPP, XattrListPP) {
   }
 }
 
+TEST_F(LibRadosIoPP, CrcZeroWrite) {
+  char buf[128];
+  bufferlist bl;
+
+  ASSERT_EQ(0, ioctx.write("foo", bl, 0, 0));
+  ASSERT_EQ(0, ioctx.write("foo", bl, 0, sizeof(buf)));
+
+  ObjectReadOperation read;
+  read.read(0, bl.length(), NULL, NULL);
+  ASSERT_EQ(0, ioctx.operate("foo", &read, &bl));
+}
+
 TEST_F(LibRadosIoECPP, SimpleWritePP) {
   SKIP_IF_CRIMSON();
   char buf[128];
@@ -865,6 +877,22 @@ TEST_F(LibRadosIoECPP, RmXattrPP) {
   ASSERT_EQ(-ENOENT, ioctx.rmxattr("foo_rmxattr", attr2));
 }
 
+TEST_F(LibRadosIoECPP, CrcZeroWrite) {
+  SKIP_IF_CRIMSON();
+  set_allow_ec_overwrites(pool_name, true);
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+  bufferlist bl;
+
+  ASSERT_EQ(0, ioctx.write("foo", bl, 0, 0));
+  ASSERT_EQ(0, ioctx.write("foo", bl, 0, sizeof(buf)));
+
+  ObjectReadOperation read;
+  read.read(0, bl.length(), NULL, NULL);
+  ASSERT_EQ(0, ioctx.operate("foo", &read, &bl));
+  recreate_pool();
+}
+
 TEST_F(LibRadosIoECPP, XattrListPP) {
   SKIP_IF_CRIMSON();
   char buf[128];
index 6c7e353e4512dbe61bb21e4237857fa69cff5118..caf84f42b4e62c465815ed0b82524c8f4868adab 100644 (file)
@@ -121,6 +121,21 @@ std::string create_one_ec_pool_pp(const std::string &pool_name, Rados &cluster)
   return "";
 }
 
+std::string set_allow_ec_overwrites_pp(const std::string &pool_name, Rados &cluster, bool allow)
+{
+  std::ostringstream oss;
+  bufferlist inbl;
+  int ret = cluster.mon_command(
+    "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool_name + "\", \"var\": \"allow_ec_overwrites\", \"val\": \"" + (allow ? "true" : "false") + "\"}",
+    inbl, NULL, NULL);
+  if (ret) {
+    cluster.shutdown();
+    oss << "mon_command osd pool set pool:" << pool_name << " pool_type:erasure allow_ec_overwrites true failed with error " << ret;
+    return oss.str();
+  }
+  return "";
+}
+
 std::string connect_cluster_pp(librados::Rados &cluster)
 {
   return connect_cluster_pp(cluster, {});
index 1d11d69236dfa4f77860dd6723ee4c42a7447dd6..64a20e56e5f5cfdbcd1b47edfe764be09f1298c4 100644 (file)
@@ -12,6 +12,8 @@ std::string create_one_pool_pp(const std::string &pool_name,
                               const std::map<std::string, std::string> &config);
 std::string create_one_ec_pool_pp(const std::string &pool_name,
                            librados::Rados &cluster);
+std::string set_allow_ec_overwrites_pp(const std::string &pool_name,
+                                      librados::Rados &cluster, bool allow);
 std::string connect_cluster_pp(librados::Rados &cluster);
 std::string connect_cluster_pp(librados::Rados &cluster,
                               const std::map<std::string, std::string> &config);
index 407c59b552ea42b5fd7baef3dceea7c91baacb6b..75c05cc20410f72d031c1189e8ba604eeac60a3b 100644 (file)
@@ -193,7 +193,6 @@ Rados RadosTestPP::s_cluster;
 void RadosTestPP::SetUpTestCase()
 {
   init_rand();
-
   auto pool_prefix = fmt::format("{}_", ::testing::UnitTest::GetInstance()->current_test_case()->name());
   pool_name = get_temp_pool_name(pool_prefix);
   ASSERT_EQ("", create_one_pool_pp(pool_name, s_cluster));
@@ -405,3 +404,15 @@ void RadosTestECPP::TearDown()
   ioctx.close();
 }
 
+void RadosTestECPP::recreate_pool()
+{
+  SKIP_IF_CRIMSON();
+  ASSERT_EQ(0, destroy_one_ec_pool_pp(pool_name, s_cluster));
+  ASSERT_EQ("", create_one_ec_pool_pp(pool_name, s_cluster));
+  SetUp();
+}
+
+void RadosTestECPP::set_allow_ec_overwrites(std::string pool, bool allow)
+{
+  ASSERT_EQ("", set_allow_ec_overwrites_pp(pool, cluster, allow));
+}
\ No newline at end of file
index 637ec11eefc74cdefbd8dce97900d97aceb090d5..3fd5f9c607763e48d0531eb73cff75a925fcb64a 100644 (file)
@@ -117,6 +117,8 @@ public:
 protected:
   static void SetUpTestCase();
   static void TearDownTestCase();
+  void recreate_pool();
+  void set_allow_ec_overwrites(std::string pool, bool allow=true);
   static librados::Rados s_cluster;
   static std::string pool_name;