Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace System.Net.Sockets.Tests
public static class TestSettings
{
// Timeout values in milliseconds.
public const int PassingTestTimeout = 10000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep this untouched to be consistent with other tests? e.g. PassingTestTimeout is normal/default timeout. If we need anything different for come case we would make it with specific name - like PassingTestLongTimeout (that part looks ok to me)

Copy link
Contributor Author

@antonfirsov antonfirsov Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this renaming to reduce the diff size.

I think more verbosity in the names wouldn't hurt here. 10 sec is quite a short time in comparison to Http.Tests's default PassingTestTimeout=30sec. We use hardcoded 30 seconds at a bunch of places in socket tests, which we will eventually replace with PassingTestLongTimeout, meaning that the "default" PassingTestTimeout=10sec will become much less common.

public const int PassingTestTimeout = 10_000;
public const int PassingTestLongTimeout = 30_000;
public const int FailingTestTimeout = 100;

public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void Socket_ConnectAsyncDnsEndPoint_HostNotFound()
bool willRaiseEvent = sock.ConnectAsync(args);
if (willRaiseEvent)
{
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection");
complete.Dispose(); // only dispose on success as we know we're done with the instance
}

Expand Down Expand Up @@ -332,7 +332,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type)

if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args))
{
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection");
}

Assert.Equal(SocketError.Success, args.SocketError);
Expand All @@ -348,7 +348,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type)

if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args))
{
Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection");
}

complete.Dispose(); // only dispose on success as we know we're done with the instance
Expand Down Expand Up @@ -404,7 +404,7 @@ public void Socket_StaticConnectAsync_HostNotFound()
OnConnectAsyncCompleted(null, args);
}

Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection");
Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection");
complete.Dispose(); // only dispose on success as we know we're done with the instance

AssertHostNotFoundOrNoData(args);
Expand Down