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