Skip to content

Commit

Permalink
Merge pull request ceph#56540 from tchaikov/wip-fix-test-leaks-ceph-c…
Browse files Browse the repository at this point in the history
…ontext

test: : do not increase ref when creating intrusive_ptr<CephContext>

Reviewed-by: Casey Bodley <[email protected]>
  • Loading branch information
tchaikov authored Mar 29, 2024
2 parents 0e3c55c + d3c5a4a commit 6237328
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/test/mon/MonMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TEST_F(MonMapTest, DISABLED_build_initial_config_from_dns) {



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

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



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

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

TEST(MonMapBuildInitial, build_initial_mon_host_from_dns_fail) {
boost::intrusive_ptr<CephContext> cct = new CephContext(CEPH_ENTITY_TYPE_MON);
boost::intrusive_ptr<CephContext> cct(new CephContext(CEPH_ENTITY_TYPE_MON), false);
cct->_conf.set_val("mon_host", "ceph.noname");
MonMap monmap;
int r = monmap.build_initial(cct.get(), false, std::cerr);
Expand Down
8 changes: 4 additions & 4 deletions src/test/rgw/test_rgw_lc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ TEST(TestLCConfigurationDecoder, XMLDoc5)

struct LCWorkTimeTests : ::testing::Test
{
CephContext* cct;
boost::intrusive_ptr<CephContext> cct;
std::unique_ptr<RGWLC::LCWorker> worker;

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

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

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

void TearDown() override {
worker.reset();
cct->put();
cct.reset();
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/test/test_ipaddr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ TEST(pick_address, filtering)
ipv4(&a_two, "10.2.1.123");
ipv6(&a_three, "2001:1234:5678:90ab::cdef");

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

cct->_conf.set_val("public_addr", "");
Expand Down Expand Up @@ -943,7 +943,7 @@ TEST(pick_address, ipv4_ipv6_enabled)

ipv4(&a_one, "10.1.1.2");

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

cct->_conf.set_val("public_addr", "");
Expand Down Expand Up @@ -975,7 +975,7 @@ TEST(pick_address, ipv4_ipv6_enabled2)

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

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

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

0 comments on commit 6237328

Please sign in to comment.