Microservices and CDC(Consumer Driven Contract) tests
Monolithic architecture is where the entire modules are implemented in one single application. Now, this app could be faster as there will be not many network calls, faster in performance but does it suffice the other below points?
will it smoothly grow in size without the complexity? are continuous deployment and continuous integration possible as there will be frequent changes for different modules? business needs are growing rapidly and so does app scaling challenges. So is it scalable? being highly coupled modules, will the application work if one of the modules is down and another module has over traffic? Microservice architecture has all the above advantages. Monolithic is good if it's a small application and never changing but as it's said
"CODE IS NEVER WRITTEN, IT'S ALWAY REWRITTEN. CHANGE IS CONSTANT". Hence, Everyone is moving towards Microservice architecture.
The name itself explains that developing the individual small services is easy to test and deploy with the rapid growth. Over time there will be a large number of microservices where some are dependent on others as a consumer and some providing the services to the consumer.
Making frequent changes to each microservice will make the developer uncertain and unreliable to deploy it as dependent microservices may break if the contract fails. This is where the CDCs(Consumer-Driven Contract) test comes into the picture to give you confidence.
CDCs Setup between Consumer as a client and Provider API:
The consumer has to write the test for the contract between it and the Provider. The consumer has to tell the provider how it is using the Provider's service as a whole or part of it. In the pre-stage of deployment, Consumer will run the tests. Failing to pass the contract, deployment is not taken further. (not mandatory on all stages like dev, qa, staging or live). The Provider also runs the consumer test on its side before deploying it to make sure that its changes won't affect the consumers to whom it is providing the service. Consumer's test should be run on each environment (mandatory to run on dev, qa, staging and live) as a pre-stage(recommended). The reason being let's say if Provider runs contract tests in dev but not in live env then consumer live application will fail. CDCs setup can be done using the Pact framework which is widely used with its huge number of language support. It can also be done with the help of the DevOps team providing a provision to run tests at the pipeline stages.
Once CDCs are in place developers will be at peace of mind and have the confidence to push any changes!
Originally published on www.linkedin.com
Related Jobs
Related Articles
Related Issues
- Started
- 0
- 18
- Intermediate
- Submitted
- 1
- 0
- Intermediate
Get hired!
Sign up now and apply for roles at companies that interest you.
Engineers who find a new job through Functional Works average a 15% increase in salary.
Start with GitHubStart with TwitterStart with Stack OverflowStart with Email