Skip to content

Commit 9f3cd25

Browse files
committed
Remove BrpcStubCacheTest friend declaration from production header
Replace white-box _timer assertions with behavioral assertions via public API in the two singleton-reinitialize tests. Signed-off-by: kaijian.ding <kaijian.ding@gmail.com>
1 parent 4b78271 commit 9f3cd25

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

be/src/common/brpc/brpc_stub_cache.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
namespace starrocks {
5656

5757
class MetricRegistry;
58-
class BrpcStubCacheTest;
5958

6059
constexpr int TIMER_TASK_RUNNING = 1;
6160

@@ -125,8 +124,6 @@ class BrpcStubCache {
125124
template <typename CacheT>
126125
friend void reset_state_for_rebind(CacheT* cache, BthreadTimer* timer);
127126

128-
friend class starrocks::BrpcStubCacheTest;
129-
130127
void replace_cleanup_task_locked(const butil::EndPoint& endpoint,
131128
std::shared_ptr<EndpointCleanupTask<BrpcStubCache>> task);
132129

@@ -170,8 +167,6 @@ class HttpBrpcStubCache {
170167
template <typename CacheT>
171168
friend void reset_state_for_rebind(CacheT* cache, BthreadTimer* timer);
172169

173-
friend class starrocks::BrpcStubCacheTest;
174-
175170
void replace_cleanup_task_locked(const butil::EndPoint& endpoint,
176171
std::shared_ptr<EndpointCleanupTask<HttpBrpcStubCache>> task);
177172

@@ -209,8 +204,6 @@ class LakeServiceBrpcStubCache {
209204
template <typename CacheT>
210205
friend void reset_state_for_rebind(CacheT* cache, BthreadTimer* timer);
211206

212-
friend class starrocks::BrpcStubCacheTest;
213-
214207
void replace_cleanup_task_locked(const butil::EndPoint& endpoint,
215208
std::shared_ptr<EndpointCleanupTask<LakeServiceBrpcStubCache>> task);
216209

be/test/common/brpc/brpc_stub_cache_test.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ TEST_F(BrpcStubCacheTest, http_singleton_reinitialize_rebinds_pipeline_timer) {
270270
HttpBrpcStubCache::initialize(_timer.get());
271271
auto* cache = HttpBrpcStubCache::getInstance();
272272
ASSERT_NE(nullptr, cache);
273-
ASSERT_EQ(_timer.get(), cache->_timer);
274273

275274
TNetworkAddress address;
276275
address.hostname = "127.0.0.1";
@@ -280,10 +279,9 @@ TEST_F(BrpcStubCacheTest, http_singleton_reinitialize_rebinds_pipeline_timer) {
280279
ASSERT_NE(nullptr, *stub);
281280

282281
cache->shutdown();
283-
ASSERT_EQ(nullptr, cache->_timer);
282+
ASSERT_FALSE(cache->get_http_stub(address).ok());
284283

285284
HttpBrpcStubCache::initialize(timer2.get());
286-
ASSERT_EQ(timer2.get(), cache->_timer);
287285

288286
auto rebound_stub = cache->get_http_stub(address);
289287
ASSERT_TRUE(rebound_stub.ok());
@@ -300,17 +298,15 @@ TEST_F(BrpcStubCacheTest, lake_singleton_reinitialize_rebinds_pipeline_timer) {
300298
LakeServiceBrpcStubCache::initialize(_timer.get());
301299
auto* cache = LakeServiceBrpcStubCache::getInstance();
302300
ASSERT_NE(nullptr, cache);
303-
ASSERT_EQ(_timer.get(), cache->_timer);
304301

305302
auto stub = cache->get_stub("127.0.0.1", 123);
306303
ASSERT_TRUE(stub.ok());
307304
ASSERT_NE(nullptr, *stub);
308305

309306
cache->shutdown();
310-
ASSERT_EQ(nullptr, cache->_timer);
307+
ASSERT_FALSE(cache->get_stub("127.0.0.1", 123).ok());
311308

312309
LakeServiceBrpcStubCache::initialize(timer2.get());
313-
ASSERT_EQ(timer2.get(), cache->_timer);
314310

315311
auto rebound_stub = cache->get_stub("127.0.0.1", 123);
316312
ASSERT_TRUE(rebound_stub.ok());

0 commit comments

Comments
 (0)