<?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 Miguel Jiménez on Medium]]></title>
        <description><![CDATA[Stories by Miguel Jiménez on Medium]]></description>
        <link>https://medium.com/@milingo?source=rss-44981f6c52a0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bjQK_3OaDFxCjGzCMKrlQw.jpeg</url>
            <title>Stories by Miguel Jiménez on Medium</title>
            <link>https://medium.com/@milingo?source=rss-44981f6c52a0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:27:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@milingo/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[Undressing old testing myths]]></title>
            <link>https://medium.com/sentisis-engineering/undressing-old-testing-myths-c1348f0a10a7?source=rss-44981f6c52a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1348f0a10a7</guid>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Miguel Jiménez]]></dc:creator>
            <pubDate>Mon, 05 Feb 2018 12:56:54 GMT</pubDate>
            <atom:updated>2023-12-27T17:36:17.034Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4S35xPsqmttab2VwINoMw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/DuBNA1QMpPA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">ian dooley</a> on <a href="https://unsplash.com/@nativemello?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Run away from those silver-bullet QA statements</h4><p>When I first heard of Agile and Scrum (about 6 years ago) I was very excited, it was a game-changer. So I started learning about it, but no matter what source I choose to do it, there was always something missing — testing. Even when one of the bibles on Scrum, <a href="https://www.goodreads.com/book/show/6707987-succeeding-with-agile">Succeeding with Agile</a>, fell into my hands it felt kind of… disappointing, there was nothing new on Quality Assurance (maybe the <a href="https://martinfowler.com/bliki/TestPyramid.html">Test Pyramid</a>?), it was basically the same stuff I had been doing for years, no adaptation at all.</p><p>I then had a feeling that would repeat over time when thinking about testing: We always leave it behind. Even worst — <strong>we live from outdated misbeliefs everybody takes for granted</strong>. I keep on hearing the same statements again and again over the years, sometimes coming out of my mouth. I would like to write them down and try to demystify them:</p><blockquote><strong>NOTE</strong>: I use the term <strong>Integration Tests</strong> several times throughout the article. I’m aware it is a blurred term that can have lots of meanings (interactions between modules, between services, <a href="https://martinfowler.com/bliki/IntegrationTest.html">Narrow Integration Tests</a>, <a href="https://labs.spotify.com/2018/01/11/testing-of-microservices/">Integrated Tests</a>…). Here I use it as a global concept that includes all of those.</blockquote><h4>I have nearly 100% test coverage</h4><p>That metric alone can be misleading. First of all, maybe you spent way too many resources to get there — I’m of course talking about the well-known <a href="https://en.wikipedia.org/wiki/Pareto_principle">Pareto principle</a> (80% of the work takes 20% of the time). Furthermore, depending on how you made those tests, you may have a whole new maintenance nightmare.</p><p>I recently had to work on two different projects, one significantly bigger than the other but otherwise similar. Both had nearly equal coverage for lines (92%-94%) and branches (70%-80%) but where the first one used 2700 tests the other had just 11 (including integration). Last time I refactored the first one, my commits never made it to production because I was unable to make the tests work; last time I touched the second one, I didn’t even have to update the tests.</p><p>I’ve seen developers flatter about the number of tests they created for a certain functionality. That’s a bad smell, <a href="https://blog.kentcdodds.com/write-tests-not-too-many-mostly-integration-5e8c7fff591c"><strong>prefer one good integration test to many unit tests</strong></a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fi.imgur.com%2FZmvuDQx.mp4&amp;src_secure=1&amp;url=https%3A%2F%2Fi.imgur.com%2FZmvuDQx.gifv&amp;image=https%3A%2F%2Fi.imgur.com%2FZmvuDQx.gif%3Fnoredirect&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=video%2Fmp4&amp;schema=imgur" width="480" height="264" frameborder="0" scrolling="no"><a href="https://medium.com/media/153712145836d99e105ed23b569485d5/href">https://medium.com/media/153712145836d99e105ed23b569485d5/href</a></iframe><h4>(Unit) Tests should only check one thing</h4><p>The rationale behind this is that, in case the test fails, it would be easy to find what part of the code is to blame. I think <strong>expressiveness on the test</strong> (and more specifically on its assertions) <strong>is what makes it easy to find the root cause of the problem</strong>. This statement is dangerous because it tends to raise the number of tests in your suite.</p><p>Furthermore, what is the scope of “<em>one thing</em>”? On its most radical form, the advocates of this statement usually say “<em>a test should have just one assertion</em>”. Now check these pieces of code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8768af1a521c3bc339556c5c51cb77a6/href">https://medium.com/media/8768af1a521c3bc339556c5c51cb77a6/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01e8b72b1a622aa7e2650dabd0b6c544/href">https://medium.com/media/01e8b72b1a622aa7e2650dabd0b6c544/href</a></iframe><p>I find the second approach more reasonable, and the paradox is that it stills holds one responsibility (check persistence over a tweet). You can follow the same abstraction path further until you find the proper balance; <strong>as the scope of your test widens, you lose precision but gain maintainability </strong><a href="https://blog.kentcdodds.com/write-tests-not-too-many-mostly-integration-5e8c7fff591c"><strong>and confidence</strong></a>. Remember that tests are also code, and <a href="https://blog.codinghorror.com/the-best-code-is-no-code-at-all/">universal rules still apply</a>.</p><h4>We should do TDD</h4><p><a href="https://dhh.dk/2014/tdd-is-dead-long-live-testing.html">No, we shouldn’t</a>.</p><h4>Tests are a means of documentation</h4><p>Yes, if done properly they can provide some insights; but this alone shouldn’t be a reason to do tests — it is just a nice side effect. Don’t expect tests to replace proper documentation.</p><h4>We cannot have Integration/System Tests without Unit Tests</h4><p>Out of all the excuses you can hear for skipping integration or system tests, the most prevalent is</p><blockquote>Well… we don’t have enough unit tests yet so… ¯\_(ツ)_/¯</blockquote><p>This way of thinking revolves around the concept of the <a href="https://martinfowler.com/bliki/TestPyramid.html">Test Pyramid</a>. Ahh, the almighty Test Pyramid… What a sticky bastard you are, especially hard to demystify.</p><p>The Pyramid is based on the assumption that unit tests are easier to build and faster to run, so you should do more of them. The later does no longer apply, things are fast now. And the first was never true; isolating a component to test only its code requires mocking, and mocking is hard (that’s why most of the self-called unit Tests end up going to a real database).</p><p>Advances in processing speed and virtualization are contributing to ease the path of integration/system tests, thus <strong>blurring the limits between the layers (types of tests) in the Pyramid</strong>. But, more importantly, even if you want to keep them, the layers are by no means sequential so don’t wait to complete a level before stepping up to the next one.</p><p>I think the pyramid is such a strong visual effect that we swallowed it up and missed the point. Deep inside, the core message should be instead: <strong>Write tests that increase the ROI</strong>, that is, that maximize the confidence and quality and minimize the costs of building and maintaining.</p><h4>Never test in production!</h4><p>This strongly depends on the nature of your product and the maturity of your process, but provided that you have:</p><ol><li>A solid Continuous Delivery process</li><li>A decent rollback strategy implanted</li><li>Real-time monitoring tools in place</li></ol><p>you can do it! I did it in the past with a system that had such wild requirements in terms of concurrent requests, load and response times that it was significantly simpler (and arguably cheaper) to deploy, fail and rollback than trying to reproduce those conditions on a test environment. Handled with care, it may actually be <a href="https://martinfowler.com/articles/qa-in-production.html">a good way to learn about your system</a>.</p><h3>Takeaways</h3><ul><li>In the era of microservices, we should pay more attention to testing integration between components (end-to-end)</li><li>In the era of Agile and continuous delivery, we should pay more attention to have <a href="https://martinfowler.com/articles/microservice-trade-offs.html">a strong deployment and monitoring solution</a> so we can perform more fail-fast-and-recover cycles</li><li>Test functionality, not modules. The deeper you dive to test your code, the harder it becomes to get it right and to maintain over time. Try to do as much <a href="https://en.wikipedia.org/wiki/Black-box_testing">Black-box testing</a> as you can, stepping away from the implementation details, since they are way more bound to change in the future</li><li>Minimize the tests, maximize the coverage</li><li>Use parameterized tests with datasets</li><li>Join related assertions</li></ul><p>And beyond everything else:</p><blockquote><strong>Don’t let fundamentalism take over your test plan, find the strategy that better suits your project’s needs</strong></blockquote><h3>Next challenges</h3><p>New challenges arise on the verge of new paradigms such as serverless computing and data science, both key components of <a href="https://lang.ai/">lang.ai</a>’s architecture. We are already implementing testing solutions with <a href="https://facebook.github.io/jest/">jest</a> and docker both on front-end and back-end, but we will soon need to expand our toolset and strategies to cover our ever-growing architecture.</p><p><em>Check the other articles in our </em><a href="http://building.lang.ai/"><em>Building Lang.ai</em></a><em> publication. We write about </em><a href="https://building.lang.ai/tagged/company-culture"><em>Machine Learning</em></a><em>, </em><a href="https://building.lang.ai/tagged/development"><em>Software Development</em></a><em>, and our </em><a href="https://building.lang.ai/tagged/company-culture"><em>Company Culture</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1348f0a10a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sentisis-engineering/undressing-old-testing-myths-c1348f0a10a7">Undressing old testing myths</a> was originally published in <a href="https://medium.com/sentisis-engineering">Building Lang.ai</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our journey from WebSockets to HTTP/2]]></title>
            <link>https://medium.com/sentisis-engineering/our-journey-from-websockets-to-http-2-4d069c54effd?source=rss-44981f6c52a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d069c54effd</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[http2]]></category>
            <dc:creator><![CDATA[Miguel Jiménez]]></dc:creator>
            <pubDate>Mon, 17 Jul 2017 06:31:02 GMT</pubDate>
            <atom:updated>2017-11-13T14:44:50.319Z</atom:updated>
            <content:encoded><![CDATA[<h4>A story of what we learned while migrating</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoBtJJ7JPFsQ8hvJHCyYmg.jpeg" /></figure><h3>HTTP/2: Hype is on</h3><p>The new HTTP protocol version landed with the promise to fix a bunch of HTTP/1.1 issues — a lot of <a href="https://http2.github.io/faq/">cool features</a>, all aimed to increase performance, perceived rendering time and providing an exit away from all those front-end optimization hacks out there like resource inlining, domain sharding…</p><p>In particular, we were interested in <strong>multiplexing</strong>. Our dashboard is made of a lot of components, each one issuing one or more requests at the same time; multiplexing makes it possible for several requests to coexist on a single TCP connection, thus reducing resources usage and response times.</p><p>So we decided to give it a try for our client’s dashboard here at <a href="https://sentisis.com/">Séntisis</a>. We are currently using Node.js and WebSockets(<a href="https://socket.io/">socket.io</a>). This was my impression when I first faced the problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*1IrjkTibKLZbACO_1_Y7gw.png" /><figcaption>Migration in my head</figcaption></figure><p>But then you notice that <a href="https://daniel.haxx.se/blog/2016/06/15/no-WebSockets-over-http2/">HTTP/2 does not support WebSockets</a> (ouch). Still, not that big of a deal, since we realized WebSockets is overkill for us (more on that later) and the plan is to move to a more RESTful API over pure HTTP.</p><h3>Push</h3><p>The problem then shifted to a different issue... One of the things we didn’t want to lose in the process was <strong>the ability for the server to send data to the client without the client actually asking for it</strong>. This may come in handy in these situations:</p><ul><li>Asking for a long-lasting process (generating a report for example) and waiting for it.</li><li>Real-time updates (news, monitoring tool…)</li><li>Chat application</li><li>Multiplayer online gaming</li></ul><p>The first two examples are the ones applying for us. So the question now turned into:</p><blockquote>How do we keep this Push feature on HTTP/2 (without WebSockets)?</blockquote><p>The answer was seemingly easy — we have the marvelous <a href="https://en.wikipedia.org/wiki/HTTP/2_Server_Push">Push on HTTP/2</a>! Piece of cake. And since WebSockets and HTTP/2 cannot live together, we just have to keep a double game on the server while the migration is on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*GgcJNUH8lifWT66AcLPOjA.png" /><figcaption>Migration in my head (v2)</figcaption></figure><p>Kind of cumbersome but no too hard… Done, right?</p><p>Not quite, there is just only one problem… HTTP/2 Push is not what we needed.</p><p>But let’s back up a little and review some of the Push technologies out there in order to make sense of the problems and available solutions. The following list of technologies is not intended to be exhaustive, there are <a href="https://en.wikipedia.org/wiki/Push_technology#HTTP_server_push">other options</a> out there and other ways to solve these problems like polling, long-polling… But these are the last contenders to enter the game and may be arguably the most used ones (at least on Node.js).</p><h3>WebSockets</h3><p>By far the most popular and adopted technology. Easy to use (especially on Node.js) as it has cool features including bi-directional communication.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e15b499e3f5763f81e29965f5e92576e/href">https://medium.com/media/e15b499e3f5763f81e29965f5e92576e/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a46d357d27e531da5d0c28aee735ccde/href">https://medium.com/media/a46d357d27e531da5d0c28aee735ccde/href</a></iframe><h4>Pros</h4><ul><li>Well documented, widely spread</li><li>Good performance and resource optimization</li><li>Bi-directional communication</li><li>Broadcast capabilities</li><li>One size fits all solution — it covers a wide range of problems (live streams, multi-client communication…) on one shot</li></ul><h4>Cons</h4><ul><li>Not standard HTTP</li><li>Overusing it may lead to bad practices</li><li>May be overkill for your application</li></ul><p>A word on these last points. At Séntisis we are using WebSockets for our dashboard which is a rather-usual web app; the decision was based on the fact we would need real-time updates, but the fact is we don’t need WebSockets for that — not even for the real-time stuff as we will see.</p><p>The lack of structure and semantics of an <em>Event</em> (the central concept of WebSockets) leads you naturally to drop the structure on your API — you end up throwing more and more stuff into that event, which keeps on getting fat, and suddenly your endpoints lose the notion of single responsibility (not to mention the notion of “resource” itself).</p><h3>HTTP/2 Push</h3><blockquote>Server Push allows you to send site assets to the user before they’ve even asked for them</blockquote><p>For example, if you request <em>index.html</em>, the server may decide that you are going to need <em>style.css</em> too, so it sends the file right away issuing a Push, saving round trips to the server. This <a href="https://www.smashingmagazine.com/2017/04/guide-http2-server-push/">Smashing Magazine article</a> explains the motivation, implementation and performance of HTTP/2 Push on high detail.</p><p>As good as HTTP/2 features are, it’s not exactly what we were looking for. It turns out Pushes <strong>are only processed by the browser and do not bubble up to your client code</strong>. Server Push’s motivations are just different and they aim to solve other (also important) problems.</p><ul><li>Suitable for resources, not features</li><li>Conversation starts on the client, server just listen and reacts to certain requests</li><li>Updates are kept on the browser cache — they do not reach your application code</li><li>It speeds up the flow and provides a way out of some historical dirty little hacks (inlining…)</li></ul><h3>Server Sent Events (SSE)</h3><p>The idea of Server Sent Events is to provide a standard way for you to open a connection and push data unilaterally from the server to the client. Let’s check an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/332146aac13379033b18aec1a92a1654/href">https://medium.com/media/332146aac13379033b18aec1a92a1654/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b02277086557923f257abbfca0d6dea4/href">https://medium.com/media/b02277086557923f257abbfca0d6dea4/href</a></iframe><p>There are of course a bunch of libraries that abstract the internals of the protocol, but I wanted this example to be deliberately low-level so that we can check how easy it is and how close to HTTP is tied up. Highlights:</p><ul><li>Notice how you turn everything to SSE on the server just by setting the header ‘<em>Content-Type: text/event-stream’</em>; this is pure HTTP. And again, on the client code, you are using the EventSource directly since it is already there for you — no libraries needed.</li><li>SSE uses a text-based format called <a href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format">event stream</a> but you can of course work with JSON.</li><li>The browser will try to reconnect automatically in case the connection is lost — no client code needed for that.</li><li>This protocol basically works for a single client; that means you don’t have the broadcast option for free. But again, you can build broadcast capabilities on top of it, and there are libraries out there that already support it.</li><li>This is not a bi-directional communication system, the server unilaterally pushes data to the client.</li><li>Connection is kept open and listens to new updates — neat stuff for real-time systems</li><li>And there is more <a href="https://www.html5rocks.com/en/tutorials/eventsource/basics/#toc-introduction-differences">extra stuff</a> (not in this example): here we are just picking every message that arrives, but you can send different events by specifying a name tag. You can also identify each pushed message by filling the id tag.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*kjfqcBqR2zHNLZRmn1gKOw.gif" /><figcaption>Chrome interprets text/event-stream and prints nicely</figcaption></figure><h4>Pros</h4><ul><li>Standard HTTP, no add-ons needed</li><li>Good performance</li><li>Easy to extend (broadcast…)</li><li>Automatic reconnection</li><li>Built-in Event names and ids support</li></ul><h4>Cons</h4><ul><li>Unilateral communication</li><li>Not supported on all browsers (IE) but you can use a polyfill</li></ul><h3>Coming back to the original problem</h3><p>So it turned out the solution has always been there. SSEs are a good fit for us, they allow us to move forward while keeping a healthy migration flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Mh9JP_iBRphkbpogfv_O9g.png" /></figure><p>As a plus, SSE can also benefit from HTTP/2 inherent strengths and improve its performance even more. In particular, multiplexing will allow bidirectional client/server communication since requests from client and SSE events could live together in the same TCP connection.</p><p>We still need to integrate it and check its limitations, but it feels right and easy so far.</p><h3>What if I still want to use WebSockets?</h3><p>You can either hold your breath and wait for <a href="https://tools.ietf.org/html/draft-hirano-httpbis-websocket-over-http2-01">WebSockets support on HTTP/2</a> or just <a href="https://www.infoq.com/articles/websocket-and-http2-coexist">stick with them</a> under HTTP/1.1. After all, we overcame almost all the problems HTTP/2 solves by pulling (clever) hacks over the years. Plus, most of the HTTP/2 features are targeted to improve the resource loading of your web, so you can greatly benefit from them if your resources and logic are separated.</p><p><strong>Just make sure you really need them</strong>.</p><h3>Conclusions</h3><ul><li>WebSockets are great, but abusing them may lower the quality of your code and architecture.</li><li>There are other ways to get the work done with simpler tools such as SSE.</li><li>HTTP/2 Push works at a browser level, not application level.</li><li>HTTP/2 does not provide a replacement for other push technologies such as WebSockets or SSE.</li></ul><h3>The next hype: GraphQL</h3><p><a href="http://graphql.org/">GraphQL</a> + <a href="https://www.apollodata.com/">Apollo</a> is the new stack we want to try. Some of GraphQL’s features like <a href="http://facebook.github.io/graphql/#sec-Subscription">subscription</a> looks promising and may help us with our real-time needs.</p><p>Since GraphQL is just a specification, it does not enforce any implementation details and (interestingly enough) subscriptions can be implemented both with <a href="https://www.npmjs.com/package/subscriptions-transport-sse">SSE</a> and <a href="https://github.com/apollographql/subscriptions-transport-ws">WebSockets</a>.</p><h4>Worth reading?</h4><p><em>Then it might be worth recommending. Give some claps to spread it! </em>👏</p><p><em>Check the other articles in our </em><a href="http://building.lang.ai/"><em>Building Lang.ai</em></a><em> publication. We write about </em><a href="https://building.sentisis.com/tagged/machine-learning"><em>Machine Learning</em></a><em>, </em><a href="https://building.sentisis.com/tagged/development"><em>Software Development</em></a><em>, and our </em><a href="https://building.sentisis.com/tagged/company-culture"><em>Company Culture</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d069c54effd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sentisis-engineering/our-journey-from-websockets-to-http-2-4d069c54effd">Our journey from WebSockets to HTTP/2</a> was originally published in <a href="https://medium.com/sentisis-engineering">Building Lang.ai</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>