micronaut-grpc icon indicating copy to clipboard operation
micronaut-grpc copied to clipboard

Use InProcessServerBuilder for testing

Open asarkar opened this issue 4 years ago • 4 comments

Micronaut gRPC creates a NettyServerBuilder automatically. How do I use an InProcessServerBuilder for testing?

One way is to set grpc.server.enabled=false, and then create the Server myself.

Server server = InProcessServerBuilder.forName(uniqueName)
      .directExecutor()
      .addService(new MyService())
      .build().start();

But then, I've to start and stop it. It'd be nice to have the framework manage it on my behalf instead.

asarkar avatar Aug 31 '20 17:08 asarkar

Actually I struggled with that, indeed it'd be nice if the framework manages a proper way to mock Grpc services

jntakpe avatar Sep 01 '20 09:09 jntakpe

grpc-spring-boot-starter does this using a property.

asarkar avatar Sep 01 '20 11:09 asarkar

@graemerocher I'm willing to submit PR for this, but there will have to be internal design changes. I looked at the code, and it assumes NettyServerBuilder. I'm thinking something like shown in this ticket, so that the builder can be configured using external properties.

Do you've any thoughts on this?

asarkar avatar Nov 17 '20 09:11 asarkar

Seems reasonable

graemerocher avatar Nov 17 '20 10:11 graemerocher

Any updates on this?

outlndrr avatar Oct 02 '24 11:10 outlndrr