]> git.apps.os.sepia.ceph.com Git - ceph.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>
Wed, 15 Jan 2025 10:16:31 +0000 (10:16 +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 ce2378108f8630ec6ea195d66ff89cb71497b767)

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

index eda2d0c3af6fd133ead0c715af3119d729eee53c..8e26c24e8a698b67eeb9d39a74c8887f27b6a87f 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;
@@ -857,7 +857,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 75c05cc20410f72d031c1189e8ba604eeac60a3b..faa303427534059650c9303b9c7df2c2add3daed 100644 (file)
@@ -401,18 +401,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()
 {
-  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();
+  ASSERT_EQ("", set_allow_ec_overwrites_pp(pool_name, cluster, true));
+  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));
-}
\ No newline at end of file
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;