Created
February 14, 2022 12:41
-
-
Save ronen-fr/77508cf73b78ef878b90873a0f1eb1dd to your computer and use it in GitHub Desktop.
question re test_scrubber_be.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gtest/gtest.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include "common/async/context_pool.h" | |
#include "common/ceph_argparse.h" | |
#include "mon/MonClient.h" | |
#include "msg/Messenger.h" | |
#include "os/ObjectStore.h" | |
#include "osd/OSD.h" | |
// testing isolated parts pf the Scrubber backend | |
class TestOSDScrub : public OSD { | |
// public: | |
// static std::unique_ptr<TestOSDScrub> create(int osd_id); | |
public: | |
TestOSDScrub(std::unique_ptr<ObjectStore> store, | |
int id, | |
Messenger* msgrs, | |
Messenger* osdc_messenger, | |
MonClient* mc, | |
const std::string& dev, | |
const std::string& jdev, | |
ceph::async::io_context_pool& ictx) | |
: OSD(g_ceph_context, | |
std::move(store), | |
id, | |
msgrs, | |
msgrs, | |
msgrs, | |
msgrs, | |
msgrs, | |
msgrs, | |
osdc_messenger, | |
mc, | |
dev, | |
jdev, | |
ictx) | |
{} | |
bool scrub_time_permit(utime_t now) | |
{ | |
return service.get_scrub_services().scrub_time_permit(now); | |
} | |
}; | |
using test_osd_t = std::unique_ptr<TestOSDScrub>; | |
class ScrubberBeTest : public ::testing::Test { | |
public: | |
// ScrubberBeTest(int num_osd) {} // for now - handle only 1 | |
void SetUp() override; | |
void TearDown() override; | |
//~ScrubberBeTest() { m_osd.reset() ; } | |
public: | |
std::string cluster_msgr_type{g_conf()->ms_cluster_type.empty() | |
? g_conf().get_val<std::string>("ms_type") | |
: g_conf()->ms_cluster_type}; | |
ceph::async::io_context_pool m_icp{5}; | |
std::unique_ptr<ObjectStore> m_store; | |
MonClient* mc; | |
test_osd_t m_osd; | |
test_osd_t create_member_osd(int osd_id); | |
}; | |
void ScrubberBeTest::SetUp() | |
{ | |
g_ceph_context->_conf.set_val("osd_fast_shutdown", "false"); | |
g_ceph_context->_conf.set_val("osd_fast_shutdown", "0"); | |
m_osd = create_member_osd(0); | |
} | |
void ScrubberBeTest::TearDown() | |
{ | |
//m_icp.finish(); | |
//std::cout << "micp" << std::endl; | |
sleep(2); | |
// must not: not started m_osd->service.agent_stop(); | |
m_osd->shutdown(); | |
std::cout << "stop" << std::endl; | |
sleep(2); | |
m_osd.reset(); | |
std::cout << "mosd" << std::endl; | |
sleep(2); | |
} | |
test_osd_t ScrubberBeTest::create_member_osd(int osd_id) | |
{ | |
// create a new ObjectStore | |
m_store = ObjectStore::create(g_ceph_context, | |
g_conf()->osd_objectstore, | |
g_conf()->osd_data, | |
g_conf()->osd_journal); | |
// will we need access to the messenger? | |
Messenger* ms = Messenger::create(g_ceph_context, | |
cluster_msgr_type, | |
entity_name_t::OSD(0), // verify the '0' | |
"make_checker", | |
getpid()); | |
ms->set_cluster_protocol(CEPH_OSD_PROTOCOL); | |
ms->set_default_policy(Messenger::Policy::stateless_server(0)); | |
ms->bind(g_conf()->public_addr); | |
mc = new MonClient(g_ceph_context, m_icp); | |
mc->build_initial_monmap(); | |
// create a new OSD | |
return std::make_unique<TestOSDScrub>(std::move(m_store), | |
osd_id, | |
ms, | |
ms, | |
mc, | |
g_conf()->osd_data, | |
g_conf()->osd_journal, | |
m_icp); | |
} | |
TEST_F(ScrubberBeTest, tac) | |
{ | |
// ScrubberBeTest* sbt = new ScrubberBeTest(1); | |
ASSERT_TRUE(m_osd); | |
// sbt.m_osd->shutdown(); | |
// sbt->m_osd.reset(); | |
// delete sbt.mc; | |
sleep(2); | |
// sbt.m_icp.stop(); | |
// sleep(2); | |
ASSERT_TRUE(true); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment