Search

Monday, December 11, 2017

Consumer-driven contract testing

Why CDC ?

When adopting microservice architecture, the system comprises of multiple microservices that makes integration test more difficult.
To verify end-to-end test we can do 1 of the following
  • Deploy all microservices to test
  • Mock other microservices
But both approaches have lots of disadvantages.
The idea of CDC is to have a contract between service producer and consumer, both side will verify again the contract if any changes violate it tests will fail.  

How ?

There are some cool frameworks , Pact is a popular one https://docs.pact.io/#
Last year Spring cloud contract project started and is gaining attention sine it supports Spring applications well.
Steps:
Producer side:
  • Define the contracts using Groovy DSL
  • The framework generates tests based on the contracts
  • Implement endpoints to pass tests
  • Generate stub data and upload to a common place for consumers to access ( stubs is packaged as a jar file and can be pushed to central Maven repo )
Consumer side:
  • Get stub data from producer
  • A WireMock instance will start with the stub data
  • Execute tests with stub http server (WireMock)
In case producer changes its implementation and violates contract, the generated tests on producer side will fail developers have to either fix implementation or change the contract.
In case the contract get modified, tests on Consumer side may fail and developers needs to verify the contract and change implementation accordingly.
Consumer sample: contract-consumer
Provide consumer: contract-provider

2 comments:

  1. First, the dealer will place a card face up after which split the deck into two piles. One of the 영앤리치 토토 most popular card games in India, Teen Patti has now been up to date for the digital age. In this sport, all gamers start by placing the identical stake into the pot of cash. Everyone is then dealt three playing cards, and every participant must determine whether or not to call or raise the stakes. Love classic desk games however want one thing completely different? Fire up a sport of Lightning Dice, be taught to play Sic Bo or spin the wheel with an unforgettable sport of Dream Catcher.

    ReplyDelete
  2. The finest on-line casinos do not always have the largest libraries around, but they do 원 엑스 벳 tend to to|are inclined to} have a various mixture of video games that can appeal to a large base of gamers. That variety is normally delivered method of|by means of|by the use of} game style, nevertheless it can also be|may also be|can be} demonstrated by using a wholesome combination of different software developers. Taking our number one spot is Ignition, boasting a unbelievable cellular poker experience along with many other on line casino video games. There are other on line casino apps we think you should to} a glance at|check out} too, all in this article.

    ReplyDelete

Business blockchain use cases