]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/librados/cls_remote_reads.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / test / librados / cls_remote_reads.cc
CommitLineData
20effc67
TL
1#include <set>
2#include <string>
3
4#include "common/ceph_json.h"
5#include "gtest/gtest.h"
6#include "test/librados/test_cxx.h"
7
1e59de90
TL
8#include "crimson_utils.h"
9
20effc67
TL
10using namespace librados;
11
12TEST(ClsTestRemoteReads, TestGather) {
1e59de90 13 SKIP_IF_CRIMSON();
20effc67
TL
14 Rados cluster;
15 std::string pool_name = get_temp_pool_name();
16 ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
17 IoCtx ioctx;
18 cluster.ioctx_create(pool_name.c_str(), ioctx);
19
20 bufferlist in, out;
21 int object_size = 4096;
22 char buf[object_size];
23 memset(buf, 1, sizeof(buf));
24
25 // create source objects from which data are gathered
26 in.append(buf, sizeof(buf));
27 ASSERT_EQ(0, ioctx.write_full("src_object.1", in));
28 in.append(buf, sizeof(buf));
29 ASSERT_EQ(0, ioctx.write_full("src_object.2", in));
30 in.append(buf, sizeof(buf));
31 ASSERT_EQ(0, ioctx.write_full("src_object.3", in));
32
33 // construct JSON request passed to "test_gather" method, and in turn, to "test_read" method
34 JSONFormatter *formatter = new JSONFormatter(true);
35 formatter->open_object_section("foo");
36 std::set<std::string> src_objects;
37 src_objects.insert("src_object.1");
38 src_objects.insert("src_object.2");
39 src_objects.insert("src_object.3");
40 encode_json("src_objects", src_objects, formatter);
41 encode_json("cls", "test_remote_reads", formatter);
42 encode_json("method", "test_read", formatter);
43 encode_json("pool", pool_name, formatter);
44 formatter->close_section();
45 in.clear();
46 formatter->flush(in);
47
48 // create target object by combining data gathered from source objects using "test_read" method
49 ASSERT_EQ(0, ioctx.exec("tgt_object", "test_remote_reads", "test_gather", in, out));
50
51 // read target object and check its size
52 ASSERT_EQ(3*object_size, ioctx.read("tgt_object", out, 0, 0));
53
54 ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
55}