]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/crimson/test_monc.cc
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / test / crimson / test_monc.cc
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"
8
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 }
24
25 using namespace std::literals;
26
27 static seastar::future<> test_monc()
28 {
29 return crimson::common::sharded_conf().start(EntityName{}, "ceph"sv).then([] {
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);
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);
41 }).then([] {
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 return seastar::do_with(MonClient{*msgr, dummy_handler},
46 [msgr](auto& monc) mutable {
47 return msgr->start({&monc}).then([&monc] {
48 return seastar::with_timeout(
49 seastar::lowres_clock::now() + std::chrono::seconds{10},
50 monc.start());
51 }).then([&monc] {
52 return monc.stop();
53 });
54 }).finally([msgr] {
55 return msgr->shutdown();
56 });
57 }).finally([] {
58 return crimson::common::sharded_perf_coll().stop().then([] {
59 return crimson::common::sharded_conf().stop();
60 });
61 });
62 }
63
64 int main(int argc, char** argv)
65 {
66 seastar::app_template app;
67 return app.run(argc, argv, [&] {
68 return test_monc().then([] {
69 std::cout << "All tests succeeded" << std::endl;
70 }).handle_exception([] (auto eptr) {
71 std::cout << "Test failure" << std::endl;
72 return seastar::make_exception_future<>(eptr);
73 });
74 });
75 }
76
77
78 /*
79 * Local Variables:
80 * compile-command: "make -j4 \
81 * -C ../../../build \
82 * unittest_seastar_monc"
83 * End:
84 */