]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/librados/service.cc
1 #include "include/rados/librados.h"
2 #include "include/rados/librados.hpp"
3 #include "test/librados/test.h"
4 #include "test/librados/TestCase.h"
5 #include "include/stringify.h"
9 #include "gtest/gtest.h"
10 #include "test/unit.cc"
12 using namespace librados
;
14 TEST(LibRadosServicePP
, RegisterEarly
) {
16 cluster
.init("admin");
17 ASSERT_EQ(0, cluster
.conf_read_file(NULL
));
18 cluster
.conf_parse_env(NULL
);
19 string name
= string("pid") + stringify(getpid());
20 ASSERT_EQ(0, cluster
.service_daemon_register(
21 "laundry", name
, {{"foo", "bar"}, {"this", "that"}}));
22 ASSERT_EQ(-EEXIST
, cluster
.service_daemon_register(
23 "laundry", name
, {{"foo", "bar"}, {"this", "that"}}));
24 ASSERT_EQ(0, cluster
.connect());
29 TEST(LibRadosServicePP
, RegisterLate
) {
31 cluster
.init("admin");
32 ASSERT_EQ(0, cluster
.conf_read_file(NULL
));
33 cluster
.conf_parse_env(NULL
);
34 ASSERT_EQ("", connect_cluster_pp(cluster
));
35 string name
= string("pid") + stringify(getpid());
36 ASSERT_EQ(0, cluster
.service_daemon_register(
37 "laundry", name
, {{"foo", "bar"}, {"this", "that"}}));
40 TEST(LibRadosServicePP
, Status
) {
42 cluster
.init("admin");
43 ASSERT_EQ(0, cluster
.conf_read_file(NULL
));
44 cluster
.conf_parse_env(NULL
);
45 string name
= string("pid") + stringify(getpid());
46 ASSERT_EQ(-ENOTCONN
, cluster
.service_daemon_update_status(
47 {{"testing", "starting"}}));
48 ASSERT_EQ(0, cluster
.connect());
49 ASSERT_EQ(0, cluster
.service_daemon_register(
50 "laundry", name
, {{"foo", "bar"}, {"this", "that"}}));
51 for (int i
=0; i
<20; ++i
) {
52 ASSERT_EQ(0, cluster
.service_daemon_update_status({
53 {"testing", "running"},
54 {"count", stringify(i
)}