Published on

Initial Stab at Testing Microservice Communication


We are in the process of trying to streamline our deployment process especially as we add more microservices to our ecosystem. The key thing we need in place first is ensuring that we know when deploying a service that we are not breaking other downstream services.

I started looking at a tool for contract tests called Pact. It is named this way as pact is a contract - in this case a contract between microservices.

I am still busy getting a proper feel for it but the basic gist I have so far is that you define a pact/contract in a microservice that consumes another service I.e the consumer. You define what api you are hitting and what the expected headers and responses look like. A mock server is then run against this.

You code the same pact on the server and confirm it still passes. One thing I'm still working out as part of this process is if this hits the real service from the consumer and if not how these tests break if the api changes and breaks the pact. I will get more into the details of this as I uncover more.