Skip to content

Commit 7822ee4

Browse files
authored
Merge pull request ceph#55984 from xxhdx1985126/wip-rbd-cls-sparsify-test
test/cls_rbd/test_cls_rbd: change to check for 4KB-aligned sparse read Reviewed-by: Mykola Golub <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]>
2 parents ae8ab82 + 6ec3fd9 commit 7822ee4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/test/cls_rbd/test_cls_rbd.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ static bool is_sparse_read_supported(librados::IoCtx &ioctx,
7474
const std::string &oid) {
7575
EXPECT_EQ(0, ioctx.create(oid, true));
7676
bufferlist inbl;
77-
inbl.append(std::string(1, 'X'));
78-
EXPECT_EQ(0, ioctx.write(oid, inbl, inbl.length(), 1));
79-
EXPECT_EQ(0, ioctx.write(oid, inbl, inbl.length(), 3));
77+
inbl.append(std::string(4096, 'X'));
78+
EXPECT_EQ(0, ioctx.write(oid, inbl, inbl.length(), 4096));
79+
EXPECT_EQ(0, ioctx.write(oid, inbl, inbl.length(), 4096 * 3));
8080

8181
std::map<uint64_t, uint64_t> m;
8282
bufferlist outbl;
83-
int r = ioctx.sparse_read(oid, m, outbl, 4, 0);
83+
int r = ioctx.sparse_read(oid, m, outbl, 4096 * 4, 0);
8484
ioctx.remove(oid);
8585

8686
int expected_r = 2;
87-
std::map<uint64_t, uint64_t> expected_m = {{1, 1}, {3, 1}};
87+
std::map<uint64_t, uint64_t> expected_m = {{4096, 4096}, {4096 * 3, 4096}};
8888
bufferlist expected_outbl;
89-
expected_outbl.append(std::string(2, 'X'));
89+
expected_outbl.append(std::string(4096 * 2, 'X'));
9090

9191
return (r == expected_r && m == expected_m &&
9292
outbl.contents_equal(expected_outbl));
@@ -205,7 +205,7 @@ TEST_F(TestClsRbd, sparse_copyup)
205205
// create some data to write
206206
inbl.append(std::string(4096, '1'));
207207
inbl.append(std::string(4096, '2'));
208-
m = {{1024, 4096}, {8192, 4096}};
208+
m = {{4096, 4096}, {4096 * 3, 4096}};
209209

210210
// copyup to nonexistent object should create new object
211211
ioctx.remove(oid);
@@ -214,9 +214,9 @@ TEST_F(TestClsRbd, sparse_copyup)
214214
// and its contents should match
215215
bufferlist outbl;
216216
bufferlist expected_outbl;
217-
expected_outbl.append(std::string(1024, '\0'));
217+
expected_outbl.append(std::string(4096, '\0'));
218218
expected_outbl.append(std::string(4096, '1'));
219-
expected_outbl.append(std::string(8192 - 4096 - 1024, '\0'));
219+
expected_outbl.append(std::string(4096, '\0'));
220220
expected_outbl.append(std::string(4096, '2'));
221221
ASSERT_EQ((int)expected_outbl.length(),
222222
ioctx.read(oid, outbl, expected_outbl.length() + 1, 0));

0 commit comments

Comments
 (0)