未验证 提交 9ea8c200 编写于 作者: M Marie Píchová 提交者: GitHub

Re-enabled mock tests for H/3. (#53802)

* Re-enabled mock tests for H/3.

* Used IsMockQuicSupported to run the mock tests only on supported platforms.

* Disabling mock test completely.

* Hanging test fix experiment.

* Disabled some mock tests failing in CI.
上级 645dfe69
......@@ -6,6 +6,7 @@
using Xunit;
using Xunit.Abstractions;
using System.Net.Test.Common;
using System.Net.Quic;
namespace System.Net.Http.Functional.Tests
{
......@@ -30,6 +31,12 @@ private HttpClient CreateHttpClient(Version version)
[MemberData(nameof(AltSvcHeaderUpgradeVersions))]
public async Task AltSvc_Header_Upgrade_Success(Version fromVersion, bool overrideHost)
{
// [ActiveIssue("https://github.com/dotnet/runtime/issues/54050")]
if (UseQuicImplementationProvider == QuicImplementationProviders.Mock)
{
return;
}
// The test makes a request to a HTTP/1 or HTTP/2 server first, which supplies an Alt-Svc header pointing to the second server.
using GenericLoopbackServer firstServer =
fromVersion.Major switch
......@@ -73,6 +80,12 @@ fromVersion.Major switch
[Fact]
public async Task AltSvc_ConnectionFrame_UpgradeFrom20_Success()
{
// [ActiveIssue("https://github.com/dotnet/runtime/issues/54050")]
if (UseQuicImplementationProvider == QuicImplementationProviders.Mock)
{
return;
}
using Http2LoopbackServer firstServer = Http2LoopbackServer.CreateServer();
using Http3LoopbackServer secondServer = CreateHttp3LoopbackServer();
using HttpClient client = CreateHttpClient(HttpVersion.Version20);
......@@ -98,6 +111,12 @@ public async Task AltSvc_ConnectionFrame_UpgradeFrom20_Success()
[Fact]
public async Task AltSvc_ResponseFrame_UpgradeFrom20_Success()
{
// [ActiveIssue("https://github.com/dotnet/runtime/issues/54050")]
if (UseQuicImplementationProvider == QuicImplementationProviders.Mock)
{
return;
}
using Http2LoopbackServer firstServer = Http2LoopbackServer.CreateServer();
using Http3LoopbackServer secondServer = CreateHttp3LoopbackServer();
using HttpClient client = CreateHttpClient(HttpVersion.Version20);
......
......@@ -170,7 +170,7 @@ public async Task SendMoreThanStreamLimitRequestsConcurrently_LastWaits(int stre
{
// This combination leads to a hang manifesting in CI only. Disabling it until there's more time to investigate.
// [ActiveIssue("https://github.com/dotnet/runtime/issues/53688")]
if (streamLimit == 10 && this.UseQuicImplementationProvider == QuicImplementationProviders.Mock)
if (this.UseQuicImplementationProvider == QuicImplementationProviders.Mock)
{
return;
}
......
......@@ -31,6 +31,10 @@ public static bool IsMsQuicSupported
}
}
// This should correspond to platforms on which System.Net.Quic is supported. See also HttpConnectionPool.IsHttp3Supported().
public static bool IsMockQuicSupported
=> (OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
protected static HttpClientHandler CreateHttpClientHandler(Version useVersion = null, QuicImplementationProvider quicImplementationProvider = null, bool allowAllHttp2Certificates = true)
{
useVersion ??= HttpVersion.Version11;
......
......@@ -40,7 +40,7 @@ public sealed class SocketsHttpHandler_HttpClientMiniStress_Http3_MsQuic : HttpC
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandler_HttpClientMiniStress_Http3_Mock : HttpClientMiniStress
{
public SocketsHttpHandler_HttpClientMiniStress_Http3_Mock(ITestOutputHelper output) : base(output) { }
......
......@@ -3083,7 +3083,7 @@ public sealed class SocketsHttpHandlerTest_Http3_MsQuic : HttpClientHandlerTest_
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandlerTest_Http3_Mock : HttpClientHandlerTest_Http3
{
public SocketsHttpHandlerTest_Http3_Mock(ITestOutputHelper output) : base(output) { }
......@@ -3098,7 +3098,7 @@ public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_MsQuic :
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_Mock : HttpClientHandlerTest
{
public SocketsHttpHandlerTest_HttpClientHandlerTest_Http3_Mock(ITestOutputHelper output) : base(output) { }
......@@ -3117,7 +3117,7 @@ public sealed class SocketsHttpHandlerTest_Cookies_Http3_MsQuic : HttpClientHand
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/53093")]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandlerTest_Cookies_Http3_Mock : HttpClientHandlerTest_Cookies
{
public SocketsHttpHandlerTest_Cookies_Http3_Mock(ITestOutputHelper output) : base(output) { }
......@@ -3133,7 +3133,7 @@ public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_M
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_Mock : HttpClientHandlerTest_Headers
{
public SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http3_Mock(ITestOutputHelper output) : base(output) { }
......@@ -3152,7 +3152,7 @@ public sealed class SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/53093")]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3_Mock : SocketsHttpHandler_Cancellation_Test
{
public SocketsHttpHandler_HttpClientHandler_Cancellation_Test_Http3_Mock(ITestOutputHelper output) : base(output) { }
......@@ -3168,7 +3168,7 @@ public sealed class SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_MsQui
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_Mock : HttpClientHandler_AltSvc_Test
{
public SocketsHttpHandler_HttpClientHandler_AltSvc_Test_Http3_Mock(ITestOutputHelper output) : base(output) { }
......@@ -3184,7 +3184,7 @@ public sealed class SocketsHttpHandler_HttpClientHandler_Finalization_Http3_MsQu
protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic;
}
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))]
[ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))]
public sealed class SocketsHttpHandler_HttpClientHandler_Finalization_Http3_Mock : HttpClientHandler_Finalization_Test
{
public SocketsHttpHandler_HttpClientHandler_Finalization_Http3_Mock(ITestOutputHelper output) : base(output) { }
......
......@@ -371,15 +371,20 @@ public StreamLimit(int maxCount)
public void Decrement()
{
TaskCompletionSource? availableTcs = null;
lock (_syncRoot)
{
--_actualCount;
if (!_availableTcs.Task.IsCompleted)
{
_availableTcs.SetResult();
availableTcs = _availableTcs;
_availableTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
}
}
if (availableTcs is not null)
{
availableTcs.SetResult();
}
}
public bool TryIncrement()
......@@ -396,7 +401,18 @@ public bool TryIncrement()
}
public ValueTask WaitForAvailableStreams(CancellationToken cancellationToken)
=> new ValueTask(_availableTcs.Task.WaitAsync(cancellationToken));
{
TaskCompletionSource availableTcs;
lock (_syncRoot)
{
if (_actualCount > 0)
{
return default;
}
availableTcs = _availableTcs;
}
return new ValueTask(availableTcs.Task.WaitAsync(cancellationToken));
}
public void CloseWaiters()
=> _availableTcs.SetException(ExceptionDispatchInfo.SetCurrentStackTrace(new QuicOperationAbortedException()));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册