{"id":1374,"date":"2022-03-08T08:00:38","date_gmt":"2022-03-08T15:00:38","guid":{"rendered":"https:\/\/bullyrooks.com\/?p=1374"},"modified":"2022-03-08T08:08:29","modified_gmt":"2022-03-08T15:08:29","slug":"kube-cloud-pt6-contract-testing","status":"publish","type":"post","link":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/08\/kube-cloud-pt6-contract-testing\/","title":{"rendered":"Kube Cloud Pt6 | Contract Testing"},"content":{"rendered":"\n<p>Contract testing may be the most misunderstood and overlooked concept in distributed software development.  As we&#8217;re developing microservices we&#8217;re going to need to do some service governance to make sure that service versions are compatible with each other.  This can normally be managed with a conversation between teams developing in a monolith, since neither of their changes can go out without breaking the codebase.  However, with microservice oriented teams operating at their own pace, service governance becomes much more important and tools (and accepted enterprise wide best practices) become much more important.  Since each of the teams are delivering at their own pace with the feature sets that they need, they need to make sure that changes that are introduced are compatible with existing services that depend on them.<\/p>\n\n\n\n<p>Part of the reason this is so often overlooked is that the concept involves two words that I find make engineers skin crawl<\/p>\n\n\n\n<p><strong>Testing<\/strong>: tests always seem to cause problems.  Hopefully, my approach to testing through component tests focused on behavior can make testing much easier and lower the barrier to introducing new tests.  Thankfully, contract tests are more like behavior tests than traditional unit tests.<\/p>\n\n\n\n<p><strong>Contracts<\/strong>: the term seems to imply some sort of process, which usually upsets developers<\/p>\n\n\n\n<p>Finally, the frameworks that were used to build contract tests were complicated and often inadequate.  This complexity often (rightfully) turned people off of them.  However, I have found that <a href=\"https:\/\/docs.pact.io\/\">pact<\/a>&#8216;s brand of contract testing not only lowers the barrier of entry by making tests easy, but their cloud hosted contract broker makes getting started easy and works well once you make changes to your build and deploy pipelines.  This is a key and often overlooked component:  your contract tests need to integrate into your build and deploy pipeline.  This is because they&#8217;re doing the heavy lifting of service governance for you by checking to see if services are compatible before they get deployed together.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setup a Pactflow account<\/h2>\n\n\n\n<p><a href=\"https:\/\/pactflow.io\/\">Pactflow<\/a> offers a cloud hosted pact broker that has a free trial account.  Go ahead and setup the account<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"65\" src=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-01-at-3.00.41-PM-1024x69.png?resize=960%2C65&#038;ssl=1\" alt=\"\" class=\"wp-image-1375\" srcset=\"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-01-at-3.00.41-PM.png?resize=1024%2C69&amp;ssl=1 1024w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-01-at-3.00.41-PM.png?resize=300%2C20&amp;ssl=1 300w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-01-at-3.00.41-PM.png?resize=768%2C52&amp;ssl=1 768w, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-01-at-3.00.41-PM.png?w=1026&amp;ssl=1 1026w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>Once you create an account you should see the dashboard that looks like this:<\/p>\n\n\n\n<p><\/p>\n\n\n\n\n\n<p>Pactflow provides a broker which will be the place where contracts (defined by client contract unit tests) will be stored.  The broker not only knows about all of the contracts and who the customer and providers are, but they can verify that the providers have &#8220;met the contract&#8221; through provider contract unit tests.  The process of verifying that the contract has been met will be built into our pipelines and will either allow or halt the deployment of services that have validated or broken their contracts.<\/p>\n\n\n\n<p>Lets start with writing some consumer contracts.  We&#8217;ll be building the contract test from cloud-application to message-generator (synchronous REST call) as well as the contract test from message-repository to cloud-application (asynchronous messaging).<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\nContract testing may be the most misunderstood and overlooked concept in distributed&hellip;\n<\/div>\n<div class=\"link-more\"><a href=\"https:\/\/bullyrooks.com\/index.php\/2022\/03\/08\/kube-cloud-pt6-contract-testing\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Kube Cloud Pt6 | Contract Testing&rdquo;<\/span>&hellip;<\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[199,197,198,200,43],"course":[196],"class_list":["post-1374","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-contract-testing","tag-pact","tag-pactflow","tag-service-governance","tag-spring-boot","course-kube-cloud-pt6-contract-testing","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1439,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/13\/kube-cloud-pt6-synchronous-contract-testing-conclusion\/","url_meta":{"origin":1374,"position":0},"title":"Kube Cloud Pt6 | Synchronous Contract Testing Conclusion","author":"Bullyrook","date":"March 13, 2022","format":false,"excerpt":"This course absolutely warrants a final thoughts page. Contract testing can be quite powerful, but it has to be done correctly and that means that you need quite a bit of engineering experience not only from a software development side, but also from an operations CICD side as well. First\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":832,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-22-e37d26471e9e\/","url_meta":{"origin":1374,"position":1},"title":"Conclusion and Review","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"Up to this point we\u2019ve been writing, testing, building, deploying and integrating services. Lets take a moment to reflect on what we have accomplished and why. Here we are at 22 articles in. That seems like a lot, but I wanted to write these articles in an easily ingested way\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1395,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/12\/kube-cloud-pt6-update-to-consumer-contract\/","url_meta":{"origin":1374,"position":2},"title":"Kube Cloud Pt6 | Break the Contract from a Consumer Change","author":"Bullyrook","date":"March 12, 2022","format":false,"excerpt":"We're going to go back to cloud-application at this point and update our client to expect a field that isn't being currently provided (message generated date). This should break our contract test and prevent us from deploying, but there's some updates we need to make to support this. Add the\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/image-25.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/image-25.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/image-25.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":815,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-14-8e1ade0b7b84\/","url_meta":{"origin":1374,"position":3},"title":"System Design","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"We\u2019ve successfully deployed a service and confirmed that its accessible. However, a single service doesn\u2019t make an app. We now need to fill out the rest of the application and introduce some best practices around service governance and system engineering. The Application Design We\u2019re going to be organizing the UI\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":828,"url":"https:\/\/bullyrooks.com\/index.php\/2020\/03\/30\/simple-spring-boot-service-to-kubernetes-application-step-4-dba10da3d834\/","url_meta":{"origin":1374,"position":4},"title":"Create a REST Controller","author":"Bullyrook","date":"March 30, 2020","format":false,"excerpt":"In this article we\u2019re going to take the service layer we created in the last step and add a REST interface to it. We\u2019re going to follow the hexagonal design principles we previously discussed and add a functional or component test and explain how those test work and why they\u2019re\u2026","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1447,"url":"https:\/\/bullyrooks.com\/index.php\/2023\/05\/14\/unit-tests-vs-component-tests-which-ones-better-for-software-quality\/","url_meta":{"origin":1374,"position":5},"title":"Unit Tests vs. Component Tests: Which One&#8217;s Better for Software Quality?","author":"Bullyrook","date":"May 14, 2023","format":false,"excerpt":"Dive into the good and bad of unit tests and component tests in software development. Find out how to get the best of both worlds for top-notch code quality.","rel":"","context":"In &quot;Software Development&quot;","block_context":{"text":"Software Development","link":"https:\/\/bullyrooks.com\/index.php\/category\/software-development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/comments?post=1374"}],"version-history":[{"count":2,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1374\/revisions"}],"predecessor-version":[{"id":1398,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1374\/revisions\/1398"}],"wp:attachment":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/media?parent=1374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/categories?post=1374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/tags?post=1374"},{"taxonomy":"course","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/course?post=1374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}