1 #include <seastar/core/app-template.hh>
2 #include "common/ceph_argparse.h"
3 #include "crimson/common/auth_handler.h"
4 #include "crimson/common/config_proxy.h"
5 #include "crimson/mon/MonClient.h"
6 #include "crimson/net/Connection.h"
7 #include "crimson/net/Messenger.h"
9 using Config
= crimson::common::ConfigProxy
;
10 using MonClient
= crimson::mon::Client
;
14 class DummyAuthHandler
: public crimson::common::AuthHandler
{
16 void handle_authentication(const EntityName
& name
,
17 const AuthCapsInfo
& caps
) final
21 DummyAuthHandler dummy_handler
;
25 using namespace std::literals
;
27 static seastar::future
<> test_monc()
29 return crimson::common::sharded_conf().start(EntityName
{}, "ceph"sv
).then([] {
30 std::vector
<const char*> args
;
32 std::string conf_file_list
;
33 auto init_params
= ceph_argparse_early_args(args
,
34 CEPH_ENTITY_TYPE_CLIENT
,
37 auto& conf
= crimson::common::local_conf();
38 conf
->name
= init_params
.name
;
39 conf
->cluster
= cluster
;
40 return conf
.parse_config_files(conf_file_list
);
42 return crimson::common::sharded_perf_coll().start();
43 }).then([]() mutable {
44 auto msgr
= crimson::net::Messenger::create(entity_name_t::OSD(0), "monc", 0);
45 auto& conf
= crimson::common::local_conf();
46 if (conf
->ms_crc_data
) {
49 if (conf
->ms_crc_header
) {
50 msgr
->set_crc_header();
52 msgr
->set_require_authorizer(false);
53 return seastar::do_with(MonClient
{*msgr
, dummy_handler
},
54 [msgr
](auto& monc
) mutable {
55 return msgr
->start({&monc
}).then([&monc
] {
56 return seastar::with_timeout(
57 seastar::lowres_clock::now() + std::chrono::seconds
{10},
63 return msgr
->shutdown();
66 return crimson::common::sharded_perf_coll().stop().then([] {
67 return crimson::common::sharded_conf().stop();
72 int main(int argc
, char** argv
)
74 seastar::app_template app
;
75 return app
.run(argc
, argv
, [&] {
76 return test_monc().then([] {
77 std::cout
<< "All tests succeeded" << std::endl
;
78 }).handle_exception([] (auto eptr
) {
79 std::cout
<< "Test failure" << std::endl
;
80 return seastar::make_exception_future
<>(eptr
);
88 * compile-command: "make -j4 \
90 * unittest_seastar_monc"