Skip to content

Commit

Permalink
Fix unstable keepalive ut (#2261)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwbmmm authored and smbzhang committed May 22, 2023
1 parent 98e8c57 commit bdbd539
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/brpc_socket_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ TEST_F(SocketTest, keepalive) {
brpc::SocketUniquePtr ptr;
ASSERT_EQ(0, brpc::Socket::Address(id, &ptr));
CheckNoKeepalive(ptr->fd());
sockfd.release();
}

int keepalive_idle = 1;
Expand All @@ -1136,6 +1137,7 @@ TEST_F(SocketTest, keepalive) {
default_keepalive_idle,
default_keepalive_interval,
default_keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive idle.
Expand All @@ -1155,6 +1157,7 @@ TEST_F(SocketTest, keepalive) {
keepalive_idle,
default_keepalive_interval,
default_keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive interval.
Expand All @@ -1174,6 +1177,7 @@ TEST_F(SocketTest, keepalive) {
default_keepalive_idle,
keepalive_interval,
default_keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive count.
Expand All @@ -1193,6 +1197,7 @@ TEST_F(SocketTest, keepalive) {
default_keepalive_idle,
default_keepalive_interval,
keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive idle, interval, count.
Expand All @@ -1216,6 +1221,7 @@ TEST_F(SocketTest, keepalive) {
keepalive_idle,
keepalive_interval,
keepalive_count);
sockfd.release();
}
}

Expand Down Expand Up @@ -1245,6 +1251,7 @@ TEST_F(SocketTest, keepalive_input_message) {
brpc::SocketUniquePtr ptr;
ASSERT_EQ(0, brpc::Socket::Address(id, &ptr));
CheckNoKeepalive(ptr->fd());
sockfd.release();
}

// Enable keepalive.
Expand All @@ -1263,6 +1270,7 @@ TEST_F(SocketTest, keepalive_input_message) {
default_keepalive_idle,
default_keepalive_interval,
default_keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive idle.
Expand All @@ -1281,6 +1289,7 @@ TEST_F(SocketTest, keepalive_input_message) {
brpc::FLAGS_socket_keepalive_idle_s,
default_keepalive_interval,
default_keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive idle, interval.
Expand All @@ -1299,6 +1308,7 @@ TEST_F(SocketTest, keepalive_input_message) {
brpc::FLAGS_socket_keepalive_idle_s,
brpc::FLAGS_socket_keepalive_interval_s,
default_keepalive_count);
sockfd.release();
}

// Enable keepalive and set keepalive idle, interval, count.
Expand All @@ -1317,6 +1327,7 @@ TEST_F(SocketTest, keepalive_input_message) {
brpc::FLAGS_socket_keepalive_idle_s,
brpc::FLAGS_socket_keepalive_interval_s,
brpc::FLAGS_socket_keepalive_count);
sockfd.release();
}

// Options of keepalive set by user have priority over Gflags.
Expand All @@ -1340,6 +1351,7 @@ TEST_F(SocketTest, keepalive_input_message) {
keepalive_idle,
brpc::FLAGS_socket_keepalive_interval_s,
brpc::FLAGS_socket_keepalive_count);
sockfd.release();
}

{
Expand All @@ -1359,6 +1371,7 @@ TEST_F(SocketTest, keepalive_input_message) {
brpc::FLAGS_socket_keepalive_idle_s,
keepalive_interval,
brpc::FLAGS_socket_keepalive_count);
sockfd.release();
}

{
Expand All @@ -1378,6 +1391,7 @@ TEST_F(SocketTest, keepalive_input_message) {
brpc::FLAGS_socket_keepalive_idle_s,
brpc::FLAGS_socket_keepalive_interval_s,
keepalive_count);
sockfd.release();
}

{
Expand All @@ -1401,5 +1415,6 @@ TEST_F(SocketTest, keepalive_input_message) {
keepalive_idle,
keepalive_interval,
keepalive_count);
sockfd.release();
}
}

0 comments on commit bdbd539

Please sign in to comment.