Skip to content

Commit 7c05f97

Browse files
committed
Fix tests
1 parent 67b4997 commit 7c05f97

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Servers/Kestrel/Core/test/Http1/Http1OutputProducerTests.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ public async Task FlushAsync_OnSocketWithCanceledPendingFlush_ReturnsResultWithI
117117
[Fact]
118118
public void AbortsTransportEvenAfterDispose()
119119
{
120+
var metricsTagsFeature = new TestConnectionMetricsTagsFeature();
120121
var mockConnectionContext = new Mock<ConnectionContext>();
121122

122-
var outputProducer = CreateOutputProducer(connectionContext: mockConnectionContext.Object);
123+
var outputProducer = CreateOutputProducer(connectionContext: mockConnectionContext.Object, metricsTagsFeature: metricsTagsFeature);
123124

124125
outputProducer.Dispose();
125126

@@ -132,6 +133,8 @@ public void AbortsTransportEvenAfterDispose()
132133
outputProducer.Abort(null, ConnectionEndReason.AbortedByApplication);
133134

134135
mockConnectionContext.Verify(f => f.Abort(null), Times.Once());
136+
137+
Assert.Equal(nameof(ConnectionEndReason.AbortedByApplication), metricsTagsFeature.Tags.Single(t => t.Key == KestrelMetrics.KestrelConnectionEndReason).Value);
135138
}
136139

137140
[Fact]
@@ -219,7 +222,8 @@ public void ReusesFakeMemory()
219222

220223
private TestHttpOutputProducer CreateOutputProducer(
221224
PipeOptions pipeOptions = null,
222-
ConnectionContext connectionContext = null)
225+
ConnectionContext connectionContext = null,
226+
IConnectionMetricsTagsFeature metricsTagsFeature = null)
223227
{
224228
pipeOptions = pipeOptions ?? new PipeOptions();
225229
connectionContext = connectionContext ?? Mock.Of<ConnectionContext>();
@@ -234,12 +238,17 @@ private TestHttpOutputProducer CreateOutputProducer(
234238
serviceContext.Log,
235239
Mock.Of<ITimeoutControl>(),
236240
Mock.Of<IHttpMinResponseDataRateFeature>(),
237-
Mock.Of<IConnectionMetricsTagsFeature>(),
241+
metricsTagsFeature ?? new TestConnectionMetricsTagsFeature(),
238242
Mock.Of<IHttpOutputAborter>());
239243

240244
return socketOutput;
241245
}
242246

247+
private class TestConnectionMetricsTagsFeature : IConnectionMetricsTagsFeature
248+
{
249+
public ICollection<KeyValuePair<string, object>> Tags { get; } = new List<KeyValuePair<string, object>>();
250+
}
251+
243252
private class TestHttpOutputProducer : Http1OutputProducer
244253
{
245254
public TestHttpOutputProducer(Pipe pipe, string connectionId, ConnectionContext connectionContext, MemoryPool<byte> memoryPool, KestrelTrace log, ITimeoutControl timeoutControl, IHttpMinResponseDataRateFeature minResponseDataRateFeature, IConnectionMetricsTagsFeature metricsTagsFeature, IHttpOutputAborter outputAborter)

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ await Http3Api.WaitForConnectionErrorAsync<ConnectionAbortedException>(
21392139
expectedLastStreamId: null,
21402140
Http3ErrorCode.UnexpectedFrame,
21412141
null);
2142-
Assert.Equal(nameof(ConnectionEndReason.UnexpectedFrame), Http3Api.ConnectionTags[KestrelMetrics.KestrelConnectionEndReason]);
2142+
Assert.Equal(nameof(ConnectionEndReason.UnsupportedFrame), Http3Api.ConnectionTags[KestrelMetrics.KestrelConnectionEndReason]);
21432143
}
21442144

21452145
[Fact]

0 commit comments

Comments
 (0)