Skip to content

Commit

Permalink
Sockets.tests: TcpReceiveSendGetsCanceledByDispose: remove Timeout. (#…
Browse files Browse the repository at this point in the history
…52599)

* Sockets.tests: TcpReceiveSendGetsCanceledByDispose: remove Timeout.

This timeout is not needed and masks a more useful exception thrown
by the test.

* Add WaitAsync to timeout on all async operations

* Add missing timeout
  • Loading branch information
tmds authored Jun 8, 2021
1 parent 8671908 commit 06cf0b0
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,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;
Expand Down Expand Up @@ -996,7 +997,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)
Expand Down Expand Up @@ -1028,7 +1029,9 @@ await RetryHelper.ExecuteAsync(async () =>
var buffer = new ArraySegment<byte>(new byte[4096]);
while (true)
{
SendAsync(socket1, buffer).GetAwaiter().GetResult();
SendAsync(socket1, buffer)
.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout))
.GetAwaiter().GetResult();
}
});
}
Expand All @@ -1038,14 +1041,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)
{
Expand Down Expand Up @@ -1080,7 +1086,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;
Expand Down

0 comments on commit 06cf0b0

Please sign in to comment.