From: Samuel Just Date: Fri, 31 May 2024 17:19:51 +0000 (+0000) Subject: test/librados/io_cxx: fix ec overwrites cleanup in CrcZeroWrite X-Git-Tag: v19.2.3~411^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=652c5025a957ea4dc4a0a5ee333b7d24da1e18da;p=ceph.git test/librados/io_cxx: fix ec overwrites cleanup in CrcZeroWrite 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 (cherry picked from commit ce2378108f8630ec6ea195d66ff89cb71497b767) --- diff --git a/src/test/librados/io_cxx.cc b/src/test/librados/io_cxx.cc index eda2d0c3af6fd..8e26c24e8a698 100644 --- a/src/test/librados/io_cxx.cc +++ b/src/test/librados/io_cxx.cc @@ -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) { diff --git a/src/test/librados/testcase_cxx.cc b/src/test/librados/testcase_cxx.cc index 75c05cc20410f..faa3034275340 100644 --- a/src/test/librados/testcase_cxx.cc +++ b/src/test/librados/testcase_cxx.cc @@ -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 diff --git a/src/test/librados/testcase_cxx.h b/src/test/librados/testcase_cxx.h index 3fd5f9c607763..15b7df8171b7f 100644 --- a/src/test/librados/testcase_cxx.h +++ b/src/test/librados/testcase_cxx.h @@ -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;