enable Alpn_H3_Success test (#56818)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Wed, 4 Aug 2021 22:20:34 +0000 (15:20 -0700)
committerGitHub <noreply@github.com>
Wed, 4 Aug 2021 22:20:34 +0000 (15:20 -0700)
* enable Alpn_H3_Success test

* update

src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http3.cs

index 42c42d4..566d29e 100644 (file)
@@ -375,6 +375,8 @@ namespace System.Net.Http.Functional.Tests
             Assert.Equal(HttpVersion.Version30, response.Version);
             Assert.Null(callbackRequest);
             Assert.Equal(1, invocationCount);
+
+            await serverTask;
         }
 
         [OuterLoop]
@@ -630,7 +632,6 @@ namespace System.Net.Http.Functional.Tests
         }
 
         [ConditionalFact(nameof(IsMsQuicSupported))]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/56609")]
         public async Task Alpn_H3_Success()
         {
             // Mock doesn't use ALPN.
@@ -642,44 +643,32 @@ namespace System.Net.Http.Functional.Tests
             var options = new Http3Options() { Alpn = SslApplicationProtocol.Http3.ToString() };
             using Http3LoopbackServer server = CreateHttp3LoopbackServer(options);
 
-            using var clientDone = new SemaphoreSlim(0);
-            using var serverDone = new SemaphoreSlim(0);
-
+            Http3LoopbackConnection connection = null;
             Task serverTask = Task.Run(async () =>
             {
-                using Http3LoopbackConnection connection = (Http3LoopbackConnection)await server.EstablishGenericConnectionAsync();
-
-                SslApplicationProtocol negotiatedAlpn = ExtractMsQuicNegotiatedAlpn(connection);
-                Assert.Equal(SslApplicationProtocol.Http3, negotiatedAlpn);
-
+                connection = (Http3LoopbackConnection)await server.EstablishGenericConnectionAsync();
                 using Http3LoopbackStream stream = await connection.AcceptRequestStreamAsync();
                 await stream.HandleRequestAsync();
-
-                serverDone.Release();
-                await clientDone.WaitAsync();
             });
 
-            Task clientTask = Task.Run(async () =>
+            using HttpClient client = CreateHttpClient();
+            using HttpRequestMessage request = new()
             {
-                using HttpClient client = CreateHttpClient();
-
-                using HttpRequestMessage request = new()
-                    {
-                        Method = HttpMethod.Get,
-                        RequestUri = server.Address,
-                        Version = HttpVersion30,
-                        VersionPolicy = HttpVersionPolicy.RequestVersionExact
-                    };
-                HttpResponseMessage response = await client.SendAsync(request).WaitAsync(TimeSpan.FromSeconds(10));
-
-                response.EnsureSuccessStatusCode();
-                Assert.Equal(HttpVersion.Version30, response.Version);
+                Method = HttpMethod.Get,
+                RequestUri = server.Address,
+                Version = HttpVersion30,
+                VersionPolicy = HttpVersionPolicy.RequestVersionExact
+            };
+            HttpResponseMessage response = await client.SendAsync(request).WaitAsync(TimeSpan.FromSeconds(10));
+            response.EnsureSuccessStatusCode();
+            Assert.Equal(HttpVersion.Version30, response.Version);
 
-                clientDone.Release();
-                await serverDone.WaitAsync();
-            });
+            await serverTask;
+            Assert.NotNull(connection);
 
-            await new[] { clientTask, serverTask }.WhenAllOrAnyFailed(200_000);
+            SslApplicationProtocol negotiatedAlpn = ExtractMsQuicNegotiatedAlpn(connection);
+            Assert.Equal(new SslApplicationProtocol("h3"), negotiatedAlpn);
+            connection.Dispose();
         }
 
         [ConditionalFact(nameof(IsMsQuicSupported))]