question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integration-Test with grpc server does cancel streamed requests.

See original GitHub issue

Dear grpc dotnet team.

I’m currently using aspnet.grpc with .net core 3.1 and I did catch some strange behaviour.

When using the testing framework of asp.net core to create integration tests, any call that uses serverside or client side streams is cancelled instead of correctly resolved.

Funny enough, when running the tests locally on the developer workstation it does run as intended and when running the tests on ci in docker build, they fail and are cancelled.

Parallel testing is disabled and everything should run serial.

An example of such a test is:

[Fact(Skip = "Does not work on ci.")]
public async Task Throws_On_Deleted_File()
{
    var file = await UploadFile();
    await Client.DeleteAsync(new DeleteRequest { Id = file.Id });
    var ex = await Assert.ThrowsAsync<RpcException>(
        async () =>
        {
            using var call = Client.Replace();
            await call.RequestStream.WriteAsync(
                new ReplaceRequest
                {
                    Metadata = new ReplaceMetadata
                    {
                        FileId = file.Id,
                        TotalSize = 42,
                    },
                });
            await call.RequestStream.CompleteAsync();
            await call.ResponseAsync;
        });
    ex.Status.StatusCode.Should().Be(StatusCode.NotFound);
}

This test is intended for a storage system that has file information. Now when a file is deleted, obviously the correct RpcException would be NotFound. But on CI the result is an RpcException with Cancelled. It’s the horror to debug since it does work as intended locally and the debugger does step to the correct elements.

Do you guys have any idea what could go sideways with those calls? Or something that I need to change?

Regards Chris

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
buehlercommented, Feb 20, 2020

Nice, it seems to be working. Thanks to all participants! Regards

0reactions
buehlercommented, Feb 20, 2020

@anurse Let me check…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cancellation
When an RPC is cancelled, the server should stop any ongoing computation and end its side of the stream. Often, servers are also...
Read more >
Running gRPC server and client in JUnit test (sometimes) ...
make sure you are calling onCompleted · check your catch blocks and make sure onError is being called and that there is logging...
Read more >
Integration Tests for gRPC Services in ASP.NET Core
NET - Grpc.net is built on Grpc.Core which uses the protoc tool (see: ... Server streaming RPC: In this case, the client sends...
Read more >
Creating and testing gRPC server interceptors in Ruby
After the service is defined, we need to implement a skeleton service to return a simple response to the RPC call. Once these...
Read more >
Message Does not Arrive in gRPC Server Events ...
Message Does not Arrive in gRPC Server Events Integration Test ... tests which use the grpc streaming features, which looks like this :....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found