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
|
#include "gtest/gtest.h"
#include "global/global_context.h"
#include "osdc/Striper.h"
TEST(Striper, Stripe1)
{
file_layout_t l;
l.object_size = 262144;
l.stripe_unit = 4096;
l.stripe_count = 3;
vector<ObjectExtent> ex;
Striper::file_to_extents(g_ceph_context, 1, &l, 5006035, 46419, 5006035, ex);
cout << "result " << ex << std::endl;
ASSERT_EQ(3u, ex.size());
ASSERT_EQ(98304u, ex[0].truncate_size);
ASSERT_EQ(ex[1].offset, ex[1].truncate_size);
ASSERT_EQ(94208u, ex[2].truncate_size);
}
TEST(Striper, EmptyPartialResult)
{
file_layout_t l;
l.object_size = 4194304;
l.stripe_unit = 4194304;
l.stripe_count = 1;
vector<ObjectExtent> ex;
Striper::file_to_extents(g_ceph_context, 1, &l, 725549056, 131072, 72554905600, ex);
cout << "ex " << ex << std::endl;
ASSERT_EQ(2u, ex.size());
Striper::StripedReadResult r;
bufferlist bl;
r.add_partial_result(g_ceph_context, bl, ex[1].buffer_extents);
bufferptr bp(65536);
bp.zero();
bl.append(bp);
r.add_partial_result(g_ceph_context, bl, ex[0].buffer_extents);
bufferlist outbl;
r.assemble_result(g_ceph_context, outbl, false);
ASSERT_EQ(65536u, outbl.length());
}
TEST(Striper, GetNumObj)
{
file_layout_t l;
l.object_size = 262144;
l.stripe_unit = 4096;
l.stripe_count = 3;
uint64_t size,numobjs;
size = 6999;
numobjs = Striper::get_num_objects(l, size);
ASSERT_EQ(2u, numobjs);
size = 793320;
numobjs = Striper::get_num_objects(l, size);
ASSERT_EQ(5u, numobjs);
size = 805608;
numobjs = Striper::get_num_objects(l, size);
ASSERT_EQ(6u, numobjs);
}
|