]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/librados/io_cxx: fix ec overwrites cleanup in CrcZeroWrite
authorSamuel Just <sjust@redhat.com>
Fri, 31 May 2024 17:19:51 +0000 (17:19 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Thu, 27 Jun 2024 11:09:52 +0000 (11:09 +0000)
We can't rely on recreating the pool at the end of the test case because
failing an assert in CrcZeroWrite would skip it.  Instead, recreate the
pool in TearDown with other cleanup.

Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit 85ace61c2f01d814bdcc5fbce0320f10c5a606cc)

src/test/librados/io_cxx.cc
src/test/librados/testcase_cxx.cc
src/test/librados/testcase_cxx.h

index 39e10a6298543380ea1056105551717c8e211bd9..c640df9aea323d649cd7abc7ac6afe4e022823a9 100644 (file)
@@ -846,7 +846,7 @@ TEST_F(LibRadosIoECPP, RmXattrPP) {
 
 TEST_F(LibRadosIoECPP, CrcZeroWrite) {
   SKIP_IF_CRIMSON();
-  set_allow_ec_overwrites(pool_name, true);
+  set_allow_ec_overwrites();
   char buf[128];
   memset(buf, 0xcc, sizeof(buf));
   bufferlist bl;
@@ -858,7 +858,6 @@ TEST_F(LibRadosIoECPP, CrcZeroWrite) {
   ObjectReadOperation read;
   read.read(0, bl.length(), NULL, NULL);
   ASSERT_EQ(0, ioctx.operate("foo", &read, &bl));
-  recreate_pool();
 }
 
 TEST_F(LibRadosIoECPP, XattrListPP) {
index 9295142c6470aaea4e000fd6531549408af43b22..105c492ababb93c21ab3bdf3b5edd47f6e365506 100644 (file)
@@ -404,31 +404,16 @@ void RadosTestECPP::TearDown()
     cleanup_default_namespace(ioctx);
     cleanup_namespace(ioctx, nspace);
   }
+  if (ec_overwrites_set) {
+    ASSERT_EQ(0, destroy_one_ec_pool_pp(pool_name, s_cluster));
+    ASSERT_EQ("", create_one_ec_pool_pp(pool_name, s_cluster));
+    ec_overwrites_set = false;
+  }
   ioctx.close();
 }
 
-void RadosTestECPP::recreate_pool()
+void RadosTestECPP::set_allow_ec_overwrites()
 {
-  ec_overwrites_set = true;
   ASSERT_EQ("", set_allow_ec_overwrites_pp(pool_name, cluster, true));
-
-  char buf[128];
-  memset(buf, 0xcc, sizeof(buf));
-  bufferlist bl;
-  bl.append(buf, sizeof(buf));
-
-  const std::string objname = "RadosTestECPP::set_allow_ec_overwrites:test_obj";
-  ASSERT_EQ(0, ioctx.write(objname, bl, sizeof(buf), 0));
-  const auto end = std::chrono::steady_clock::now() + std::chrono::seconds(120);
-  while (true) {
-    if (0 == ioctx.write(objname, bl, sizeof(buf), 0)) {
-      break;
-    }
-    ASSERT_LT(std::chrono::steady_clock::now(), end);
-    std::this_thread::sleep_for(std::chrono::seconds(2));
-  }
+  ec_overwrites_set = true;
 }
-
-void RadosTestECPP::set_allow_ec_overwrites(std::string pool, bool allow)
-{
-  ASSERT_EQ("", set_allow_ec_overwrites_pp(pool, cluster, allow));
index 3fd5f9c607763e48d0531eb73cff75a925fcb64a..15b7df8171b7fccfe617808a3cac646f0a623678 100644 (file)
@@ -111,14 +111,14 @@ protected:
 };
 
 class RadosTestECPP : public RadosTestPP {
+  bool ec_overwrites_set = false;
 public:
   RadosTestECPP(bool c=false) : cluster(s_cluster), cleanup(c) {}
   ~RadosTestECPP() override {}
 protected:
   static void SetUpTestCase();
   static void TearDownTestCase();
-  void recreate_pool();
-  void set_allow_ec_overwrites(std::string pool, bool allow=true);
+  void set_allow_ec_overwrites();
   static librados::Rados s_cluster;
   static std::string pool_name;