<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexander Zagniotov on Medium]]></title>
        <description><![CDATA[Stories by Alexander Zagniotov on Medium]]></description>
        <link>https://medium.com/@alexanderzagniotov?source=rss-28417a841399------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PzhtOkEJuv4Om9s7FKnktA.jpeg</url>
            <title>Stories by Alexander Zagniotov on Medium</title>
            <link>https://medium.com/@alexanderzagniotov?source=rss-28417a841399------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:23:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexanderzagniotov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing Microservices in Docker and Docker Compose]]></title>
            <link>https://alexanderzagniotov.medium.com/testing-microservices-in-docker-and-docker-compose-4dd54b02bd1c?source=rss-28417a841399------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dd54b02bd1c</guid>
            <category><![CDATA[integration-testing]]></category>
            <category><![CDATA[microservices-testing]]></category>
            <category><![CDATA[contract-testing]]></category>
            <category><![CDATA[stubby4j]]></category>
            <category><![CDATA[api-testing]]></category>
            <dc:creator><![CDATA[Alexander Zagniotov]]></dc:creator>
            <pubDate>Sat, 22 May 2021 01:33:58 GMT</pubDate>
            <atom:updated>2021-12-26T13:07:06.972Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Testing Microservices with Docker and Docker Compose</h3><h3>Overview</h3><p>The current post talks about local testing of micro-service interactions in Docker Compose environment and stubbing some of these micro-services in <a href="https://stubby4j.com/">stubby4j</a>, an HTTP/1.1, HTTP/2 and WebSockets API stub server. The tutorial emphasizes the usage of <a href="https://stubby4j.com/">stubby4j</a> in order to demonstrate how it can help with testing of micro-services.</p><p>Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.</p><p><a href="https://stubby4j.com/">https://stubby4j.com</a> is a tool for stubbing external systems in both Docker and non-containerized environments for integration, contract and behavior testing. stubby4j allows you to configure (i.e.: to stub) various failure/success scenarios with simple HTTP responses, as well as complex HTTP responses. See <a href="https://stubby4j.com/#key-features">stubby4j key features</a> for more information.</p><h3>Introduction</h3><p>When developing and testing microservices, it is good practice to focus on testing interactions of the service with its direct upstream/downstream dependencies.</p><ul><li>Testing that a service makes requests with expected headers and/or parameters,</li><li>Testing that the service exposes the right endpoints,</li><li>Testing that the service handles success/failure responses as expected and knows how to gracefully handle unexpected failures; or</li><li>Testing that the service interacts properly with external APIs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*n0dmr2H0AD_5_kkhC7YBmA.png" /></figure><p>In order to perform such tests, you would have to fake your indirect dependencies. Faking your dependencies can be easily achieved with <a href="https://stubby4j.com/">stubby4j</a>. It helps to address the use cases outlined below (this is by no means an exhaustive list).</p><ul><li>Simulate responses from a real server and don’t care (or cannot) to send requests over the network</li><li>Stub out external web services (when developing &amp; testing locally) in a Docker based micro-service architecture</li><li>Verify that your application behaves as expected upon WebSocket server pushes</li><li>Verify that your code makes HTTP/1.1 or HTTP/2 (over TLS) requests with all the required parameters and/or headers</li><li>Avoid negative productivity impact when an external API you depend on doesn’t exist or isn’t complete</li><li>Simulate edge cases and/or failure modes for your web service that the real remote API won’t reliably produce</li><li>Inject faults, where after X good responses on the same URI your web service gets a bad one</li><li>Verify that your code makes HTTP requests with all the required parameters and/or headers</li><li>Verify that your code correctly handles HTTP response error codes</li></ul><p>There are a number of use cases where you’d want to use HTTP stub server in your development/QA environment. If you are a Software Engineer/Test Engineer/QA, then the above should hit close to home for you.</p><p>In this tutorial we will learn how to test microservices running in Docker environment by leveraging the Docker Compose and dependency stubbing with <a href="https://stubby4j.com/">stubby4j</a>.</p><h3>Approach</h3><p>We use docker compose to spin up two local Docker containers in an isolated environment using the definitions in the local <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/docker-compose.yaml">docker-compose.yaml</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c85c38934db9ba1b54c93a7431be05d/href">https://medium.com/media/4c85c38934db9ba1b54c93a7431be05d/href</a></iframe><ol><li>Flight Booking web service (starts on 0.0.0.0:8080). A REST-ful web service that fetches some information about a fake flight booking which consists from fake user account and fake user reservation information. The service exposes a single endpoint /api/v1/flights/1 and relies on two downstream web services for the Account and Reservation information.<br><em>Please note that </em><em>Account and </em><em>Reservation services do not exist. The idea here is to assume that they are still being developed and thus need to be stubbed for our local testing in the meanwhile.</em></li><li>stubby4j, an HTTP stub server (starts on 0.0.0.0:8882). The endpoints of the two web services Account and Reservation that Flight Booking consumes are stubbed in stubby4j.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*Rf8lDESLvckFyVvMg_vrZg.png" /></figure><p>The main idea behind the current exercise is to test the behavior of the Flight Booking service when the /api/v1/flights/1 API is invoked and its downstream dependencies (i.e.: the stubbed Account and Reservation services) produce the following HTTP response codes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/257e0bf63dd44fd0828542a3910faa87/href">https://medium.com/media/257e0bf63dd44fd0828542a3910faa87/href</a></iframe><h3>Stubbing dependencies</h3><p>stubby4j stubs defined in the following YAML config <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/stubs.yaml">stubby4j-yaml-config/stubs.yaml</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8a3882dd4fc148c8e71a9328ac8ad8/href">https://medium.com/media/9c8a3882dd4fc148c8e71a9328ac8ad8/href</a></iframe><p>The Account service specific stub are defined in <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/include-account-service-stubs.yaml">stubby4j-yaml-config/include-account-service-stubs.yaml</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fae46f1c9a96ba7bdca8b499c87ed66/href">https://medium.com/media/2fae46f1c9a96ba7bdca8b499c87ed66/href</a></iframe><p>while the Reservation service specific stubs are defined in <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/include-reservation-service-stubs.yaml">stubby4j-yaml-config/include-reservation-service-stubs.yaml</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1c753164fe2b45e67da52eac2f8ebb7/href">https://medium.com/media/d1c753164fe2b45e67da52eac2f8ebb7/href</a></iframe><p>When creating stub definitions, you can start by crafting a simple HTTP response by hand inside the YAML config. Unfortunately this method of stubbing makes it harder to define realistic responses and probably won’t scale as your project grows.</p><p>If you have a dump of a realistic HTTP response from a real blackened in a local file, stubby4j can load it via the file YAML property are runtime, i.e.: <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/include-reservation-service-stubs.yaml">stubby4j-yaml-config/include-reservation-service-stubs.yaml</a></p><p>Alternatively, you can use <a href="https://stubby4j.com/docs/http_endpoint_configuration_howto.html#record-and-replay">Record &amp; Replay</a> or <a href="https://stubby4j.com/docs/http_endpoint_configuration_howto.html#request-proxying">Request proxying</a> stubby4j features to record an HTTP response from a real backend for automatic replaying. This method of stubbing can scale better with your project development lifecycle.</p><p>To understand in more depth the stubby4j configuration options beyond the current tutorial, see the <a href="https://stubby4j.com/docs/http_endpoint_configuration_howto.html">HTTP Endpoint configuration HOWTO</a> for more information.</p><h3>Building &amp; Running</h3><h4>Building</h4><p>From root folder with stubby4j configuration run $ docker-compose up. In another terminal you can query the logs from the command line or if running a Docker for Desktop GUI, you can select the logs from an active container.</p><h4>Explanation</h4><p>The command builds the Flight Booking image using the local <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/Dockerfile">Dockerfile</a> (this can take a few minutes, please be patient) and fetches pre-built stubby4j Docker image from <a href="https://hub.docker.com/r/azagniotov/stubby4j">https://hub.docker.com/r/azagniotov/stubby4j</a></p><h4>Running</h4><p>Make a cURL (or in Postman / web browser) request:</p><p>$ curl -X GET &quot;http://localhost:8080/api/v1/flights/1&quot;</p><p><strong>IMPORTANT: Docker on MacOS Caveats</strong></p><blockquote>If your cURL requests to http://localhost:8080/api/v1/flights/1 fails with Connection refused, it means that the mapping of host machine port 8080 to the Docker container port 8080 did not work. You may need to setup port forwarding for port 8080 in VirtualBox: Settings =&gt; Network =&gt; Adapter 1 (NAT) =&gt; Advanced =&gt; Port Forwarding.</blockquote><h3>Flight Booking service responses</h3><p>Flight Booking responds with 200 OK &amp; the following JSON response (use-case #1 in the aforementioned table):</p><pre>{<br>  &quot;reservation&quot; : &quot;p5e20A9hSi2IsV0soVpafQ==&quot;,<br>  &quot;name&quot; : &quot;Leanne Graham&quot;,<br>  &quot;phone&quot; : &quot;1-770-736-8031 x56442&quot;,<br>  &quot;basePrice&quot; : &quot;USD10.00&quot;,<br>  &quot;taxes&quot; : &quot;EUR19.62&quot;<br>}</pre><p>Flight Booking responds with 500 Internal Server Error &amp; the following JSON response (use-case #2 in the aforementioned table):</p><pre>{&quot;code&quot;: 500, &quot;message&quot;: &quot;Server.ValidationException&quot;}</pre><p>Flight Booking responds with 500 Internal Server Error &amp; the following JSON response (use-case #3 in the aforementioned table):</p><pre>{&quot;code&quot;: 500, &quot;message&quot;: &quot;null&quot;}</pre><p>Flight Booking responds with 500 Internal Server Error &amp; the following JSON response (use-case #4 in the aforementioned table):</p><pre>{&quot;code&quot;: 500, &quot;message&quot;: &quot;Internal Server Error&quot;}</pre><p>Flight Booking responds with 500 Internal Server Error &amp; generic Tomcat error due to socket read timeout (use-case #5 in the aforementioned table). This is an example of a use case which Flight Booking service does not handle gracefully - request read timeout.</p><h4>Explanation</h4><p>Upon a GET request to the aforementioned http://localhost:8080/api/v1/flights/1 the following data is returned from the two stubbed Account and Reservation services:</p><ul><li>The Account service endpoint /api/v1/accounts/1 always responds with the HTTP status 200 OK and the same HTTP JSON response defined in <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/json/account.service.expected.success.response.json">stubby4j-yaml-config/json/account.service.expected.success.response.json</a></li><li>The Reservation service endpoint /api/v1/reservations/1 responds with different HTTP responses on each invocation of http://localhost:8080/api/v1/flights/1 . There are a total of five different HTTP responses that stubby4j loops over when rendering responses for /api/v1/reservations/1: 200 OK, 400 Bad Request, 403 Forbidden and two 500 Internal Server Error with different JSON response bodies defined under <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/json">stubby4j-yaml-config/json</a>.</li></ul><h3>Logs</h3><p>At runtime, the stubby4j application logs are emitted into stubby4j-yaml-config/logs/stubby4j.log. The logs contain debug information from matching incoming HTTP requests to the defined stubs.</p><h3>Conclusion</h3><p>In this tutorial, we’ve learnt how to test microservices locally running in a Docker environment by leveraging Docker Compose and stubby4j, an HTTP stub server.</p><p>We also saw how to stub multiple HTTP responses with different behavior under the same stubbed URI defined in defined in <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose/blob/master/stubby4j-yaml-config/include-reservation-service-stubs.yaml">stubby4j-yaml-config/include-reservation-service-stubs.yaml</a>.</p><p>To understand in more depth the stubby4j capabilities and the available features, see <a href="https://stubby4j.com/">https://stubby4j.com</a> and <a href="https://stubby4j.com/docs/http_endpoint_configuration_howto.html">HTTP endpoint configuration HOWTO</a> for more information.</p><p>The source code for this tutorial is available over on <a href="https://github.com/azagniotov/testing-microservices-in-docker-and-docker-compose">GitHub</a>.</p><p>Oh, did I mention that <a href="https://stubby4j.com/">stubby4j</a> supports API stubbing <a href="https://stubby4j.com/#support-for-http2-on-https-uris-over-tls">over HTTP/2</a> and <a href="https://stubby4j.com/docs/websockets_configuration_howto.html">also WebSocket</a> protocols? :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dd54b02bd1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buying COTS VS Building In-House]]></title>
            <link>https://alexanderzagniotov.medium.com/buying-cots-vs-building-in-house-24a542079625?source=rss-28417a841399------2</link>
            <guid isPermaLink="false">https://medium.com/p/24a542079625</guid>
            <dc:creator><![CDATA[Alexander Zagniotov]]></dc:creator>
            <pubDate>Mon, 09 Feb 2015 15:49:33 GMT</pubDate>
            <atom:updated>2015-02-09T15:49:33.923Z</atom:updated>
            <content:encoded><![CDATA[<p>The following is a set of <em>guidelines</em> (not rules set in stone) that help to understand better when to build software in-house VS buying a commercial of the shelf (COTS) software product. These guidelines are drawn from the experiences of several colleagues &amp; friends I have work(ed|ing) with:</p><ol><li>If a software is core to your business, <strong><em>BUILD IT. </em></strong>Also, one of the reasons not to buy COTS when it is core to your business — your competitors can buy the same software solution you are using. Hence, you lose your competitive advantage</li><li>If you are willing to change Your business processes to match the COTS, <strong><em>BUY IT</em></strong></li><li>If there is COTS and you have to do <em>significant</em><strong> </strong>customization that doesn’t match their model, <strong><em>BUILD IT</em></strong></li><li>If there is COTS and you have to do <em>insignificant</em><strong> </strong>customization within their model, <strong><em>BUY IT. </em></strong>If, while trying to customize you realize that the effort is much more significant than anticipated with less of a match to your business, <strong><em>BUILD IT</em></strong></li><li>If it gets your product out the door significantly quicker and starts your business (signs up customers, generates revenue, etc) <strong><em>BUY IT. </em></strong>If it wasn’t too expensive or no longer adds value to your business, come back around and <strong><em>BUILD IT </em></strong>later</li><li>If other services that are core to your business have to integrate with COTS, and evolving this integration is going to impact your ability to serve business needs, <strong><em>BUILD IT</em></strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24a542079625" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You Are Doing Continuous Integration Only If]]></title>
            <link>https://alexanderzagniotov.medium.com/you-are-doing-continuous-integration-only-if-9caac4e05ece?source=rss-28417a841399------2</link>
            <guid isPermaLink="false">https://medium.com/p/9caac4e05ece</guid>
            <dc:creator><![CDATA[Alexander Zagniotov]]></dc:creator>
            <pubDate>Mon, 09 Feb 2015 15:07:14 GMT</pubDate>
            <atom:updated>2015-02-13T22:39:37.956Z</atom:updated>
            <content:encoded><![CDATA[<p>Throughout my career, I have been on various teams doing continuous integration. The following are the takeaways drawn from my experience, learnings &amp; observation. <strong>You are doing continuous integration Only if</strong>:</p><ol><li>The CI tool is running on the main code line (trunk/master)</li><li>All engineers on the team checking-in to trunk/master at least once a day</li><li>Feature branches are merged into trunk/master at least once a day</li><li>Every code check-in/push results in build and test suite being run</li><li>The build is not broken for more than a few minutes at the time nor build left broken overnight</li><li>Latest code changes that broke the build reverted if it takes long time to fix it (“long” here can be longer than 15 mins)</li><li>Engineers on the team have the mindset &amp; discipline to rollback their build breaking changes if the latter are blocking everyone else from working of a known good code state</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9caac4e05ece" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>