Conversation
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsThis is test-only change
contributes to #55642
|
ManickaP
left a comment
There was a problem hiding this comment.
Some small comments, otherwise LGTM, thanks!
src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs
Outdated
Show resolved
Hide resolved
| public X509Certificate2 ServerCertificate = System.Net.Test.Common.Configuration.Certificates.GetServerCertificate(); | ||
| public X509Certificate2 ClientCertificate = System.Net.Test.Common.Configuration.Certificates.GetClientCertificate(); | ||
|
|
||
| public const int PassingTestTimeout = 30_000; |
There was a problem hiding this comment.
Why don't you declare it as TimeSpan? You wouldn't need to add those overloads to TaskTimeoutExtensions.cs and you'd have avoided mistakes like WaitAsync(TimeSpan.FromSeconds(PassingTestTimeout)) - seconds instead of milliseconds. Unless you really want there super long timeout.
There was a problem hiding this comment.
Some tests suites have actually both - one created from the other. I may do that for consistency.
src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs
Outdated
Show resolved
Hide resolved
| { | ||
| using QuicListener listener = CreateQuicListener(); | ||
| using QuicConnection clientConnection = CreateQuicConnection(listener.ListenEndPoint); | ||
| Task<QuicConnection> serverTask = listener.AcceptConnectionAsync().AsTask(); |
There was a problem hiding this comment.
SInce this is a common, repeated pattern, I wonder if we should have a helper method for it, like CreateClientAndServer or something like that. Or EstablishConnection or something.
We have RunClientServer, but that's not really the same.
There was a problem hiding this comment.
yah. I wanted to like SslStream. But if I return tuple we loose the using var.
We would need to than use good old
using (clientConn)
using (serverConn)
{
....
}There was a problem hiding this comment.
BTW the helper would be also nice if we want to bet in any retry logs for the flaky listener if we don't find way how to fix it.
There was a problem hiding this comment.
Yeah, it's a little verbose because of the using stuff.
One idea would be to define something like
struct QuicConnectionPair : IDisposable
{
public QuicConnection Client { get; }
public QuicConnection Server { get; }
public void Dispose() { Client.Dispose(); Server.Dispose(); }
}
public static ValueTask<ConnectionPair> EstablishConnectionAsync(...) { ... }Then you can just write code like this:
using (var connectionPair = await EstablishConnectionAsync(...);
// use connectionPair.Client and connectionPair.Server hereIf we feel really ambitious we could generalize ConnectionPair to something like DisposablePair<T1, T2>. And maybe add some implicit conversion ops from ValueTuple<T1, T2>...
@stephentoub already has something vaguely like this for the Stream Conformance Tests.
This is test-only change
ITestOutputHelperso we can capture more data on failurescontributes to #55642