]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | #include <seastar/core/app-template.hh> |
2 | #include "common/ceph_argparse.h" | |
9f95a23c | 3 | #include "crimson/common/auth_handler.h" |
11fdf7f2 TL |
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" | |
8 | ||
9f95a23c TL |
9 | using Config = crimson::common::ConfigProxy; |
10 | using MonClient = crimson::mon::Client; | |
11 | ||
12 | namespace { | |
13 | ||
14 | class DummyAuthHandler : public crimson::common::AuthHandler { | |
15 | public: | |
16 | void handle_authentication(const EntityName& name, | |
17 | const AuthCapsInfo& caps) final | |
18 | {} | |
19 | }; | |
20 | ||
21 | DummyAuthHandler dummy_handler; | |
22 | ||
23 | } | |
11fdf7f2 TL |
24 | |
25 | static seastar::future<> test_monc() | |
26 | { | |
9f95a23c | 27 | return crimson::common::sharded_conf().start(EntityName{}, string_view{"ceph"}).then([] { |
11fdf7f2 TL |
28 | std::vector<const char*> args; |
29 | std::string cluster; | |
30 | std::string conf_file_list; | |
31 | auto init_params = ceph_argparse_early_args(args, | |
32 | CEPH_ENTITY_TYPE_CLIENT, | |
33 | &cluster, | |
34 | &conf_file_list); | |
9f95a23c | 35 | auto& conf = crimson::common::local_conf(); |
11fdf7f2 TL |
36 | conf->name = init_params.name; |
37 | conf->cluster = cluster; | |
38 | return conf.parse_config_files(conf_file_list); | |
39 | }).then([] { | |
9f95a23c | 40 | return crimson::common::sharded_perf_coll().start(); |
11fdf7f2 | 41 | }).then([] { |
9f95a23c TL |
42 | auto msgr = crimson::net::Messenger::create(entity_name_t::OSD(0), "monc", 0); |
43 | auto& conf = crimson::common::local_conf(); | |
44 | if (conf->ms_crc_data) { | |
45 | msgr->set_crc_data(); | |
46 | } | |
47 | if (conf->ms_crc_header) { | |
48 | msgr->set_crc_header(); | |
49 | } | |
50 | msgr->set_require_authorizer(false); | |
51 | return seastar::do_with(MonClient{*msgr, dummy_handler}, | |
52 | [msgr](auto& monc) { | |
53 | return msgr->start(&monc).then([&monc] { | |
54 | return seastar::with_timeout( | |
55 | seastar::lowres_clock::now() + std::chrono::seconds{10}, | |
56 | monc.start()); | |
57 | }).then([&monc] { | |
58 | return monc.stop(); | |
11fdf7f2 | 59 | }); |
9f95a23c TL |
60 | }).finally([msgr] { |
61 | return msgr->shutdown(); | |
11fdf7f2 TL |
62 | }); |
63 | }).finally([] { | |
9f95a23c TL |
64 | return crimson::common::sharded_perf_coll().stop().then([] { |
65 | return crimson::common::sharded_conf().stop(); | |
11fdf7f2 TL |
66 | }); |
67 | }); | |
68 | } | |
69 | ||
70 | int main(int argc, char** argv) | |
71 | { | |
72 | seastar::app_template app; | |
73 | return app.run(argc, argv, [&] { | |
74 | return test_monc().then([] { | |
75 | std::cout << "All tests succeeded" << std::endl; | |
76 | }).handle_exception([] (auto eptr) { | |
77 | std::cout << "Test failure" << std::endl; | |
78 | return seastar::make_exception_future<>(eptr); | |
79 | }); | |
80 | }); | |
81 | } | |
82 | ||
83 | ||
84 | /* | |
85 | * Local Variables: | |
86 | * compile-command: "make -j4 \ | |
87 | * -C ../../../build \ | |
88 | * unittest_seastar_monc" | |
89 | * End: | |
90 | */ |