Skip to content

Commit 6e9cead

Browse files
authored
Unit test event counters and update to latest SDK (#415)
1 parent 4c9bd4a commit 6e9cead

33 files changed

+801
-74
lines changed

Grpc.DotNet.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Proto", "Proto", "{BF1393D4
6868
testassets\Proto\nested.proto = testassets\Proto\nested.proto
6969
testassets\Proto\singleton.proto = testassets\Proto\singleton.proto
7070
testassets\Proto\streaming.proto = testassets\Proto\streaming.proto
71+
testassets\Proto\unimplemented.proto = testassets\Proto\unimplemented.proto
7172
EndProjectSection
7273
EndProject
7374
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTestsWebsite", "testassets\FunctionalTestsWebsite\FunctionalTestsWebsite.csproj", "{7B95289B-4992-4C0D-B26F-8EC58F81FC96}"

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.0.100-preview8-013421"
3+
"version": "3.0.100-preview8-013532"
44
}
55
}

perf/Grpc.AspNetCore.Microbenchmarks/Grpc.AspNetCore.Microbenchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<Protobuf Include=".\Proto\chat.proto" GrpcServices="Server" />
1414

1515
<Compile Include="..\..\test\Shared\TestRequestBodyPipeFeature.cs" Link="Internal\TestRequestBodyPipeFeature.cs" />
16-
<Compile Include="..\..\test\Shared\TestResponseBodyPipeFeature.cs" Link="Internal\TestResponseBodyPipeFeature.cs" />
16+
<Compile Include="..\..\test\Shared\TestResponseBodyFeature.cs" Link="Internal\TestResponseBodyFeature.cs" />
1717

1818
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1919

perf/Grpc.AspNetCore.Microbenchmarks/UnaryServerCallHandlerBenchmarkBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void GlobalSetup()
8686
_httpContext.Request.ContentType = GrpcProtocolConstants.GrpcContentType;
8787

8888
_httpContext.Features.Set<IRequestBodyPipeFeature>(new TestRequestBodyPipeFeature(_requestPipe));
89-
_httpContext.Features.Set<IResponseBodyPipeFeature>(new TestResponseBodyPipeFeature(new TestPipeWriter()));
89+
_httpContext.Features.Set<IHttpResponseBodyFeature>(new TestResponseBodyFeature(new TestPipeWriter()));
9090
_httpContext.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
9191
{
9292
Trailers = _trailers

src/Grpc.AspNetCore.Server/Internal/GrpcEventSource.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ internal GrpcEventSource()
4848
{
4949
}
5050

51+
[NonEvent]
52+
internal void ResetCounters()
53+
{
54+
_totalCalls = 0;
55+
_currentCalls = 0;
56+
_messageSent = 0;
57+
_messageReceived = 0;
58+
_callsFailed = 0;
59+
_callsDeadlineExceeded = 0;
60+
}
61+
5162
// Used for testing
5263
internal GrpcEventSource(string eventSourceName)
5364
: base(eventSourceName)

src/Grpc.AspNetCore.Server/Internal/HttpContextServerCallContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ private async Task DeadlineExceededAsync()
432432

433433
// Immediately send remaining response content and trailers
434434
// If feature is null then reset/abort will still end request, but response won't have trailers
435-
var completionFeature = HttpContext.Features.Get<IHttpResponseCompletionFeature>();
435+
var completionFeature = HttpContext.Features.Get<IHttpResponseBodyFeature>();
436436
if (completionFeature != null)
437437
{
438438
await completionFeature.CompleteAsync();

src/Grpc.Net.Client/Grpc.Net.Client.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
<VersionPrefix>$(GrpcDotnetVersion)</VersionPrefix>
1212
</PropertyGroup>
1313

14+
<ItemGroup>
15+
<KnownFrameworkReference Update="NETStandard.Library">
16+
<!-- TODO(JamesNK): Recent .NET bits seems to have a general issue related to netstandard2.1 https://github.com/dotnet/sdk/pull/3463 -->
17+
<RuntimeFrameworkName>NETStandard.Library</RuntimeFrameworkName>
18+
</KnownFrameworkReference>
19+
</ItemGroup>
20+
1421
<PropertyGroup>
1522
<!-- Include PDB in the built .nupkg -->
1623
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>

src/Grpc.Net.Client/HttpClientCallInvoker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public HttpClientCallInvoker(HttpClient client, ILoggerFactory? loggerFactory)
5454
}
5555

5656
internal Uri BaseAddress => _client.BaseAddress;
57+
internal bool DisableClientDeadlineTimer { get; set; }
5758

5859
/// <summary>
5960
/// Gets or sets the maximum message size in bytes that can be sent from the client.

src/Grpc.Net.Client/Internal/GrpcCall.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ private async Task StartAsync(HttpClient client, HttpRequestMessage request)
454454
{
455455
using (StartScope())
456456
{
457-
if (_timeout != null)
457+
if (_timeout != null && !CallInvoker.DisableClientDeadlineTimer)
458458
{
459459
Log.StartingDeadlineTimeout(Logger, _timeout.Value);
460460

src/Grpc.Net.Client/Internal/GrpcEventSource.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ internal GrpcEventSource(string eventSourceName)
5252
{
5353
}
5454

55+
[NonEvent]
56+
internal void ResetCounters()
57+
{
58+
_totalCalls = 0;
59+
_currentCalls = 0;
60+
_messageSent = 0;
61+
_messageReceived = 0;
62+
_callsFailed = 0;
63+
_callsDeadlineExceeded = 0;
64+
}
65+
5566
[MethodImpl(MethodImplOptions.NoInlining)]
5667
[Event(eventId: 1, Level = EventLevel.Verbose)]
5768
public void CallStart(string method)

0 commit comments

Comments
 (0)