How to test gRPC APIs?
Asked Answered
K

7

20

I have been assigned to test a gRPC API (written in Golang) but I don't know how to go about testing it and I couldn't find any tutorials online for this type of testing. The only method that I can think of is to write unit tests to test the methods themselves but I would like to also test it with a client. For example, I have tested REST APIs in the past using JMeter as a client to send requests and verify the response data. Is there a method for testing gRPC APIs with a client or is unit testing the only way?

Keratosis answered 12/12, 2017 at 2:25 Comment(0)
S
16

Well, I was in search for a client like Postman, then i found bloomrpc, which helps in calling grpc services. But i am not sure if it serves your purpose, if you are looking for a tool like jmeter.

Sturgill answered 7/9, 2019 at 9:24 Comment(3)
Any idea how we can wrap the text in BloomRPC? Sometimes the string gets huge and it's clumsy without text wrap. – Trellas
Any tools for grcp like JMeter? – Transvestite
2024 update: This is no longer maintained and shouldn't be used – Tanked
W
12

If you are searching for a tool like Postman, there is also https://kreya.app. With it, you can call your gRPC services and view the responses.

Disclaimer: I'm one of the authors of Kreya.

Wolenik answered 28/1, 2021 at 14:55 Comment(0)
H
5

Since you mentiond you've done testing before with JMeter, I assume that you're looking for an external test client that can call the gRPC service. There are several that you can use. The common ones are

With those 4 clients, you can dynamically call gRPC services. However, if you are looking a test client that can also do load testing, Fint is the one you will need.

Heighten answered 12/3, 2021 at 9:1 Comment(0)
B
4

For anyone who stumbles upon this thread ... All the previous answers have already provided good tools. We used BloomRPC & Kreya in our team (individual choices).

What I want to add is this gRPC Ecosystem Page. It contains a curated lists of all related tools. There are other GUI test tools (see GUI section), or Load testing, benchmarking tools (Testing)

https://github.com/grpc-ecosystem/awesome-grpc

PS : I'll be honest, I have not able to check all tools besides BloomRPC & Kreya.

Bun answered 27/1, 2022 at 1:27 Comment(0)
K
3

Postman just published they have grpc in beta :

https://blog.postman.com/postman-now-supports-grpc/

I tested it just now and it worked perfectly for me πŸ‘πŸ»πŸ™‚

grpc postman

Karlynkarma answered 21/2, 2022 at 16:50 Comment(0)
T
2

There can be two type of testing.

  • Testing just the implementation of the gRPC method by ignoring the networking

    this question answers this aspect of the testing. By just writing the unit test for the RPC method

  • If you want to test both the implementation and the gRPC networking aspects as well then you need write the gRPC client for the service you want to test.

Here a code snippet about creating a gRPC client

// Set up a connection to the server.
conn, err := grpc.Dial(address, grpc.WithInsecure())
// Execute RPC you want to test
r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name})

Check here for complete code example

Tarnetgaronne answered 12/12, 2017 at 11:44 Comment(2)
If I didn't missing something, the testing with an implement of gRPC client is completely manual. It means You have to start the server manually then you can run the client to test it, right? – Longwood
@BrickYang yes you are partly correct. But usually server is started before the test cases ( for example in init method ) and it is stopped after all the test cases are completed. – Tarnetgaronne
D
2

You can also try this command line tool, evans, for testing gRPC

Demisec answered 9/6, 2020 at 7:34 Comment(1)
Try to avoid link-only answers, provide an example or some context around it. – Whitener

© 2022 - 2024 β€” McMap. All rights reserved.