Skip to content
Draft
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
25 changes: 22 additions & 3 deletions src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.DotNet.XUnitExtensions;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;

namespace System.Net.Http.Functional.Tests
{
Expand Down Expand Up @@ -1172,10 +1173,28 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
using HttpResponseMessage response = await SendAsync(client, request, cts.Token);
});
cancelServerCts.Cancel();
Assert.True(ex is HttpRequestException or TaskCanceledException);
try
{
Assert.True(ex is HttpRequestException or TaskCanceledException);

Measurement<double> m = Assert.Single(recorder.GetMeasurements());
VerifyRequestDuration(m, uri, acceptedErrorTypes: [typeof(TaskCanceledException).FullName, "response_ended"], method: "POST");
Measurement<double> m = Assert.Single(recorder.GetMeasurements());
VerifyRequestDuration(m, uri, acceptedErrorTypes: [typeof(TaskCanceledException).FullName, "response_ended"], method: "POST");
}
catch (XunitException)
{
_output.WriteLine($"Client exception: {ex}");
if (ex is HttpRequestException requestException)
{
_output.WriteLine($"HttpRequestError: {requestException.HttpRequestError}");
}

if (ex.GetBaseException() is SocketException socketException)
{
_output.WriteLine($"SocketErrorCode: {socketException.SocketErrorCode}; NativeErrorCode: {socketException.NativeErrorCode}");
}

throw;
}
}, async server =>
{
await IgnoreExceptions(async () =>
Expand Down
Loading