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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
#include "gtest/gtest.h"
#include "include/rados/librados.hpp"
#include "test/librados/test_cxx.h"
#include "test/librados/testcase_cxx.h"
#include "crimson_utils.h"
using namespace librados;
typedef RadosTestPP LibRadosStatPP;
typedef RadosTestECPP LibRadosStatECPP;
TEST_F(LibRadosStatPP, StatPP) {
char buf[128];
memset(buf, 0xcc, sizeof(buf));
bufferlist bl;
bl.append(buf, sizeof(buf));
ASSERT_EQ(0, ioctx.write("foo", bl, sizeof(buf), 0));
uint64_t size;
time_t mtime;
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf), size);
ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
}
TEST_F(LibRadosStatPP, Stat2Mtime2PP) {
char buf[128];
memset(buf, 0xcc, sizeof(buf));
bufferlist bl;
bl.append(buf, sizeof(buf));
librados::ObjectWriteOperation op;
struct timespec ts;
ts.tv_sec = 1457129052;
ts.tv_nsec = 123456789;
op.mtime2(&ts);
op.write(0, bl);
ASSERT_EQ(0, ioctx.operate("foo", &op));
/* XXX time comparison asserts could spuriously fail */
uint64_t size;
time_t mtime;
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf), size);
ASSERT_EQ(mtime, ts.tv_sec);
struct timespec ts2;
ASSERT_EQ(0, ioctx.stat2("foo", &size, &ts2));
ASSERT_EQ(sizeof(buf), size);
ASSERT_EQ(ts2.tv_sec, ts.tv_sec);
ASSERT_EQ(ts2.tv_nsec, ts.tv_nsec);
ASSERT_EQ(-ENOENT, ioctx.stat2("nonexistent", &size, &ts2));
}
TEST_F(LibRadosStatPP, ClusterStatPP) {
cluster_stat_t cstat;
ASSERT_EQ(0, cluster.cluster_stat(cstat));
}
TEST_F(LibRadosStatPP, PoolStatPP) {
std::string n = ioctx.get_pool_name();
ASSERT_EQ(n, pool_name);
char buf[128];
memset(buf, 0xff, sizeof(buf));
bufferlist bl1;
bl1.append(buf, sizeof(buf));
ASSERT_EQ(0, ioctx.write("foo", bl1, sizeof(buf), 0));
std::list<std::string> v;
std::map<std::string,stats_map> stats;
ASSERT_EQ(0, cluster.get_pool_stats(v, stats));
}
TEST_F(LibRadosStatECPP, StatPP) {
SKIP_IF_CRIMSON();
char buf[128];
memset(buf, 0xcc, sizeof(buf));
bufferlist bl;
bl.append(buf, sizeof(buf));
ASSERT_EQ(0, ioctx.write("foo", bl, sizeof(buf), 0));
uint64_t size;
time_t mtime;
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf), size);
ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
}
TEST_F(LibRadosStatECPP, ClusterStatPP) {
SKIP_IF_CRIMSON();
cluster_stat_t cstat;
ASSERT_EQ(0, cluster.cluster_stat(cstat));
}
TEST_F(LibRadosStatECPP, PoolStatPP) {
SKIP_IF_CRIMSON();
std::string n = ioctx.get_pool_name();
ASSERT_EQ(n, pool_name);
char buf[128];
memset(buf, 0xff, sizeof(buf));
bufferlist bl1;
bl1.append(buf, sizeof(buf));
ASSERT_EQ(0, ioctx.write("foo", bl1, sizeof(buf), 0));
std::list<std::string> v;
std::map<std::string,stats_map> stats;
ASSERT_EQ(0, cluster.get_pool_stats(v, stats));
}
TEST_F(LibRadosStatPP, StatPPNS) {
char buf[128];
memset(buf, 0xcc, sizeof(buf));
bufferlist bl;
bl.append(buf, sizeof(buf));
ioctx.set_namespace("");
ASSERT_EQ(0, ioctx.write("foo", bl, sizeof(buf), 0));
ASSERT_EQ(0, ioctx.write("foo2", bl, sizeof(buf), 0));
char buf2[64];
memset(buf2, 0xbb, sizeof(buf2));
bufferlist bl2;
bl2.append(buf2, sizeof(buf2));
ioctx.set_namespace("nspace");
ASSERT_EQ(0, ioctx.write("foo", bl2, sizeof(buf2), 0));
uint64_t size;
time_t mtime;
ioctx.set_namespace("");
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf), size);
ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
ioctx.set_namespace("nspace");
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf2), size);
ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
ASSERT_EQ(-ENOENT, ioctx.stat("foo2", &size, &mtime));
}
TEST_F(LibRadosStatECPP, StatPPNS) {
SKIP_IF_CRIMSON();
char buf[128];
memset(buf, 0xcc, sizeof(buf));
bufferlist bl;
bl.append(buf, sizeof(buf));
ioctx.set_namespace("");
ASSERT_EQ(0, ioctx.write("foo", bl, sizeof(buf), 0));
ASSERT_EQ(0, ioctx.write("foo2", bl, sizeof(buf), 0));
char buf2[64];
memset(buf2, 0xbb, sizeof(buf2));
bufferlist bl2;
bl2.append(buf2, sizeof(buf2));
ioctx.set_namespace("nspace");
ASSERT_EQ(0, ioctx.write("foo", bl2, sizeof(buf2), 0));
uint64_t size;
time_t mtime;
ioctx.set_namespace("");
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf), size);
ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
ioctx.set_namespace("nspace");
ASSERT_EQ(0, ioctx.stat("foo", &size, &mtime));
ASSERT_EQ(sizeof(buf2), size);
ASSERT_EQ(-ENOENT, ioctx.stat("nonexistent", &size, &mtime));
ASSERT_EQ(-ENOENT, ioctx.stat("foo2", &size, &mtime));
}
|