MUAS
MUAS

Reputation: 626

Testing Grpc Services Written in Multiple Languages

So I have a fairly complex distributed system composed of multiple services (Service 1, Service 2, Service 3, and Service 4). Each one of these services is a grpc server and they often communicate with each other (e.g. Service 1 will make a rpc to Service 2 that will return a response, or Service 1 makes a rpc to Service 3 that makes another rpc to Service 4 before returning a response to Service 1). The tricky part is that these services are written in different programming languages, some of them are in Python and some of them are in Go.

How can I write tests for the rpc endpoints in each server if they are written in different languages, and what do I do for the rpc endpoints that need to contact another one of the services before returning a response?

Upvotes: 1

Views: 343

Answers (1)

Rahul
Rahul

Reputation: 36

You should be able to test each of these services independently using mocks.

For a service written in go you can use gomocks, please refer this link: https://www.google.com/url?sa=t&source=web&rct=j&url=https://github.com/golang/mock&ved=2ahUKEwi6nu2rquzpAhVNwjgGHcxiAekQFjAAegQIARAB&usg=AOvVaw3EoV6CtCn21kcU-Q4bneys

So if you need to test service 1 which has calls to service 2, you mock the service 2 to return the expected result. You should be able to find similar mocking frameworks for other languages as well

Upvotes: 2

Related Questions