Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quic test improvements #56043

Merged
merged 7 commits into from
Jul 27, 2021
Merged

quic test improvements #56043

merged 7 commits into from
Jul 27, 2021

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Jul 20, 2021

This is test-only change

  • Fix pattern when we can hang in AcceptAsync if client fails to connect
  • plumb more ITestOutputHelper so we can capture more data on failures
  • add some more timeouts in places
  • restrict wildcard on Conformance tests so editor can create swap file without breaking build.

contributes to #55642

@wfurt wfurt requested a review from a team July 20, 2021 21:08
@wfurt wfurt self-assigned this Jul 20, 2021
@ghost
Copy link

ghost commented Jul 20, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

This is test-only change

  • Fix pattern when we can hang in AcceptAsync if client fails to connect
  • plumb more ITestOutputHelper so we can capture more data on failures
  • add some more timeouts in places
  • restrict wildcard on Conformance tests so editor can create swap file without breaking build.

contributes to #55642

Author: wfurt
Assignees: wfurt
Labels:

area-System.Net.Quic

Milestone: -

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

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

Some small comments, otherwise LGTM, thanks!

@@ -28,6 +30,10 @@ public abstract class QuicTestBase<T>
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;
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Some tests suites have actually both - one created from the other. I may do that for consistency.

@@ -30,10 +30,10 @@ public async Task UnidirectionalAndBidirectionalStreamCountsWork()
{
using QuicListener listener = CreateQuicListener();
using QuicConnection clientConnection = CreateQuicConnection(listener.ListenEndPoint);
Task<QuicConnection> serverTask = listener.AcceptConnectionAsync().AsTask();
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

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)
{
  ....
}

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

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 here

If 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.

@wfurt wfurt merged commit 66d23a7 into dotnet:main Jul 27, 2021
@wfurt wfurt deleted the quicTest_55642 branch July 27, 2021 01:36
@karelz karelz added this to the 6.0.0 milestone Jul 29, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants