From 3d3d1800db872311eaca4e67d6abae8decf66a2e Mon Sep 17 00:00:00 2001 From: wfurt Date: Fri, 27 Oct 2023 13:15:53 -0700 Subject: [PATCH 1/2] make Http2_IncorrectServerPreface_RequestFailsWithAppropriateHttpProtocolException test more deterministic --- .../tests/FunctionalTests/HttpClientHandlerTest.Http2.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs index a9b1be6e7766a2..e87cc7d1202444 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs @@ -139,7 +139,8 @@ public async Task Http2_StreamResetByServerBeforePrefix_RequestFailsWithGoawayPr Http2LoopbackConnection connection = await server.AcceptConnectionAsync(timeout: null); _ = await connection.ReadSettingsAsync(); - + // Wait until client starts sending request + Frame frame = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); GoAwayFrame goAwayFrame = new GoAwayFrame(lastStreamId: 0, (int)ProtocolErrors.HTTP_1_1_REQUIRED, additionalDebugData: Array.Empty(), streamId: 0); await connection.WriteFrameAsync(goAwayFrame); @@ -363,6 +364,8 @@ public async Task Http2_IncorrectServerPreface_RequestFailsWithAppropriateHttpPr Http2LoopbackConnection connection = await server.AcceptConnectionAsync(); await connection.ReadSettingsAsync(); + // Wait until client starts sending request + Frame frame = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); await connection.SendGoAway(0, ProtocolErrors.INTERNAL_ERROR); await AssertProtocolErrorAsync(sendTask, ProtocolErrors.INTERNAL_ERROR); From 16b02899b3e00d730e8ea5928b734240baf69dd1 Mon Sep 17 00:00:00 2001 From: wfurt Date: Mon, 30 Oct 2023 13:21:23 -0700 Subject: [PATCH 2/2] feedback --- .../tests/FunctionalTests/HttpClientHandlerTest.Http2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs index e87cc7d1202444..3036935ef5533d 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs @@ -140,7 +140,7 @@ public async Task Http2_StreamResetByServerBeforePrefix_RequestFailsWithGoawayPr Http2LoopbackConnection connection = await server.AcceptConnectionAsync(timeout: null); _ = await connection.ReadSettingsAsync(); // Wait until client starts sending request - Frame frame = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); + _ = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); GoAwayFrame goAwayFrame = new GoAwayFrame(lastStreamId: 0, (int)ProtocolErrors.HTTP_1_1_REQUIRED, additionalDebugData: Array.Empty(), streamId: 0); await connection.WriteFrameAsync(goAwayFrame); @@ -365,7 +365,7 @@ public async Task Http2_IncorrectServerPreface_RequestFailsWithAppropriateHttpPr Http2LoopbackConnection connection = await server.AcceptConnectionAsync(); await connection.ReadSettingsAsync(); // Wait until client starts sending request - Frame frame = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); + _ = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); await connection.SendGoAway(0, ProtocolErrors.INTERNAL_ERROR); await AssertProtocolErrorAsync(sendTask, ProtocolErrors.INTERNAL_ERROR);