]>
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 | 24 | |
20effc67 TL |
25 | using namespace std::literals; |
26 | ||
11fdf7f2 TL |
27 | static seastar::future<> test_monc() |
28 | { | |
20effc67 | 29 | return crimson::common::sharded_conf().start(EntityName{}, "ceph"sv).then([] { |
11fdf7f2 TL |
30 | std::vector<const char*> args; |
31 | std::string cluster; | |
32 | std::string conf_file_list; | |
33 | auto init_params = ceph_argparse_early_args(args, | |
34 | CEPH_ENTITY_TYPE_CLIENT, | |
35 | &cluster, | |
36 | &conf_file_list); | |
9f95a23c | 37 | auto& conf = crimson::common::local_conf(); |
11fdf7f2 TL |
38 | conf->name = init_params.name; |
39 | conf->cluster = cluster; | |
40 | return conf.parse_config_files(conf_file_list); | |
41 | }).then([] { | |
9f95a23c | 42 | return crimson::common::sharded_perf_coll().start(); |
f67539c2 | 43 | }).then([]() mutable { |
9f95a23c TL |
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) { | |
47 | msgr->set_crc_data(); | |
48 | } | |
49 | if (conf->ms_crc_header) { | |
50 | msgr->set_crc_header(); | |
51 | } | |
52 | msgr->set_require_authorizer(false); | |
53 | return seastar::do_with(MonClient{*msgr, dummy_handler}, | |
f67539c2 TL |
54 | [msgr](auto& monc) mutable { |
55 | return msgr->start({&monc}).then([&monc] { | |
9f95a23c TL |
56 | return seastar::with_timeout( |
57 | seastar::lowres_clock::now() + std::chrono::seconds{10}, | |
58 | monc.start()); | |
59 | }).then([&monc] { | |
60 | return monc.stop(); | |
11fdf7f2 | 61 | }); |
9f95a23c TL |
62 | }).finally([msgr] { |
63 | return msgr->shutdown(); | |
11fdf7f2 TL |
64 | }); |
65 | }).finally([] { | |
9f95a23c TL |
66 | return crimson::common::sharded_perf_coll().stop().then([] { |
67 | return crimson::common::sharded_conf().stop(); | |
11fdf7f2 TL |
68 | }); |
69 | }); | |
70 | } | |
71 | ||
72 | int main(int argc, char** argv) | |
73 | { | |
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); | |
81 | }); | |
82 | }); | |
83 | } | |
84 | ||
85 | ||
86 | /* | |
87 | * Local Variables: | |
88 | * compile-command: "make -j4 \ | |
89 | * -C ../../../build \ | |
90 | * unittest_seastar_monc" | |
91 | * End: | |
92 | */ |