From b14cdd5aa67de155f1da9151a64eb48905f162e4 Mon Sep 17 00:00:00 2001 From: dsiganos Date: Thu, 17 Jun 2021 14:03:06 +0100 Subject: [PATCH] fix unit test socket.max_connections (#3345) There were race conditions in the way counters were checked and callbacks were handled. --- nano/core_test/socket.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nano/core_test/socket.cpp b/nano/core_test/socket.cpp index 7114f26a..c8e68c21 100644 --- a/nano/core_test/socket.cpp +++ b/nano/core_test/socket.cpp @@ -63,8 +63,8 @@ TEST (socket, max_connections) }; ASSERT_TIMELY (5s, get_tcp_accept_failures () == 1); - ASSERT_EQ (get_tcp_accept_successes (), 2); - ASSERT_EQ (connection_attempts, 3); + ASSERT_TIMELY (5s, get_tcp_accept_successes () == 2); + ASSERT_TIMELY (5s, connection_attempts == 3); // create space for one socket and fill the connections table again @@ -77,8 +77,8 @@ TEST (socket, max_connections) client5->async_connect (dst_endpoint, connect_handler); ASSERT_TIMELY (5s, get_tcp_accept_failures () == 2); - ASSERT_EQ (get_tcp_accept_successes (), 3); - ASSERT_EQ (connection_attempts, 5); + ASSERT_TIMELY (5s, get_tcp_accept_successes () == 3); + ASSERT_TIMELY (5s, connection_attempts == 5); // close all existing sockets and fill the connections table again // start counting form 1 because 0 is the already closed socket @@ -97,9 +97,9 @@ TEST (socket, max_connections) client8->async_connect (dst_endpoint, connect_handler); ASSERT_TIMELY (5s, get_tcp_accept_failures () == 3); - ASSERT_EQ (get_tcp_accept_successes (), 5); - ASSERT_EQ (connection_attempts, 8); // connections initiated by the client - ASSERT_EQ (server_sockets.size (), 5); // connections accepted by the server + ASSERT_TIMELY (5s, get_tcp_accept_successes () == 5); + ASSERT_TIMELY (5s, connection_attempts == 8); // connections initiated by the client + ASSERT_TIMELY (5s, server_sockets.size () == 5); // connections accepted by the server node->stop (); runner.stop_event_processing ();