From 648e3b12f06be13cabd361903a96445b7dd59846 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 17 May 2026 02:44:00 +0300 Subject: [PATCH] Replace public/protected ifdef with a friend class --- src/client/cluster_client.h | 7 +------ src/test/CMakeLists.txt | 1 + src/test/test_cluster_client.cpp | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/client/cluster_client.h b/src/client/cluster_client.h index 52dafb32..88e0393b 100644 --- a/src/client/cluster_client.h +++ b/src/client/cluster_client.h @@ -83,9 +83,6 @@ class writeback_cache_t; // FIXME: Split into public and private interfaces class __attribute__((visibility("default"))) cluster_client_t { -#ifdef __MOCK__ -public: -#endif timerfd_manager_t *tfd = NULL; ring_loop_t *ringloop = NULL; @@ -155,12 +152,9 @@ public: void list_inode(inode_t inode, uint64_t min_offset, uint64_t max_offset, int max_parallel_pgs, std::function&& objects)> pg_callback); -#ifndef __MOCK__ protected: -#endif void continue_ops(int time_passed = 0); -protected: bool affects_osd(uint64_t inode, uint64_t offset, uint64_t len, osd_num_t osd); bool affects_pg(uint64_t inode, uint64_t offset, uint64_t len, pool_id_t pool_id, pg_num_t pg_num); @@ -201,4 +195,5 @@ protected: osd_num_t select_nearest_osd(const std::vector & osds); friend class writeback_cache_t; + friend class cluster_client_test_t; }; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 57057c50..2cfda1ab 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -15,6 +15,7 @@ add_executable(bindiff # stub_uring_osd add_executable(stub_uring_osd + EXCLUDE_FROM_ALL stub_uring_osd.cpp ) target_link_libraries(stub_uring_osd diff --git a/src/test/test_cluster_client.cpp b/src/test/test_cluster_client.cpp index 945971b1..b8de60e4 100644 --- a/src/test/test_cluster_client.cpp +++ b/src/test/test_cluster_client.cpp @@ -6,6 +6,15 @@ #include #include "cluster_client_impl.h" +class cluster_client_test_t +{ +public: + static void continue_ops(cluster_client_t *cli) + { + cli->continue_ops(cli->client_retry_interval); + } +}; + void configure_single_pg_pool(cluster_client_t *cli) { cli->st_cli.parse_state((etcd_kv_t){ @@ -260,7 +269,7 @@ void test1() pretend_disconnected(cli, 1); pretend_connected(cli, 1); - cli->continue_ops(cli->client_retry_interval); + cluster_client_test_t::continue_ops(cli); // Check replay { @@ -323,7 +332,7 @@ void test1() pretend_op_completed(cli, find_op(cli, 1, OSD_OP_WRITE, 0, 0x1000), -EPIPE); check_disconnected(cli, 1); pretend_connected(cli, 1); - cli->continue_ops(cli->client_retry_interval); + cluster_client_test_t::continue_ops(cli); check_op_count(cli, 1, 1); can_complete(r1); pretend_op_completed(cli, find_op(cli, 1, OSD_OP_WRITE, 0, 0x1000), 0); @@ -342,7 +351,7 @@ void test1() check_completed(r1); check_disconnected(cli, 1); pretend_connected(cli, 1); - cli->continue_ops(cli->client_retry_interval); + cluster_client_test_t::continue_ops(cli); check_op_count(cli, 1, 1); pretend_op_completed(cli, find_op(cli, 1, OSD_OP_WRITE, 0, 0x1000), 0); check_op_count(cli, 1, 1);