<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andre Sutherland</title>
    <description>The latest articles on DEV Community by Andre Sutherland (@fr3shw3b).</description>
    <link>https://dev.to/fr3shw3b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4274187%2F186904ff-e781-4ea4-9bca-0ff25de23f11.jpeg</url>
      <title>DEV Community: Andre Sutherland</title>
      <link>https://dev.to/fr3shw3b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fr3shw3b"/>
    <language>en</language>
    <item>
      <title>How to run your whole system locally and catch integration bugs</title>
      <dc:creator>Andre Sutherland</dc:creator>
      <pubDate>Mon, 30 Nov 2026 12:53:33 +0000</pubDate>
      <link>https://dev.to/fr3shw3b/how-to-run-your-whole-system-locally-and-catch-integration-bugs-1e01</link>
      <guid>https://dev.to/fr3shw3b/how-to-run-your-whole-system-locally-and-catch-integration-bugs-1e01</guid>
      <description>&lt;p&gt;When building software systems, there is a generally accepted idea that “it works locally” or&lt;br&gt;
“it works on my machine” is to be taken with a pinch of salt. That's fair: with lightweight local dev servers, mocks&lt;br&gt;
and unit test suites, it can be hard to trust what happens locally when it looks little like production,&lt;br&gt;
leaving the real verdict for QA or staging.&lt;/p&gt;

&lt;p&gt;Over the years, I've been wrestling with this idea, adamant that there is (to a certain extent) a way&lt;br&gt;
to catch a lot of these integration issues within minutes or even seconds of making changes locally.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why every service passes its tests and the system still breaks
&lt;/h2&gt;

&lt;p&gt;Often, the focus for quality can index too much on isolated test suites for a single component in a system.&lt;br&gt;
Whether it's unit tests for functions, component/API tests for an endpoint or a reactive task, or integration boundary&lt;br&gt;
tests, the focus is on how a piece of software interacts with a snapshot of the outside world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvzbqocemflrons4dfl4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvzbqocemflrons4dfl4f.png" alt="The same system of a web app, orders service, payments service, Postgres, a queue and object storage, drawn three times. Panel 1, one component isolated: the orders service under test against a stubbed payments service, a fake queue and a local Postgres container. Panel 2, the whole system on your machine: every component running together from source or images, with the payments service being changed and an AWS emulator standing in for object storage. Panel 3, end to end in a cloud environment: everything deployed or managed." width="800" height="1075"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's hard to put all your trust in the isolated tests because the snapshot of the&lt;br&gt;
outside world in panel 1 is what you believed about the other side when the test was written.&lt;br&gt;
When the other side changes, the snapshot is no longer a reliable source of truth about its shape or behaviour&lt;br&gt;
and the tests keep passing as if all is well.&lt;/p&gt;

&lt;p&gt;In addition to snapshots going stale, in an organisation where each team tests its own services, more often than not, nobody takes&lt;br&gt;
ownership of the space between them. This then pushes the discovery of integration issues to after changes have been deployed&lt;br&gt;
to QA or staging.&lt;/p&gt;

&lt;p&gt;In the diagram above, panel 2 is what brings forward the ability to test the real integration&lt;br&gt;
without waiting for a deployment and having to navigate the issues in a place where it is hard to debug.&lt;/p&gt;

&lt;p&gt;You might be thinking: can't we just write more automated tests that deal with the outside world like panel 3? After all, that's&lt;br&gt;
what customers will be dealing with when it ships. The answer is you can, but it comes at a cost: slower runs, flaky tests, environments that need maintenance and failures that are hard to trace.&lt;br&gt;
It's better to search for a balance of the two approaches rather than go all in on one or the other.&lt;/p&gt;

&lt;p&gt;The isolated suites act as a solid base for good software with cheap, reliable tests that can be repeated&lt;br&gt;
as often as needed. Then you can have the whole system running locally, dynamically responding to changes&lt;br&gt;
before they go anywhere near QA or staging — giving you or your coding agents an incredibly fast feedback loop.&lt;/p&gt;

&lt;p&gt;In practice, "the whole system" means the slice your change touches, those services and what they depend on.&lt;br&gt;
When your system consists of a handful of services (an API, frontend, a few event-driven jobs) then that&lt;br&gt;
can all comfortably run locally; if we're talking about a complex system with hundreds of microservices, you'd run&lt;br&gt;
a relevant subset and use stand-ins for everything else.&lt;/p&gt;

&lt;p&gt;QA, staging and cloud end-to-end tests still have an important role to play; we'll be exploring that further in &lt;a href="https://lo1.dev/blog/bugs-between-services/#what-local-cant-catch" rel="noopener noreferrer"&gt;What local can't catch&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The three issues we'll be touching on next are some that a stale snapshot hides and a local system catches:&lt;br&gt;
API drift, CORS and cookies between hosts, and features that need HTTPS.&lt;/p&gt;
&lt;h2&gt;
  
  
  API drift
&lt;/h2&gt;

&lt;p&gt;Picture a case where the payments team from the diagram above has changed &lt;code&gt;amount&lt;/code&gt; from&lt;br&gt;
a number in pounds to an object to support more currencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;12.5&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"GBP"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this particular instance, the orders team wasn't made aware that the shape of the amount field&lt;br&gt;
had changed, as it was buried in a bigger release on the payments side for changes to the payments processor.&lt;/p&gt;

&lt;p&gt;The orders team maintains a snapshot of the payments service in a stub of the following form:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stub&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"predicates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"equals"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/payments/pay_123"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"responses"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"is"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;12.5&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Example in the &lt;a href="https://www.mbtest.dev/docs/api/predicates" rel="noopener noreferrer"&gt;mountebank&lt;/a&gt; predicate format.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When the current suite of tests runs for the orders service, the tests pass as the stub continues&lt;br&gt;
to return the old response. The issue doesn't show up until the payments team releases the update along with&lt;br&gt;
the wider payments processor changes in the QA environment. Orders don't fail outright; they're saved with&lt;br&gt;
a total of &lt;code&gt;NaN&lt;/code&gt;, and the orders team needs to work with the payments team to debug what broke and correct the&lt;br&gt;
contract and the implementation in the orders service.&lt;/p&gt;

&lt;p&gt;With the system running locally (panel 2 in the diagram), the developer on the payments team making the change&lt;br&gt;
places an order and sees the broken total before the change is even merged. They find out in minutes on their&lt;br&gt;
local machine or in an agent sandbox, with both services' logs right in front of them to rapidly identify and&lt;br&gt;
address the issue.&lt;/p&gt;

&lt;p&gt;Automated schema checks and tools such as &lt;a href="https://docs.pact.io/" rel="noopener noreferrer"&gt;Pact&lt;/a&gt; can help a lot with automated testing&lt;br&gt;
of contracts. If the orders team had a pact for this interaction and the payments team verified it in CI,&lt;br&gt;
this exact change would have failed the payments build. Even with this kind of tooling, contracts only cover&lt;br&gt;
the interactions someone wrote down, and only when both teams have adopted the tooling and keep it up to date.&lt;/p&gt;
&lt;h2&gt;
  
  
  CORS and cookies between hosts
&lt;/h2&gt;

&lt;p&gt;When using &lt;code&gt;localhost&lt;/code&gt; for running the frontend locally, the API usually is on another port.&lt;br&gt;
For example, you could have &lt;code&gt;localhost:3000&lt;/code&gt; running the web app dev server and &lt;code&gt;localhost:4000&lt;/code&gt;&lt;br&gt;
for the API. These are different origins, but CORS rules still rarely get tested locally, as the dev server&lt;br&gt;
often proxies API requests so the browser sees them as same-origin, or the API allows any &lt;code&gt;localhost&lt;/code&gt; origin.&lt;br&gt;
Neither exercises rules that map to those in a deployed environment. An allowed origin of &lt;code&gt;["http://localhost:3000"]&lt;/code&gt; is less&lt;br&gt;
likely to catch CORS errors surfacing in staging than that of &lt;code&gt;["https://app.{env}.store.com"]&lt;/code&gt;, which maps across environments.&lt;/p&gt;

&lt;p&gt;Related cookie-based bugs can also hide on localhost. Ports are not considered for SameSite cookies:&lt;br&gt;
&lt;code&gt;localhost:3000&lt;/code&gt; and &lt;code&gt;localhost:4000&lt;/code&gt; are the same site. Secure cookies also work over plain HTTP on&lt;br&gt;
localhost, when they'd be rejected on any other HTTP host. A cookie domain&lt;br&gt;
such as &lt;code&gt;.store.com&lt;/code&gt; can't be tested on &lt;code&gt;localhost&lt;/code&gt;, so cookies shared across subdomains aren't tested until staging.&lt;/p&gt;

&lt;p&gt;What catches this in a local setup is having each service on its own hostname, over HTTPS, as it is in production.&lt;/p&gt;
&lt;h2&gt;
  
  
  The need for HTTPS
&lt;/h2&gt;

&lt;p&gt;It's worth saying up front that Chrome and Firefox treat &lt;code&gt;localhost&lt;/code&gt; as a secure context, so service workers,&lt;br&gt;
secure cookies and APIs like &lt;code&gt;crypto.subtle&lt;/code&gt; all work over plain HTTP there. That's handy for a quick&lt;br&gt;
dev server, but it also means a whole class of issues stays hidden until the app is on a real hostname.&lt;br&gt;
Once each service has its own hostname such as &lt;code&gt;api.local.store.com&lt;/code&gt;, as in the previous section, or you open the app on a phone over&lt;br&gt;
your local network, plain HTTP is no longer a secure context and the browser starts behaving the way it&lt;br&gt;
does in production.&lt;/p&gt;

&lt;p&gt;This was something I learnt the hard way, going through a gruelling process of&lt;br&gt;
getting file uploads to mirror a deployed environment locally along with subdomain-scoped PWAs in a recent project.&lt;/p&gt;
&lt;h3&gt;
  
  
  Uploads straight to object storage
&lt;/h3&gt;

&lt;p&gt;Picture a case where the web app lets customers upload photos with &lt;a href="https://uppy.io/" rel="noopener noreferrer"&gt;Uppy&lt;/a&gt;, straight&lt;br&gt;
from the browser to an S3 bucket. The web app asks a backend service for a signed URL, then sends the&lt;br&gt;
file to the bucket itself, so three parts of the system have to agree with each other: the frontend,&lt;br&gt;
the backend that signs the URL and the storage service. Locally, uploads tend to be tested against a mock&lt;br&gt;
or a bucket that allows everything, and there are a few things that don't show up until staging.&lt;/p&gt;

&lt;p&gt;The first is the bucket's CORS rules. The upload is a cross-origin request from the web app to the bucket,&lt;br&gt;
so the bucket needs to allow the web app's origin and the methods Uppy uses. For multipart uploads, Uppy&lt;br&gt;
also needs to read the &lt;code&gt;ETag&lt;/code&gt; header from the response for each part, and the browser hides it unless the&lt;br&gt;
bucket exposes it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bucket CORS rules&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"CORSRules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"AllowedOrigins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"https://app.store.com"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"AllowedMethods"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"AllowedHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ExposeHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ETag"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you leave out &lt;code&gt;ExposeHeaders&lt;/code&gt;, the parts upload fine, but Uppy can't read their &lt;code&gt;ETag&lt;/code&gt;s and the upload&lt;br&gt;
fails with an error pointing at the bucket's CORS configuration.&lt;/p&gt;

&lt;p&gt;The second is the host in the signed URL. The signature covers the host the URL was signed for, so when the&lt;br&gt;
backend runs in Docker and talks to a local S3 such as LocalStack at &lt;code&gt;http://localstack:4566&lt;/code&gt;, it hands the&lt;br&gt;
browser a URL for a hostname the browser can't reach. Rewriting the host afterwards breaks the signature, and&lt;br&gt;
S3 rejects the request with &lt;code&gt;SignatureDoesNotMatch&lt;/code&gt;. The same goes for headers the URL was signed with. If the&lt;br&gt;
backend signs for a specific &lt;code&gt;Content-Type&lt;/code&gt; and the browser sends a different one, the upload is rejected.&lt;/p&gt;

&lt;p&gt;The third is mixed content. Once the web app is on HTTPS, every request it makes has to be HTTPS too, and an&lt;br&gt;
upload to a storage endpoint on plain HTTP is blocked by the browser. A setup on &lt;code&gt;localhost&lt;/code&gt; won't tell you&lt;br&gt;
this, as Chrome and Firefox allow requests to &lt;code&gt;http://localhost&lt;/code&gt; from a secure page.&lt;/p&gt;

&lt;p&gt;What catches all three locally is the web app, the backend and a local S3 such as LocalStack, each on a real&lt;br&gt;
hostname over HTTPS, with the bucket configured as it is in production. LocalStack doesn't check the signatures of signed URLs by&lt;br&gt;
default, so set &lt;code&gt;S3_SKIP_SIGNATURE_VALIDATION=0&lt;/code&gt; to have it check them as S3 does. An upload on your machine then goes&lt;br&gt;
through the same CORS checks, signed URLs and mixed content rules as it would in staging.&lt;/p&gt;
&lt;h3&gt;
  
  
  Service workers
&lt;/h3&gt;

&lt;p&gt;Service workers need a secure context to register, and each one is scoped to a single origin. Because&lt;br&gt;
&lt;code&gt;localhost&lt;/code&gt; counts as secure, it's easy to build an offline mode or push notifications on your machine and never see registration fail. Open the same app on a&lt;br&gt;
phone over your local network at &lt;code&gt;http://192.168.1.20:3000&lt;/code&gt; and &lt;code&gt;navigator.serviceWorker&lt;/code&gt; is undefined. Put it&lt;br&gt;
behind HTTPS with a certificate the browser doesn't trust and registration still fails, even after clicking&lt;br&gt;
through the warning. HTTPS on its own isn't enough: the certificate has to be trusted by the device.&lt;/p&gt;

&lt;p&gt;The origin scope is what pushed me to a fuller local setup. The PWAs were scoped to each tenant's subdomain,&lt;br&gt;
such as &lt;code&gt;acme.store.com&lt;/code&gt; and &lt;code&gt;globex.store.com&lt;/code&gt;, so each tenant got its own service worker, caches and install.&lt;br&gt;
An app on &lt;code&gt;localhost:3000&lt;/code&gt; can only ever be one origin, so testing across tenants meant setting up hosts file&lt;br&gt;
entries for each tenant's subdomain and full HTTPS with a certificate the browser trusts, giving me the same&lt;br&gt;
origins locally as in production. Chrome and Firefox resolve names like &lt;code&gt;acme.localhost&lt;/code&gt;, which gets part of the&lt;br&gt;
way there, but they don't match the domains the app expects in production and they don't work on a phone.&lt;/p&gt;

&lt;p&gt;Like the CORS and cookie issues, what catches these locally is each service on its own hostname, over HTTPS,&lt;br&gt;
with a certificate your browser and devices trust.&lt;/p&gt;
&lt;h2&gt;
  
  
  What running the whole system locally takes
&lt;/h2&gt;

&lt;p&gt;To catch the issues above before they get to QA or staging, a local setup needs more than a couple of dev&lt;br&gt;
servers and a database container. Whichever tools you use, it comes down to the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real infrastructure, such as the database, message broker and caches, running in containers or emulators.&lt;/li&gt;
&lt;li&gt;Services that find each other by URL, configured the same way they are in production rather than through
special cases for local.&lt;/li&gt;
&lt;li&gt;Real hostnames and HTTPS with a trusted certificate, for the CORS and cookie issues, uploads and
service workers.&lt;/li&gt;
&lt;li&gt;Local stand-ins for the cloud services that can't run on your machine, such as an AWS emulator like LocalStack for S3.&lt;/li&gt;
&lt;li&gt;Everything started in the right order, with migrations and seed data, so the system is usable as soon as
it comes up.&lt;/li&gt;
&lt;li&gt;The service you're changing running from source with hot reload, and everything else from images.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a few common ways to get there, each with its trade-offs.&lt;/p&gt;

&lt;p&gt;Docker Compose for everything is the simplest place to start, and most teams already have a compose file&lt;br&gt;
for their infrastructure. Compose Watch syncs source changes into the container for the service you're&lt;br&gt;
changing, but a dependency change means a rebuild and the container setup has to support hot reload, and&lt;br&gt;
hostnames and HTTPS are left for you to set up with a proxy and certificates of your own.&lt;/p&gt;

&lt;p&gt;Tools such as &lt;a href="https://tilt.dev/" rel="noopener noreferrer"&gt;Tilt&lt;/a&gt; and &lt;a href="https://skaffold.dev/" rel="noopener noreferrer"&gt;Skaffold&lt;/a&gt; are powerful and handle&lt;br&gt;
rebuilding and redeploying as you make changes. They're built mainly around Kubernetes, though both can also&lt;br&gt;
run plain Docker or a compose file. If production runs on Kubernetes, a local cluster gets you close to it,&lt;br&gt;
but if it doesn't, much of what they offer goes unused. For systems too big to run on one machine, tools like &lt;a href="https://telepresence.io/" rel="noopener noreferrer"&gt;Telepresence&lt;/a&gt;&lt;br&gt;
and &lt;a href="https://metalbear.com/mirrord/" rel="noopener noreferrer"&gt;mirrord&lt;/a&gt; take a different approach, connecting the service on your machine to the&lt;br&gt;
rest of the system in a shared cluster.&lt;/p&gt;

&lt;p&gt;Then there are scripts and a README, which is probably the most common setup of all. They work for whoever&lt;br&gt;
wrote them, and they drift as the system changes, until starting the system locally becomes a half-day job&lt;br&gt;
for anyone joining the team.&lt;/p&gt;
&lt;h2&gt;
  
  
  Where lo1 fits
&lt;/h2&gt;

&lt;p&gt;After years of piecing together my own versions of the setup above for different projects, with compose&lt;br&gt;
files, scripts and a proxy configured by hand, I built &lt;a href="https://lo1.dev/docs" rel="noopener noreferrer"&gt;lo1&lt;/a&gt; to do it from a single &lt;code&gt;lo1.yaml&lt;/code&gt;.&lt;br&gt;
It's open source and runs on macOS, Linux and Windows.&lt;/p&gt;

&lt;p&gt;lo1 starts your infrastructure from an ordinary Docker Compose file, runs init tasks such as migrations and&lt;br&gt;
seed data, then starts each service in dependency order. Each service runs in dev mode with its own command,&lt;br&gt;
so your usual dev server and hot reload keep working, or in a container from an image. A Caddy proxy in front&lt;br&gt;
gives every service with a port its own hostname, over HTTPS if you turn it on. By default the certificate is&lt;br&gt;
trusted by your machine only, and for phones and other devices on your network, &lt;a href="https://lo1.dev/docs/proxy-and-tls#acme" rel="noopener noreferrer"&gt;ACME mode&lt;/a&gt;&lt;br&gt;
gets a certificate from a public CA such as Let's Encrypt instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;lo1.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;shop&lt;/span&gt;

&lt;span class="c1"&gt;# Postgres and anything else the services need, as an ordinary compose file.
&lt;/span&gt;&lt;span class="na"&gt;extraCompose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./infra.compose.yaml&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# The migrate and seed init tasks and env are left out here.
&lt;/span&gt;  &lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;service&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./api&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4100&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node src/server.js&lt;/span&gt;
    &lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost:4100/health&lt;/span&gt;
    &lt;span class="na"&gt;dependsOn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./web&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4200&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node src/server.js&lt;/span&gt;
    &lt;span class="na"&gt;dependsOn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;api&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;proxy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;tld&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;local&lt;/span&gt;
  &lt;span class="na"&gt;tls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For bigger systems, you don't have to run all of it.&lt;br&gt;
&lt;code&gt;lo1 up --services api,web&lt;/code&gt; starts the services you name plus everything they depend on, and setting&lt;br&gt;
&lt;a href="https://lo1.dev/docs/configuration#modes" rel="noopener noreferrer"&gt;&lt;code&gt;mode: skip&lt;/code&gt;&lt;/a&gt; on a service leaves it out entirely, so you run the slice you're&lt;br&gt;
working on and lo1 works out the rest. &lt;code&gt;lo1 up --detach&lt;/code&gt; returns once everything is ready, or exits non-zero if something fails to start,&lt;br&gt;
which also makes it a good fit for &lt;a href="https://lo1.dev/docs/coding-agents" rel="noopener noreferrer"&gt;coding agents&lt;/a&gt; testing their changes against the real system.&lt;/p&gt;

&lt;p&gt;Here's what a run looks like with the shop example from the &lt;a href="https://lo1.dev/docs/quick-start" rel="noopener noreferrer"&gt;quick start&lt;/a&gt;: a web app,&lt;br&gt;
an API and Postgres with a migration and seed data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ lo1 up
[lo1] Starting infrastructure
[lo1] Starting services
[lo1] migrate: completed
[lo1] seed: completed
[lo1] api: started
[lo1] web: started
[lo1] Ready

  Workspace shop is ready in 3.7s
    infrastructure 2.4s · services 1.3s

  Services:
    api  https://api.shop.local
    web  https://web.shop.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What local can't catch
&lt;/h2&gt;

&lt;p&gt;Running the whole system locally doesn't replace QA, staging or end-to-end tests in a cloud environment,&lt;br&gt;
and it's worth being clear about where it stops.&lt;/p&gt;

&lt;p&gt;The first is load and the network. Everything on your machine talks over loopback with next to no latency,&lt;br&gt;
and nothing else is competing for the database. Timeouts, retries, connection pool limits and what happens&lt;br&gt;
when a service is slow or unreachable for a few seconds don't show up until there's a real network and real&lt;br&gt;
traffic in between.&lt;/p&gt;

&lt;p&gt;Then there's the cloud itself. An emulator like LocalStack gets you the APIs, but by default it doesn't&lt;br&gt;
enforce IAM, so a role missing a permission works fine locally and fails in staging. The same goes for&lt;br&gt;
service limits, quotas and the quirks of managed services that an emulator either doesn't reproduce or&lt;br&gt;
can't keep up with.&lt;/p&gt;

&lt;p&gt;Data is another one. A query that's quick against a few hundred seeded rows can fall over against millions,&lt;br&gt;
and seed data rarely has the odd shapes production data picks up over the years, the missing fields, the&lt;br&gt;
legacy formats and the edge cases nobody remembers adding.&lt;/p&gt;

&lt;p&gt;Finally, there's the size of the system. With hundreds of services, you run the slice around your change on your&lt;br&gt;
machine, and the interactions beyond that slice still need to be found further along.&lt;/p&gt;

&lt;p&gt;Staging still has an important job to do; it just shouldn't be where you first find out that two services&lt;br&gt;
disagree.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Bugs often live between services, so testing the system where it runs together gives you the best&lt;br&gt;
chance of catching them, and doing so locally allows you to rapidly find and address them as you&lt;br&gt;
make changes.&lt;/p&gt;

&lt;p&gt;Are there any bugs discovered in QA or staging that you wish you'd caught earlier? I'd love to hear about&lt;br&gt;
them in &lt;a href="https://github.com/newstack-cloud/lo1/discussions/38" rel="noopener noreferrer"&gt;GitHub Discussions&lt;/a&gt; or leave a comment here.&lt;/p&gt;

&lt;p&gt;If your setup needs something lo1 doesn't do yet, &lt;a href="https://github.com/newstack-cloud/lo1/issues" rel="noopener noreferrer"&gt;open an issue&lt;/a&gt;&lt;br&gt;
and let me know.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://lo1.dev/blog/bugs-between-services/" rel="noopener noreferrer"&gt;lo1.dev&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>testing</category>
      <category>microservices</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
