mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
tests: Deflake socket_inet_loopback_isolated_test
This test case creates one connection, then it closes one end of it. After that it waits for a linger timeout and tries to create the second connection with the same client source port. The test is flaky if the second half of the fist connection isn't closed before creating the second connection. PiperOrigin-RevId: 715924851
This commit is contained in:
@@ -295,7 +295,11 @@ func (n *Network) CreateLinksAndRoutes(args *CreateLinksAndRoutesArgs, _ *struct
|
||||
nicID := n.Stack.NextNICID()
|
||||
nicids[link.Name] = nicID
|
||||
|
||||
linkEP := ethernet.New(loopback.New())
|
||||
var linkEP stack.LinkEndpoint
|
||||
linkEP = ethernet.New(loopback.New())
|
||||
if args.LogPackets {
|
||||
linkEP = sniffer.New(linkEP)
|
||||
}
|
||||
|
||||
log.Infof("Enabling loopback interface %q with id %d on addresses %+v", link.Name, nicID, link.Addresses)
|
||||
opts := stack.NICOptions{
|
||||
|
||||
@@ -210,6 +210,13 @@ TEST_P(SocketInetLoopbackIsolatedTest, TCPFinWait2Test) {
|
||||
ASSERT_THAT(bind(conn_fd2.get(), AsSockAddr(&conn_bound_addr), conn_addrlen),
|
||||
SyscallSucceeds());
|
||||
|
||||
// Close the `accepted` end otherwise connect can return ECONNREFUSED.
|
||||
constexpr int kTCPLingerTimeout0 = 0;
|
||||
EXPECT_THAT(setsockopt(accepted.get(), IPPROTO_TCP, TCP_LINGER2,
|
||||
&kTCPLingerTimeout0, sizeof(kTCPLingerTimeout0)),
|
||||
SyscallSucceedsWithValue(0));
|
||||
shutdown(accepted.get(), SHUT_WR);
|
||||
|
||||
ASSERT_THAT(
|
||||
RetryEINTR(connect)(conn_fd2.get(), AsSockAddr(&conn_addr), conn_addrlen),
|
||||
SyscallSucceeds());
|
||||
|
||||
Reference in New Issue
Block a user