]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/rgw/test_rgw_common.cc
import ceph quincy 17.2.6
[ceph.git] / ceph / src / test / rgw / test_rgw_common.cc
1 #include "test_rgw_common.h"
2
3 void test_rgw_add_placement(RGWZoneGroup *zonegroup, RGWZoneParams *zone_params, const std::string& name, bool is_default)
4 {
5 zonegroup->placement_targets[name] = { name };
6
7 RGWZonePlacementInfo& pinfo = zone_params->placement_pools[name];
8 pinfo.index_pool = rgw_pool(name + ".index").to_str();
9
10 rgw_pool data_pool(name + ".data");
11 pinfo.storage_classes.set_storage_class(RGW_STORAGE_CLASS_STANDARD, &data_pool, nullptr);
12 pinfo.data_extra_pool = rgw_pool(name + ".extra").to_str();
13
14 if (is_default) {
15 zonegroup->default_placement = rgw_placement_rule(name, RGW_STORAGE_CLASS_STANDARD);
16 }
17 }
18
19 void test_rgw_init_env(RGWZoneGroup *zonegroup, RGWZoneParams *zone_params)
20 {
21 test_rgw_add_placement(zonegroup, zone_params, "default-placement", true);
22
23 }
24
25 void test_rgw_populate_explicit_placement_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
26 {
27 b->tenant = t;
28 b->name = n;
29 b->marker = m;
30 b->bucket_id = id;
31 b->explicit_placement.data_pool = rgw_pool(dp);
32 b->explicit_placement.index_pool = rgw_pool(ip);
33 }
34
35 void test_rgw_populate_old_bucket(old_rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
36 {
37 b->tenant = t;
38 b->name = n;
39 b->marker = m;
40 b->bucket_id = id;
41 b->data_pool = dp;
42 b->index_pool = ip;
43 }
44
45 std::string test_rgw_get_obj_oid(const rgw_obj& obj)
46 {
47 std::string oid;
48 std::string loc;
49
50 get_obj_bucket_and_oid_loc(obj, oid, loc);
51 return oid;
52 }
53
54 void test_rgw_init_explicit_placement_bucket(rgw_bucket *bucket, const char *name)
55 {
56 test_rgw_populate_explicit_placement_bucket(bucket, "", name, ".data-pool", ".index-pool", "marker", "bucket-id");
57 }
58
59 void test_rgw_init_old_bucket(old_rgw_bucket *bucket, const char *name)
60 {
61 test_rgw_populate_old_bucket(bucket, "", name, ".data-pool", ".index-pool", "marker", "bucket-id");
62 }
63
64 void test_rgw_populate_bucket(rgw_bucket *b, const char *t, const char *n, const char *m, const char *id)
65 {
66 b->tenant = t;
67 b->name = n;
68 b->marker = m;
69 b->bucket_id = id;
70 }
71
72 void test_rgw_init_bucket(rgw_bucket *bucket, const char *name)
73 {
74 test_rgw_populate_bucket(bucket, "", name, "marker", "bucket-id");
75 }
76
77 rgw_obj test_rgw_create_obj(const rgw_bucket& bucket, const std::string& name, const std::string& instance, const std::string& ns)
78 {
79 rgw_obj obj(bucket, name);
80 if (!instance.empty()) {
81 obj.key.set_instance(instance);
82 }
83 if (!ns.empty()) {
84 obj.key.ns = ns;
85 }
86 obj.bucket = bucket;
87
88 return obj;
89 }
90
91