Skip to content

Commit

Permalink
Some helpful comments about unit test socket_timeout.connect (#4389)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsiganos authored Jan 25, 2024
1 parent afcbde1 commit 6f996b2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nano/core_test/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ TEST (socket, concurrent_writes)
* set timeout to one second
* do a tcp connect that will block for at least a few seconds at the tcp level
* check that the connect returns error and that the correct counters have been incremented
*
* NOTE: it is possible that the O/S has tried to access the IP address 10.255.254.253 before
* and has it marked in the routing table as unroutable. In that case this test case will fail.
* If this test is run repeadetly the tests fails for this reason because the connection fails
* with "No route to host" error instead of a timeout.
*/
TEST (socket_timeout, connect)
{
Expand Down Expand Up @@ -603,6 +608,8 @@ TEST (socket_timeout, connect)
ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_connect_error, nano::stat::dir::in));

// check that the socket was closed due to tcp_io_timeout timeout
// NOTE: this assert is not guaranteed to be always true, it is only likely that it will be true, we can also get "No route to host"
// if this test is run repeatedly or in parallel then it is guaranteed to fail due to "No route to host" instead of timeout
ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out));
}

Expand Down

0 comments on commit 6f996b2

Please sign in to comment.