]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw: link lua test against unit-main for g_ceph_context 63434/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 22 May 2025 13:26:23 +0000 (09:26 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 22 May 2025 13:26:26 +0000 (09:26 -0400)
test_rgw_lua.cc was allocating a CephContext without initializing it, so
log statements from the tests/rgw code weren't actually being logged

the unit-main target links in the main() function from test/unit.cc
which initializes the CephContext via global_init(). use the resulting
global g_ceph_context instead of managing a separate one

Related-to: https://tracker.ceph.com/issues/70673
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/test/rgw/CMakeLists.txt
src/test/rgw/test_rgw_lua.cc

index d5020266ae7856449901cbe246bd432eca241fc4..56050317314065a6f5d8f6d799c8ac42b6793386 100644 (file)
@@ -340,7 +340,7 @@ add_executable(unittest_rgw_lua test_rgw_lua.cc)
 add_ceph_unittest(unittest_rgw_lua)
 target_include_directories(unittest_rgw_lua
   SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw")
-target_link_libraries(unittest_rgw_lua ${rgw_libs})
+target_link_libraries(unittest_rgw_lua unit-main ${rgw_libs})
 
 add_executable(radosgw-cr-test rgw_cr_test.cc)
 target_link_libraries(radosgw-cr-test ${rgw_libs} librados
index 21f12c4efd14198be3817dbd1d730a5593cecfa4..e773e15891f5fc73c442c3d8d0e76328b8ca6b05 100644 (file)
@@ -17,19 +17,6 @@ using boost::container::flat_set;
 using rgw::auth::Identity;
 using rgw::auth::Principal;
 
-class CctCleaner {
-  CephContext* cct;
-public:
-  CctCleaner(CephContext* _cct) : cct(_cct) {}
-  ~CctCleaner() { 
-#ifdef WITH_CRIMSON
-    delete cct; 
-#else
-    cct->put(); 
-#endif
-  }
-};
-
 class FakeIdentity : public Identity {
 public:
   FakeIdentity() = default;
@@ -167,15 +154,11 @@ public:
   }
 };
 
-auto g_cct = new CephContext(CEPH_ENTITY_TYPE_CLIENT);
-
-CctCleaner cleaner(g_cct);
-
 tracing::Tracer tracer;
 
 inline std::unique_ptr<sal::RadosStore> make_store() {
   auto context_pool = std::make_unique<ceph::async::io_context_pool>(
-    g_cct->_conf->rgw_thread_pool_size);
+    g_ceph_context->_conf->rgw_thread_pool_size);
 
   struct StoreBundle : public sal::RadosStore {
     std::unique_ptr<ceph::async::io_context_pool> context_pool;
@@ -194,7 +177,7 @@ class TestLuaManager : public rgw::sal::StoreLuaManager {
     std::string lua_script;
     unsigned read_time = 0;
     TestLuaManager() {
-      rgw_perf_start(g_cct);
+      rgw_perf_start(g_ceph_context);
     }
     int get_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script) override {
       std::this_thread::sleep_for(std::chrono::seconds(read_time));
@@ -220,7 +203,7 @@ class TestLuaManager : public rgw::sal::StoreLuaManager {
       return 0;
     }
     ~TestLuaManager() {
-      rgw_perf_stop(g_cct);
+      rgw_perf_stop(g_ceph_context);
     }
 };
 
@@ -235,9 +218,9 @@ void set_read_time(rgw::sal::LuaManager* manager, unsigned read_time) {
   auto store = make_store();                   \
   pe.lua.manager = std::make_unique<TestLuaManager>(); \
   RGWEnv e; \
-  req_state s(g_cct, pe, &e, 0);
+  req_state s(g_ceph_context, pe, &e, 0);
 
-#define INIT_TRACE tracer.init(g_cct, "test"); \
+#define INIT_TRACE tracer.init(g_ceph_context, "test"); \
                    s.trace = tracer.start_trace("test", true);
 
 TEST(TestRGWLua, EmptyScript)
@@ -900,7 +883,7 @@ class TestBackground : public rgw::lua::Background {
 public:
   TestBackground(sal::RadosStore* store, rgw::sal::LuaManager* manager) : 
     rgw::lua::Background(store, 
-        g_cct, 
+        g_ceph_context,
         manager,
         1 /* run every second */) {
     }