tezvyn:

Shift-Left Resilience: Chaos in Your CI/CD Pipeline

AI-drafted, machine-checkedSource: developer.harness.ioadvanced

Think of it as an automated stress test in your build pipeline that breaks things on purpose. It runs alongside integration tests, injecting faults like pod failures to find weaknesses before a merge.

WHY IT EXISTS: Modern distributed systems fail in complex ways. Waiting for production outages to discover weaknesses is expensive and reactive. Integrating chaos experiments into the CI/CD pipeline allows teams to find and fix resilience issues proactively, just like they do with bugs and security vulnerabilities, before the code ever reaches production.

THE MENTAL MODEL: Think of your CI/CD pipeline as an assembly line for software. You have quality checks for bugs (unit tests) and performance (load tests). Automated chaos experiments add a new quality gate: a "shake table" test. Before a feature is shipped, the pipeline automatically puts it on the shake table, simulating real-world turbulence like network failures or resource exhaustion, to ensure it doesn't fall apart.

HOW IT WORKS: When a CI/CD pipeline runs, a chaos engineering tool is triggered, often after a successful deployment to a staging or testing environment. The tool injects a pre-defined, controlled fault from a library—for example, killing a Kubernetes pod or adding latency to a service. During the fault injection, "probes" continuously monitor the system's health and application-level SLOs. If the system remains stable and meets its objectives despite the chaos, the experiment passes. If it degrades unacceptably, the experiment fails, and the pipeline can be configured to block the promotion to production.

WHEN TO USE IT: Use this when you want to build confidence that your application can handle partial failures gracefully. It's ideal for microservices architectures where dependencies can fail. Integrate it into your CI/CD process to automatically verify the resilience of new features, test the effectiveness of your alerting, and ensure failover mechanisms work as expected before they are needed in a real incident.

WHEN NOT TO USE IT: Don't run chaos experiments in CI/CD without a stable, isolated test environment; you risk disrupting other developers and tests. Avoid it if your system lacks robust monitoring and observability ("probes"), as you won't be able to determine the impact or validate success. It's also premature if the team hasn't already embraced a culture of learning from failure.

ONE CANONICAL EXAMPLE: A development team builds a new checkout service. As part of their CI/CD pipeline, after deploying to staging, a chaos experiment automatically runs. It injects 200ms of latency into the dependency call to the payment processor. Simultaneously, a Gatling performance test simulates user traffic. A probe monitors the checkout service's success rate. If the rate drops below 99.5% during the latency injection, the experiment fails, the pipeline halts, and the build is marked as failed, preventing the fragile code from being promoted.

Read the original → developer.harness.io

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.