From 5b9642a0f29bac2eabdb561ee8d7a96a98627f59 Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Tue, 9 Apr 2024 07:48:02 -0700 Subject: [PATCH] Increase timeout when observing TCP connection failures Give the Netstack additional time to reject incoming connections for which there are no listening sockets. This prevents flakes in test environments with CPU contention, where the Netstack may be descheduled for multiple seconds. PiperOrigin-RevId: 623165285 --- test/syscalls/linux/tcp_socket.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/syscalls/linux/tcp_socket.cc b/test/syscalls/linux/tcp_socket.cc index 8d6b7ff60..ab332609d 100644 --- a/test/syscalls/linux/tcp_socket.cc +++ b/test/syscalls/linux/tcp_socket.cc @@ -1257,7 +1257,8 @@ PosixErrorOr nonBlockingConnectNoListener( // Wait for the connect to fail. struct pollfd poll_fd = {s.get(), POLLERR, 0}; - EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, 1000), SyscallSucceedsWithValue(1)); + EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, kTimeoutMillis), + SyscallSucceedsWithValue(1)); return std::move(s); } @@ -1732,7 +1733,8 @@ TEST_P(SimpleTcpSocketTest, NonBlockingConnectRefused) { // We don't need to specify any events to get POLLHUP or POLLERR as these // are added before the poll. struct pollfd poll_fd = {s.get(), /*events=*/0, 0}; - EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, 1000), SyscallSucceedsWithValue(1)); + EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, kTimeoutMillis), + SyscallSucceedsWithValue(1)); // The ECONNREFUSED should cause us to be woken up with POLLHUP. EXPECT_NE(poll_fd.revents & (POLLHUP | POLLERR), 0);