Skip to content

Commit 6237328

Browse files
authored
Merge pull request ceph#56540 from tchaikov/wip-fix-test-leaks-ceph-context
test: : do not increase ref when creating intrusive_ptr<CephContext> Reviewed-by: Casey Bodley <[email protected]>
2 parents 0e3c55c + d3c5a4a commit 6237328

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/test/mon/MonMap.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ TEST_F(MonMapTest, DISABLED_build_initial_config_from_dns) {
9898

9999

100100

101-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
101+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
102102
cct->_conf.set_val("mon_dns_srv_name", "cephmon");
103103
MonMap monmap;
104104
int r = monmap.build_initial(cct.get(), false, std::cerr);
@@ -135,7 +135,7 @@ TEST_F(MonMapTest, DISABLED_build_initial_config_from_dns_fail) {
135135
.WillOnce(Return(0));
136136
#endif
137137

138-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
138+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
139139
// using default value of mon_dns_srv_name option
140140
MonMap monmap;
141141
int r = monmap.build_initial(cct.get(), false, std::cerr);
@@ -196,7 +196,7 @@ TEST_F(MonMapTest, DISABLED_build_initial_config_from_dns_with_domain) {
196196

197197

198198

199-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
199+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
200200
cct->_conf.set_val("mon_dns_srv_name", "cephmon_ceph.com");
201201
MonMap monmap;
202202
int r = monmap.build_initial(cct.get(), false, std::cerr);
@@ -221,7 +221,7 @@ TEST_F(MonMapTest, DISABLED_build_initial_config_from_dns_with_domain) {
221221
}
222222

223223
TEST(MonMapBuildInitial, build_initial_mon_host_from_dns) {
224-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
224+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
225225
cct->_conf.set_val("mon_host", "ceph.io");
226226
MonMap monmap;
227227
int r = monmap.build_initial(cct.get(), false, std::cerr);
@@ -233,7 +233,7 @@ TEST(MonMapBuildInitial, build_initial_mon_host_from_dns) {
233233
}
234234

235235
TEST(MonMapBuildInitial, build_initial_mon_host_from_dns_fail) {
236-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
236+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
237237
cct->_conf.set_val("mon_host", "ceph.noname");
238238
MonMap monmap;
239239
int r = monmap.build_initial(cct.get(), false, std::cerr);

src/test/rgw/test_rgw_lc.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ TEST(TestLCConfigurationDecoder, XMLDoc5)
186186

187187
struct LCWorkTimeTests : ::testing::Test
188188
{
189-
CephContext* cct;
189+
boost::intrusive_ptr<CephContext> cct;
190190
std::unique_ptr<RGWLC::LCWorker> worker;
191191

192192
// expects input in the form of "%m/%d/%y %H:%M:%S"; e.g., "01/15/23 23:59:01"
@@ -234,15 +234,15 @@ struct LCWorkTimeTests : ::testing::Test
234234
protected:
235235

236236
void SetUp() override {
237-
cct = (new CephContext(CEPH_ENTITY_TYPE_ANY))->get();
237+
cct.reset(new CephContext(CEPH_ENTITY_TYPE_ANY), false);
238238

239239
cct->_conf->set_value("rgw_lc_max_wp_worker", 0, 0); // no need to create a real workpool
240-
worker = std::make_unique<RGWLC::LCWorker>(nullptr, cct, nullptr, 0);
240+
worker = std::make_unique<RGWLC::LCWorker>(nullptr, cct.get(), nullptr, 0);
241241
}
242242

243243
void TearDown() override {
244244
worker.reset();
245-
cct->put();
245+
cct.reset();
246246
}
247247
};
248248

src/test/test_ipaddr.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ TEST(pick_address, filtering)
771771
ipv4(&a_two, "10.2.1.123");
772772
ipv6(&a_three, "2001:1234:5678:90ab::cdef");
773773

774-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
774+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
775775
cct->_conf._clear_safe_to_start_threads(); // so we can set configs
776776

777777
cct->_conf.set_val("public_addr", "");
@@ -943,7 +943,7 @@ TEST(pick_address, ipv4_ipv6_enabled)
943943

944944
ipv4(&a_one, "10.1.1.2");
945945

946-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_OSD);
946+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_OSD), false);
947947
cct->_conf._clear_safe_to_start_threads(); // so we can set configs
948948

949949
cct->_conf.set_val("public_addr", "");
@@ -975,7 +975,7 @@ TEST(pick_address, ipv4_ipv6_enabled2)
975975

976976
ipv6(&a_one, "2001:1234:5678:90ab::cdef");
977977

978-
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_OSD);
978+
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_OSD), false);
979979
cct->_conf._clear_safe_to_start_threads(); // so we can set configs
980980

981981
cct->_conf.set_val("public_addr", "");

0 commit comments

Comments
 (0)