From 3d2bdf8c316642f74efa51ddfd2b569bc5285bd4 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Tue, 11 May 2021 16:29:14 +0200 Subject: [PATCH 1/3] Sockets.tests: TcpReceiveSendGetsCanceledByDispose: remove Timeout. This timeout is not needed and masks a more useful exception thrown by the test. --- .../tests/FunctionalTests/SendReceive/SendReceive.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index 478951acd7770..64a408057c7f0 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -994,7 +994,7 @@ await RetryHelper.ExecuteAsync(async () => { false, true, false }, }; - [Theory(Timeout = 40000)] + [Theory] [MemberData(nameof(TcpReceiveSendGetsCanceledByDispose_Data))] [ActiveIssue("https://github.com/dotnet/runtime/issues/50568", TestPlatforms.Android)] public async Task TcpReceiveSendGetsCanceledByDispose(bool receiveOrSend, bool ipv6Server, bool dualModeClient) From ba88131fd30aef6da35b8a03952a62ac3263c08a Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 12 May 2021 08:37:28 +0200 Subject: [PATCH 2/3] Add WaitAsync to timeout on all async operations --- .../FunctionalTests/SendReceive/SendReceive.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index 64a408057c7f0..a7711b5ef9fc7 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -950,7 +950,8 @@ await RetryHelper.ExecuteAsync(async () => msDelay *= 2; Task disposeTask = Task.Run(() => socket.Dispose()); - await Task.WhenAny(disposeTask, receiveTask).WaitAsync(TimeSpan.FromSeconds(30)); + await Task.WhenAny(disposeTask, receiveTask) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); await disposeTask; SocketError? localSocketError = null; @@ -1035,14 +1036,17 @@ await RetryHelper.ExecuteAsync(async () => msDelay *= 2; Task disposeTask = Task.Run(() => socket1.Dispose()); - await Task.WhenAny(disposeTask, socketOperation).WaitAsync(TimeSpan.FromSeconds(30)); - await disposeTask; + await Task.WhenAny(disposeTask, socketOperation) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + await disposeTask + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); SocketError? localSocketError = null; bool disposedException = false; try { - await socketOperation; + await socketOperation + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); } catch (SocketException se) { @@ -1077,7 +1081,8 @@ await RetryHelper.ExecuteAsync(async () => { try { - int received = await ReceiveAsync(socket2, receiveBuffer); + int received = await ReceiveAsync(socket2, receiveBuffer) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); if (received == 0) { break; From b03a6b01abe5fddf02d74c967325eaa36b0c139c Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 12 May 2021 16:24:12 +0200 Subject: [PATCH 3/3] Add missing timeout --- .../tests/FunctionalTests/SendReceive/SendReceive.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index a7711b5ef9fc7..8b2e52a5128be 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -1026,7 +1026,9 @@ await RetryHelper.ExecuteAsync(async () => var buffer = new ArraySegment(new byte[4096]); while (true) { - SendAsync(socket1, buffer).GetAwaiter().GetResult(); + SendAsync(socket1, buffer) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)) + .GetAwaiter().GetResult(); } }); }