]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | #include "test/librbd/test_fixture.h" | |
4 | #include "test/librbd/test_support.h" | |
5 | #include "include/int_types.h" | |
6 | #include "include/stringify.h" | |
7 | #include "include/rados/librados.h" | |
8 | #include "include/rbd/librbd.hpp" | |
9 | #include "common/Cond.h" | |
10 | #include "common/errno.h" | |
11 | #include "common/Mutex.h" | |
12 | #include "common/RWLock.h" | |
13 | #include "cls/lock/cls_lock_client.h" | |
14 | #include "cls/lock/cls_lock_types.h" | |
15 | #include "librbd/internal.h" | |
16 | #include "librbd/ImageCtx.h" | |
17 | #include "librbd/ImageWatcher.h" | |
18 | #include "librbd/WatchNotifyTypes.h" | |
19 | #include "librbd/io/AioCompletion.h" | |
20 | #include "librbd/io/ImageRequestWQ.h" | |
21 | #include "test/librados/test.h" | |
22 | #include "gtest/gtest.h" | |
23 | #include <boost/assign/std/set.hpp> | |
24 | #include <boost/assign/std/map.hpp> | |
25 | #include <boost/bind.hpp> | |
26 | #include <boost/scope_exit.hpp> | |
27 | #include <boost/thread/thread.hpp> | |
28 | #include <iostream> | |
29 | #include <map> | |
30 | #include <set> | |
31 | #include <sstream> | |
32 | #include <vector> | |
33 | ||
34 | using namespace ceph; | |
35 | using namespace boost::assign; | |
36 | using namespace librbd::watch_notify; | |
37 | ||
38 | void register_test_groups() { | |
39 | } | |
40 | ||
41 | class TestLibCG : public TestFixture { | |
42 | ||
43 | }; | |
44 | ||
45 | TEST_F(TestLibCG, group_create) | |
46 | { | |
47 | librados::IoCtx ioctx; | |
48 | ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx)); | |
49 | ||
50 | librbd::RBD rbd; | |
51 | ASSERT_EQ(0, rbd.group_create(ioctx, "mygroup")); | |
52 | ||
53 | vector<string> groups; | |
54 | ASSERT_EQ(0, rbd.group_list(ioctx, &groups)); | |
55 | ASSERT_EQ(1U, groups.size()); | |
56 | ASSERT_EQ("mygroup", groups[0]); | |
57 | ||
58 | ASSERT_EQ(0, rbd.group_remove(ioctx, "mygroup")); | |
59 | ||
60 | groups.clear(); | |
61 | ASSERT_EQ(0, rbd.group_list(ioctx, &groups)); | |
62 | ASSERT_EQ(0U, groups.size()); | |
63 | } | |
64 | ||
65 | TEST_F(TestLibCG, add_image) | |
66 | { | |
67 | librados::IoCtx ioctx; | |
68 | ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx)); | |
69 | ||
70 | const char *group_name = "mycg"; | |
71 | const char *image_name = "myimage"; | |
72 | librbd::RBD rbd; | |
73 | ASSERT_EQ(0, rbd.group_create(ioctx, group_name)); | |
74 | int order = 14; | |
75 | ASSERT_EQ(0, rbd.create2(ioctx, image_name, 65535, | |
76 | RBD_FEATURE_LAYERING, &order)); // Specified features make image of new format. | |
77 | ||
78 | ASSERT_EQ(0, rbd.group_image_add(ioctx, group_name, ioctx, image_name)); | |
79 | ||
80 | vector<librbd::group_image_status_t> images; | |
81 | ASSERT_EQ(0, rbd.group_image_list(ioctx, group_name, &images)); | |
82 | ASSERT_EQ(1U, images.size()); | |
83 | ASSERT_EQ("myimage", images[0].name); | |
84 | ASSERT_EQ(ioctx.get_id(), images[0].pool); | |
85 | ||
86 | ASSERT_EQ(0, rbd.group_image_remove(ioctx, group_name, ioctx, image_name)); | |
87 | ||
88 | images.clear(); | |
89 | ASSERT_EQ(0, rbd.group_image_list(ioctx, group_name, &images)); | |
90 | ASSERT_EQ(0U, images.size()); | |
91 | } |