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

[Flaky Test] Change request to POST to avoid retry on server Shutdown #105035

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading