Skip to content

Commit

Permalink
Change test request to POST to avoid retry on server Shutdown (#105035)
Browse files Browse the repository at this point in the history
  • Loading branch information
rokonec authored Jul 18, 2024
1 parent 0785303 commit 8f3a317
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -955,19 +955,20 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
{
using HttpMessageInvoker client = CreateHttpMessageInvoker();
using InstrumentRecorder<double> recorder = SetupInstrumentRecorder<double>(InstrumentNames.RequestDuration);
using HttpRequestMessage request = new(HttpMethod.Get, uri) { Version = UseVersion };
using HttpRequestMessage request = new(HttpMethod.Post, uri) { Version = UseVersion };
request.Content = new StringContent("{}");

Exception ex = await Assert.ThrowsAnyAsync<Exception>(async () =>
{
// Getting a cancellation is also good if we are unable to detect the peer shutdown.
using CancellationTokenSource cts = new CancellationTokenSource(10_000);
// To avoid unlimited blocking, lets bound it to 20 seconds.
using CancellationTokenSource cts = new CancellationTokenSource(20_000);
using HttpResponseMessage response = await SendAsync(client, request, cts.Token);
});
cancelServerCts.Cancel();
Assert.True(ex is HttpRequestException or TaskCanceledException);

Measurement<double> m = Assert.Single(recorder.GetMeasurements());
VerifyRequestDuration(m, uri, acceptedErrorTypes: [typeof(TaskCanceledException).FullName, "response_ended"]);
VerifyRequestDuration(m, uri, acceptedErrorTypes: [typeof(TaskCanceledException).FullName, "response_ended"], method: "POST");
}, async server =>
{
await IgnoreExceptions(async () =>
Expand Down

0 comments on commit 8f3a317

Please sign in to comment.