MCPcopy Create free account
hub / github.com/apache/brpc / TEST_F

Function TEST_F

test/brpc_socket_map_unittest.cpp:63–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61};
62
63TEST_F(SocketMapTest, disable_health_check) {
64 int32_t old_interval = brpc::FLAGS_health_check_interval;
65 brpc::FLAGS_health_check_interval = 0;
66 brpc::SocketId id;
67 ASSERT_EQ(-1, brpc::SocketMapFind(g_key, &id));
68 ASSERT_EQ(0, brpc::SocketMapInsert(g_key, &id));
69 ASSERT_EQ(0, brpc::SocketMapFind(g_key, &id));
70 {
71 brpc::SocketUniquePtr ptr;
72 ASSERT_EQ(0, brpc::Socket::Address(id, &ptr));
73 }
74 ASSERT_EQ(0, brpc::Socket::SetFailed(id));
75
76 brpc::SocketUniquePtr ptr;
77 // The socket should not be recycled,
78 // because SocketMap holds a reference to it.
79 ASSERT_EQ(1, brpc::Socket::AddressFailedAsWell(id, &ptr));
80 ASSERT_EQ(2, ptr->nref());
81 brpc::SocketMapRemove(g_key);
82 // After removing the socket, `ptr' holds the last reference.
83 ASSERT_EQ(1, ptr->nref());
84 ASSERT_EQ(-1, brpc::SocketMapFind(g_key, &id));
85 brpc::FLAGS_health_check_interval = old_interval;
86}
87
88TEST_F(SocketMapTest, idle_timeout) {
89 const int TIMEOUT = 1;

Callers

nothing calls this directly

Calls 12

SocketMapFindFunction · 0.85
SocketMapRemoveFunction · 0.85
nrefMethod · 0.80
GetPooledSocketMethod · 0.80
ReturnToPoolMethod · 0.80
ListPooledSocketsMethod · 0.80
SocketMapInsertFunction · 0.50
getMethod · 0.45
resetMethod · 0.45
idMethod · 0.45
sizeMethod · 0.45
FailedMethod · 0.45

Tested by

no test coverage detected