Skip to content

Commit deab7d4

Browse files
authored
Merge pull request ceph#63434 from cbodley/wip-70673-debug
test/rgw: link lua test against unit-main for g_ceph_context
2 parents b1005d3 + f2b292f commit deab7d4

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

src/test/rgw/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ add_executable(unittest_rgw_lua test_rgw_lua.cc)
340340
add_ceph_unittest(unittest_rgw_lua)
341341
target_include_directories(unittest_rgw_lua
342342
SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw")
343-
target_link_libraries(unittest_rgw_lua ${rgw_libs})
343+
target_link_libraries(unittest_rgw_lua unit-main ${rgw_libs})
344344

345345
add_executable(radosgw-cr-test rgw_cr_test.cc)
346346
target_link_libraries(radosgw-cr-test ${rgw_libs} librados

src/test/rgw/test_rgw_lua.cc

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,6 @@ using boost::container::flat_set;
1717
using rgw::auth::Identity;
1818
using rgw::auth::Principal;
1919

20-
class CctCleaner {
21-
CephContext* cct;
22-
public:
23-
CctCleaner(CephContext* _cct) : cct(_cct) {}
24-
~CctCleaner() {
25-
#ifdef WITH_CRIMSON
26-
delete cct;
27-
#else
28-
cct->put();
29-
#endif
30-
}
31-
};
32-
3320
class FakeIdentity : public Identity {
3421
public:
3522
FakeIdentity() = default;
@@ -167,15 +154,11 @@ class TestAccounter : public io::Accounter, public io::BasicClient {
167154
}
168155
};
169156

170-
auto g_cct = new CephContext(CEPH_ENTITY_TYPE_CLIENT);
171-
172-
CctCleaner cleaner(g_cct);
173-
174157
tracing::Tracer tracer;
175158

176159
inline std::unique_ptr<sal::RadosStore> make_store() {
177160
auto context_pool = std::make_unique<ceph::async::io_context_pool>(
178-
g_cct->_conf->rgw_thread_pool_size);
161+
g_ceph_context->_conf->rgw_thread_pool_size);
179162

180163
struct StoreBundle : public sal::RadosStore {
181164
std::unique_ptr<ceph::async::io_context_pool> context_pool;
@@ -194,7 +177,7 @@ class TestLuaManager : public rgw::sal::StoreLuaManager {
194177
std::string lua_script;
195178
unsigned read_time = 0;
196179
TestLuaManager() {
197-
rgw_perf_start(g_cct);
180+
rgw_perf_start(g_ceph_context);
198181
}
199182
int get_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script) override {
200183
std::this_thread::sleep_for(std::chrono::seconds(read_time));
@@ -220,7 +203,7 @@ class TestLuaManager : public rgw::sal::StoreLuaManager {
220203
return 0;
221204
}
222205
~TestLuaManager() {
223-
rgw_perf_stop(g_cct);
206+
rgw_perf_stop(g_ceph_context);
224207
}
225208
};
226209

@@ -235,9 +218,9 @@ void set_read_time(rgw::sal::LuaManager* manager, unsigned read_time) {
235218
auto store = make_store(); \
236219
pe.lua.manager = std::make_unique<TestLuaManager>(); \
237220
RGWEnv e; \
238-
req_state s(g_cct, pe, &e, 0);
221+
req_state s(g_ceph_context, pe, &e, 0);
239222

240-
#define INIT_TRACE tracer.init(g_cct, "test"); \
223+
#define INIT_TRACE tracer.init(g_ceph_context, "test"); \
241224
s.trace = tracer.start_trace("test", true);
242225

243226
TEST(TestRGWLua, EmptyScript)
@@ -900,7 +883,7 @@ class TestBackground : public rgw::lua::Background {
900883
public:
901884
TestBackground(sal::RadosStore* store, rgw::sal::LuaManager* manager) :
902885
rgw::lua::Background(store,
903-
g_cct,
886+
g_ceph_context,
904887
manager,
905888
1 /* run every second */) {
906889
}

0 commit comments

Comments
 (0)