]>
Commit | Line | Data |
---|---|---|
224ce89b WB |
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" | |
6 | ||
7 | #include <algorithm> | |
8 | #include <errno.h> | |
9 | #include "gtest/gtest.h" | |
10 | #include "test/unit.cc" | |
11 | ||
12 | using namespace librados; | |
13 | ||
14 | TEST(LibRadosServicePP, RegisterEarly) { | |
15 | Rados cluster; | |
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()); | |
25 | sleep(5); | |
26 | cluster.shutdown(); | |
27 | } | |
28 | ||
29 | TEST(LibRadosServicePP, RegisterLate) { | |
30 | Rados cluster; | |
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"}})); | |
38 | } | |
39 | ||
40 | TEST(LibRadosServicePP, Status) { | |
41 | Rados cluster; | |
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)} | |
55 | })); | |
56 | sleep(1); | |
57 | } | |
58 | cluster.shutdown(); | |
59 | } |