From b7ef40e540aea8e7aeffe0ce4f81fb70e0ecfc7e Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 31 May 2024 17:19:51 +0000 Subject: [PATCH] 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 85ace61c2f01d814bdcc5fbce0320f10c5a606cc) --- src/test/librados/io_cxx.cc | 3 +-- src/test/librados/testcase_cxx.cc | 29 +++++++---------------------- src/test/librados/testcase_cxx.h | 4 ++-- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/test/librados/io_cxx.cc b/src/test/librados/io_cxx.cc index 39e10a62985..c640df9aea3 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; @@ -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) { diff --git a/src/test/librados/testcase_cxx.cc b/src/test/librados/testcase_cxx.cc index 9295142c647..105c492abab 100644 --- a/src/test/librados/testcase_cxx.cc +++ b/src/test/librados/testcase_cxx.cc @@ -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)); diff --git a/src/test/librados/testcase_cxx.h b/src/test/librados/testcase_cxx.h index 3fd5f9c6077..15b7df8171b 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; -- 2.39.5