usleep(1);
}
- m_cache_client->lookup_object("test_pool", 1, 2, "123456", ctx);
+ m_cache_client->lookup_object("pool_nspace", 1, 2, "object_name", ctx);
m_send_request_index++;
}
m_wait_event.wait();
}
- bool startup_lookupobject_testing(std::string pool_name, std::string object_id) {
+ bool startup_lookupobject_testing(std::string pool_nspace, std::string object_id) {
bool hit;
auto ctx = new LambdaGenContext<std::function<void(ObjectCacheRequest*)>,
ObjectCacheRequest*>([this, &hit](ObjectCacheRequest* ack){
hit = ack->m_head.type == RBDSC_READ_REPLY;
m_wait_event.signal();
});
- m_cache_client->lookup_object(pool_name, 1, 2, object_id, ctx);
+ m_cache_client->lookup_object(pool_nspace, 1, 2, object_id, ctx);
m_wait_event.wait();
return hit;
}
- void set_hit_entry_in_fake_lru(std::string oid) {
- if (m_hit_entry_set.find(oid) == m_hit_entry_set.end()) {
- m_hit_entry_set.insert(oid);
+ void set_hit_entry_in_fake_lru(std::string cache_file_name) {
+ if (m_hit_entry_set.find(cache_file_name) == m_hit_entry_set.end()) {
+ m_hit_entry_set.insert(cache_file_name);
}
}
};
TEST_F(TestCommunication, test_pingpong) {
- startup_pingpong_testing(10, 16, 0);
+ startup_pingpong_testing(64, 16, 0);
ASSERT_TRUE(m_send_request_index == m_recv_ack_index);
startup_pingpong_testing(200, 128, 0);
ASSERT_TRUE(m_send_request_index == m_recv_ack_index);
}
for (uint64_t i = 50; i < 100; i++) {
if ((random_hit % i) != 0) {
- ASSERT_FALSE(startup_lookupobject_testing("test_pool", std::to_string(i)));
+ ASSERT_FALSE(startup_lookupobject_testing("test_nspace", std::to_string(i)));
} else {
- ASSERT_TRUE(startup_lookupobject_testing("test_pool", std::to_string(i)));
+ ASSERT_TRUE(startup_lookupobject_testing("test_nspace", std::to_string(i)));
}
}
}
TEST(test_for_message, test_1)
{
+ std::string pool_nspace("this is a pool namespace");
std::string oid_name("this is a oid name");
+ std::string cache_file_path("/temp/ceph_immutable_object_cache");
ObjectCacheMsgHeader header;
header.seq = 1;
header.type = 2;
header.version =3;
- header.data_len = 5;
- header.reserved = 6;
+ header.data_len = 0;
+ header.reserved = 5;
ObjectCacheRequest req;
req.m_data.m_read_offset = 222222;
req.m_data.m_read_len = 333333;
+ req.m_data.m_pool_id = 444444;
+ req.m_data.m_snap_id = 555555;
req.m_data.m_oid = oid_name;
+ req.m_data.m_pool_namespace = pool_nspace;
+ req.m_data.m_cache_path = cache_file_path;
+ // ObjectRequest --> bufferlist
req.encode();
ASSERT_EQ(req.m_head_buffer.length(), sizeof(req.m_head));
-
ObjectCacheRequest* req_decode;
- auto x = req.get_head_buffer();
- auto z = req.get_data_buffer();
+ auto head_bl = req.get_head_buffer();
+ auto data_bl = req.get_data_buffer();
- req_decode = decode_object_cache_request(x, z);
+ // bufferlist --> ObjectCacheRequest
+ req_decode = decode_object_cache_request(head_bl, data_bl);
ASSERT_EQ(req_decode->m_head.seq, header.seq);
+ ASSERT_EQ(req_decode->m_head.seq, 1);
ASSERT_EQ(req_decode->m_head.type, header.type);
+ ASSERT_EQ(req_decode->m_head.type, 2);
ASSERT_EQ(req_decode->m_head.version, header.version);
+ ASSERT_EQ(req_decode->m_head.version, 3);
ASSERT_EQ(req_decode->m_head.data_len, req.m_data_buffer.length());
+ ASSERT_EQ(req_decode->m_head.data_len, data_bl.length());
ASSERT_EQ(req_decode->m_head.reserved, header.reserved);
+ ASSERT_EQ(req_decode->m_head.reserved, 5);
-
+ ASSERT_EQ(req_decode->m_data.m_read_offset, req.m_data.m_read_offset);
ASSERT_EQ(req_decode->m_data.m_read_offset, 222222);
+ ASSERT_EQ(req_decode->m_data.m_read_len, req.m_data.m_read_len);
ASSERT_EQ(req_decode->m_data.m_read_len, 333333);
+ ASSERT_EQ(req_decode->m_data.m_pool_namespace, req.m_data.m_pool_namespace);
+ ASSERT_EQ(req_decode->m_data.m_pool_namespace, pool_nspace);
+ ASSERT_EQ(req_decode->m_data.m_cache_path, req.m_data.m_cache_path);
+ ASSERT_EQ(req_decode->m_data.m_cache_path, cache_file_path);
+ ASSERT_EQ(req_decode->m_data.m_oid, req.m_data.m_oid);
ASSERT_EQ(req_decode->m_data.m_oid, oid_name);
+
+ delete req_decode;
}
ASSERT_TRUE(session->is_session_work());
}
- void test_lookup_object(std::string pool, uint64_t index, uint64_t request_num, bool is_last) {
+ void test_lookup_object(std::string pool_nspace, uint64_t index,
+ uint64_t request_num, bool is_last) {
for (uint64_t i = 0; i < request_num; i++) {
auto ctx = new LambdaGenContext<std::function<void(ObjectCacheRequest*)>,
});
m_send_request_index++;
// here just for concurrently testing register + lookup, so fix object id.
- m_cache_client_vec[index]->lookup_object(pool, 1, 2, "1234", ctx);
+ m_cache_client_vec[index]->lookup_object(pool_nspace, 1, 2, "1234", ctx);
}
if (is_last) {
if (m_cache_client_vec[random_index] == nullptr) {
test_register_client(random_index);
} else {
- test_lookup_object(string("test_pool") + std::to_string(random_index), random_index, 32, i == test_times ? true : false);
+ test_lookup_object(string("test_nspace") + std::to_string(random_index),
+ random_index, 32, i == test_times ? true : false);
}
}