{"id":1439,"date":"2022-03-13T17:23:40","date_gmt":"2022-03-14T00:23:40","guid":{"rendered":"https:\/\/bullyrooks.com\/?p=1439"},"modified":"2022-05-28T10:37:06","modified_gmt":"2022-05-28T17:37:06","slug":"kube-cloud-pt6-synchronous-contract-testing-conclusion","status":"publish","type":"post","link":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/13\/kube-cloud-pt6-synchronous-contract-testing-conclusion\/","title":{"rendered":"Kube Cloud Pt6 | Synchronous Contract Testing Conclusion"},"content":{"rendered":"\n<p>This course absolutely warrants a final thoughts page.  Contract testing can be quite powerful, but it has to be done <strong>correctly<\/strong> 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.<\/p>\n\n\n\n<p>First the downsides<\/p>\n\n\n\n<div class=\"wp-block-jetpack-send-a-message\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Support<\/h2>\n\n\n\n<p>Pact has been in active development for awhile.  Its implementations are sprawling. There are several libraries that have overlapping functionality that are in various states of maturity.  The documentation is okay, but its not clear what best practices are.  Additionally, there are <strong>loads<\/strong> of proof of concept demonstrations available online (and I&#8217;m probably adding to the noise) with differing levels of &#8216;good&#8217; implementation and depth.  A lot of the demos out there are out of date and don&#8217;t work well with the more recently libraries.  This has safely been the most time I&#8217;ve spent (2 weekends) trying to get something working and documented.<\/p>\n\n\n\n<p>I&#8217;ve worked with the pact team before and they&#8217;re knowledgeable and supportive, but this project feels like its a little of &#8216;everything for everyone&#8217;:  lots of configuration but little in the way of convention (defined best practices and the framework guiding you to them).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Engineering Maturity<\/h2>\n\n\n\n<p>If you work in an organization where the CICD pipeline is owned by another team (usually called devOps, but there&#8217;s no interest in software development), you&#8217;re going to struggle being successful implementing contract testing with pact.  I had to backup and rethink my workflow a few times.  If you have siloed software engineering from operations, you&#8217;re going to get frustrated and it wouldn&#8217;t surprise me if an operations team that is working with engineergs trying to implement pact says something like &#8216;go off and figure it out and then tell us what you want to do when you have a plan&#8217;.  <\/p>\n\n\n\n<p>It didn&#8217;t help that pact&#8217;s guidance (tags vs environments and releases) has evolved as well and some of the tools support their new model (stick with the docker cli) and some tools don&#8217;t (maven plugin).  <\/p>\n\n\n\n<p>I literally kicked off probably 100 github action workflows tinkering with the pipelines working on this.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Production Readiness<\/h2>\n\n\n\n<p>You will probably get to a point with pact that you are literally blocked.  You can&#8217;t deploy a consumer because the provider doesn&#8217;t support the contract and the provider can&#8217;t deploy because it can&#8217;t fulfill a contract.  Will you have the experience to untie that knot?  Will you have to &#8216;delete the integration&#8217; and start over (I&#8217;ll admit, I did it a few times)?  Will you have people in your team supporting you (devOps) or people demanding that you tear down contract testing (usually engineering leadership)?  Can you slowly roll it out and harden process against the edge cases?  Will you be able to implement rollback?  If not, you could bring your engineering organization to a standstill.<\/p>\n\n\n\n<p>Now the positive side<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Proactive vs Reactive<\/h2>\n\n\n\n<p>I prefer contract testing so that we can prevent issues in production before we have to react to them.  If I can prevent a team from delivering a breaking change and also <strong>inform<\/strong> them of why its a breaking change and which service it impacts, I can then point them to the right people to talk to to see how to fix the issue.<\/p>\n\n\n\n<p>This actually saves time in the long run and the costs of multi team war rooms trying to figure out why we&#8217;re losing money by the minute.  Those get expensive really fast.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Improved Communication<\/h2>\n\n\n\n<p>Its a little counterintuitive since a system is sitting in the middle of your CICD pipeline &#8216;replacing&#8217; a conversation that should have happened.  However, in my experience software teams (especially those empowered by microservice development to release early and often) are not doing the due diligence they should have been doing to understand systemic impacts of service releases.  <\/p>\n\n\n\n<p>Pact will probably trigger conversations about service governance best practices like<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>What is a breaking change<\/li><li>Semantic versioning<\/li><li>Dependency mapping<\/li><li>Service level objectives<\/li><li>The purpose of your microservice (put an end to people making your service do more than it was intended to do)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Reduced Dependency on End to End Testing<\/h2>\n\n\n\n<p>The entire goal of contract testing is to make sure that if your services meet their defined specifications then everything &#8216;should work&#8217;.  The only way to &#8216;prove&#8217; this before was to write an end to end test that did just that.  However, end to end test suites begin to balloon and eventually become monsters of their own within your organization.  <\/p>\n\n\n\n<p>Contract testing may slow down an individual build and slightly increase build dependencies (the webhook is an example), but this is peanuts compared to multi-hour end to end tests that eat up your acceptance testing environments.  If I had to make the choice, I would choose contract tests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When Should you use Contract Testing<\/h2>\n\n\n\n<p><a href=\"https:\/\/docs.pact.io\/#when-would-i-use-contract-testing\">Pact has thoughts on this<\/a>.  So do I.  <\/p>\n\n\n\n<p>Use contract testing sparingly.  Use it when you have externally available services (write your own consumer contracts and confirm that you don&#8217;t break them).  Use them when you have service interactions already in place (don&#8217;t start with pact, unless you&#8217;re an expert).  Don&#8217;t use them for intra-domain service interactions, use them for inter-domain service interactions (usually interfaces that are used between teams).  <\/p>\n\n\n\n<p>Pact <strong>will<\/strong> (slightly) slow you down in the short term, so don&#8217;t do this to yourself when you&#8217;re writing greenfield services that are all within the same domain.  Its a very good tool to use when you want to make sure that you don&#8217;t break something that will be noticed by someone on another team.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"entry-summary\">\nThis course absolutely warrants a final thoughts page. Contract testing can be&hellip;\n<\/div>\n<div class=\"link-more\"><a href=\"https:\/\/bullyrooks.com\/index.php\/2022\/03\/13\/kube-cloud-pt6-synchronous-contract-testing-conclusion\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &ldquo;Kube Cloud Pt6 | Synchronous Contract Testing Conclusion&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],"course":[196],"class_list":["post-1439","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-contract-testing","tag-pact","tag-pactflow","course-kube-cloud-pt6-contract-testing","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1374,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/08\/kube-cloud-pt6-contract-testing\/","url_meta":{"origin":1439,"position":0},"title":"Kube Cloud Pt6 | Contract Testing","author":"Bullyrook","date":"March 8, 2022","format":false,"excerpt":"Contract testing may be the most misunderstood and overlooked concept in distributed software development. As we're developing microservices we'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\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":1402,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/08\/kube-cloud-pt6-fulfill-the-consumer-contract-test-for-rest-endpoint\/","url_meta":{"origin":1439,"position":1},"title":"Kube Cloud Pt6 | Fulfill the Consumer Contract Test for REST Endpoint","author":"Bullyrook","date":"March 8, 2022","format":false,"excerpt":"Now we need to fulfill our contract with the consumer. We just need to add a few pieces that that a consumer build will trigger a provider verification. Add a Verification Workflow Go back to your branch in message-generator and add a new github action workflow called verify-changed-pact.yaml with this\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-15.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/image-15.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/image-15.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1377,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/08\/kube-cloud-pt6-consumer-contract-tests-for-rest-endpoints\/","url_meta":{"origin":1439,"position":2},"title":"Kube Cloud Pt6 | Consumer Contract Tests for REST Endpoints","author":"Bullyrook","date":"March 8, 2022","format":false,"excerpt":"Let's start with cloud-application, create a new branch git checkout -b client-contract Lets add the necessary dependencies to our pom.xml <pact.version>4.0.10<\/pact.version> <pact.provider.maven.plugin>4.3.5<\/pact.provider.maven.plugin> <\/properties> ... <!-- Contract Testing --> <dependency> <groupId>au.com.dius<\/groupId> <artifactId>pact-jvm-consumer-junit5<\/artifactId> <version>${pact.version}<\/version> <scope>test<\/scope> <\/dependency> ... <plugin> <groupId>au.com.dius.pact.provider<\/groupId> <artifactId>maven<\/artifactId> <version${pact.provider.maven.plugin}<\/version> <configuration> <pactBrokerUrl>${env.PACTFLOW_URL}<\/pactBrokerUrl> <pactBrokerToken>${env.PACTFLOW_TOKEN}<\/pactBrokerToken> <projectVersion>${env.PACT_PUBLISH_CONSUMER_VERSION}<\/projectVersion> <pactBrokerAuthenticationScheme>Bearer<\/pactBrokerAuthenticationScheme> <\/configuration> <\/plugin> Pact is mostly a\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\/Screen-Shot-2022-03-02-at-2.04.53-PM.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-02-at-2.04.53-PM.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-02-at-2.04.53-PM.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-02-at-2.04.53-PM.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/bullyrooks.com\/wp-content\/uploads\/2022\/03\/Screen-Shot-2022-03-02-at-2.04.53-PM.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1387,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/08\/kube-cloud-pt6-provider-contract-test-for-rest-endpoints\/","url_meta":{"origin":1439,"position":3},"title":"Kube Cloud Pt6 | Provider Contract Test for REST Endpoints","author":"Bullyrook","date":"March 8, 2022","format":false,"excerpt":"Now lets move over to message-generator repo and create a new branch git checkout -b provider-test Pom Updates for Dependencies Update the pom.xml to pull in both the provider test library and the plugin ... <pact.version>4.3.5<\/pact.version> <maven-failsafe-plugin.version>3.0.0-M5<\/maven-failsafe-plugin.version> <maven-surefire-plugin.version>3.0.0-M5<\/maven-surefire-plugin.version> <pact.maven.plugin.version>4.3.5<\/pact.maven.plugin.version> <\/properties> ... <profiles> <profile> <id>contract<\/id> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin<\/artifactId> <version>${maven-surefire-plugin.version}<\/version> <configuration>\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-10.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1395,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/03\/12\/kube-cloud-pt6-update-to-consumer-contract\/","url_meta":{"origin":1439,"position":4},"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":1141,"url":"https:\/\/bullyrooks.com\/index.php\/2022\/01\/02\/kubernetes-application-hosted-in-the-cloud\/","url_meta":{"origin":1439,"position":5},"title":"Kubernetes Application Hosted in the Cloud","author":"Bullyrook","date":"January 2, 2022","format":false,"excerpt":"It's been a few years since my last spring boot based kubernetes application. That course ended with a microservice deployed into kubernetes via minikube locally. I'm using this course to expand on that effort. In this course I'm going to show a few ways to do the same things in\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":[]}],"_links":{"self":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1439","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=1439"}],"version-history":[{"count":2,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1439\/revisions"}],"predecessor-version":[{"id":1443,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/posts\/1439\/revisions\/1443"}],"wp:attachment":[{"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/media?parent=1439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/categories?post=1439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/tags?post=1439"},{"taxonomy":"course","embeddable":true,"href":"https:\/\/bullyrooks.com\/index.php\/wp-json\/wp\/v2\/course?post=1439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}