Software Testing
Chaos Engineering for QA
This course teaches quality assurance professionals how to bring chaos engineering practices into their testing strategy. Rather than only checking that an application behaves correctly under ideal conditions, you will learn to deliberately inject failures such as slow networks, dropped connections, and unavailable dependencies, then observe how the system and its users cope. The course covers the core vocabulary of chaos engineering (steady state, hypothesis, blast radius), the tools testers can use to simulate faults in a browser or at the network layer, how to design safe and well scoped experiments, how to read logs and metrics to judge the outcome, and how to fold chaos experiments into everyday QA work and CI/CD pipelines without putting real users at risk. By the end, you will be able to plan, run, and report on a resilience experiment with the same rigor you apply to a functional test case.
Intermediate · By the Xtest team · About 35 minutes to read
Introduction
Most test suites are built to prove that an application works when everything around it behaves. The database answers quickly, the payment gateway responds, the network never drops a packet. In the real world none of that holds for long, and the moment a dependency slows down or a request fails, many applications fall over in ways nobody planned for or tested. Chaos engineering is the discipline of finding those weaknesses on your own terms, before a real outage finds them for you, by deliberately introducing failure into a system and watching how it responds. For a long time this was treated as an operations concern, something done to production infrastructure by reliability engineers. This course makes the case that QA has a natural seat at that table: testers already know how to design an experiment, define a pass and fail condition, and document what happened, and those are exactly the skills chaos engineering needs. You will learn the vocabulary of the field, the kinds of faults worth injecting (network failures, slow responses, unavailable services, resource exhaustion), the tools available to simulate them at the browser and network level, and how to keep an experiment small, observable, and reversible so it teaches you something without creating a real incident. The course closes by looking at how resilience experiments fit alongside your regular functional and regression testing, including in a continuous integration pipeline.
Foundations of Chaos Engineering for QA
What Chaos Engineering Is
Chaos engineering is the practice of running controlled experiments on a system to learn how it behaves under turbulent conditions such as network failure, slow dependencies, or unexpected load, rather than waiting to find out during a real outage. It is not random breakage for its own sake. Every experiment starts from a question: if this fails, what happens to the user, and does the system recover gracefully?
Why QA Should Own Part of This
Traditional QA proves that a feature behaves correctly when its dependencies behave correctly. Chaos engineering asks the next question: what happens when a dependency stops behaving? A checkout flow that works perfectly against a fast, always-available payment API may show the user a blank screen, a duplicate charge, or a stuck spinner the moment that API is slow or returns an error. Finding that gap is squarely a quality question, and testers already have the mindset for it: define an expected result, set up a controlled scenario, observe, record evidence, and report a finding with severity and reproduction steps.
The Vocabulary You Need
- Steady state: a measurable sign that the system is healthy, such as a page loading, an order completing, or an error rate staying below a threshold.
- Hypothesis: a specific, falsifiable prediction, for example "if the recommendations service returns errors, the product page will still load and simply hide the recommendations block."
- Blast radius: how much of the system, traffic, or users an experiment can affect. A good experiment starts with the smallest blast radius that can still answer the question.
- Fault injection: the mechanism used to introduce the failure, whether that is aborting a network request, adding latency, or stopping a service.
- Rollback: the plan for stopping the experiment and restoring normal behavior the moment something goes wrong or the experiment is over.
How This Differs From Exploratory Bug Hunting
Exploratory testing looks for defects nobody specifically planned for by trying unusual paths through an application as it stands. Chaos engineering instead changes the environment around the application, holding the user's actions constant while the dependency, network, or infrastructure misbehaves. The two complement each other well: exploratory work finds the unexpected path, chaos experiments find the unexpected failure.
Steady State and Hypothesis-Driven Testing
Before you break anything, you need a clear and measurable definition of what 'working' looks like. This is the steady state: a concrete signal you can check before, during, and after an experiment, such as 'the checkout page returns a 200 status and shows the order confirmation text' or 'the error rate in the browser console stays at zero'. Vague goals like 'the app should be fine' cannot be verified, so the first job in any chaos experiment is turning a feeling into a measurement.
Once steady state is defined, write the hypothesis as a single sentence that could turn out to be wrong: 'If the inventory service times out, the product page will show a cached price and an "availability unknown" label instead of crashing.' A good hypothesis names the fault, the component affected, and the expected behavior, so that when you run the experiment there is no ambiguity about whether it passed or failed. This is the same discipline used in writing a clear test case: one action, one expected outcome, written down before you run anything. Treat a hypothesis that turns out false exactly like a failed test case: log it, attach the evidence, and route it to the team that owns that part of the system. Over time, a library of hypotheses about your most critical user journeys becomes a map of the resilience gaps worth fixing first, and a record of the ones you have already proven sound.
Blast Radius and Experiment Safety
Blast radius is the boundary of what an experiment is allowed to touch: one browser tab, one test account, one API route, one percentage of traffic, or an entire environment. The rule of thumb is to start with the smallest blast radius that can still answer your hypothesis, and only widen it once you understand how the system responds. Injecting a fault against your own test session in a staging environment proves far less can go wrong than injecting the same fault against a slice of real production traffic, and QA should almost always start at the smaller end.
Safety in a chaos experiment comes from three things: a steady state you are actively watching, a rollback you can trigger instantly, and a stop condition agreed before you start, such as 'end the experiment if error rate crosses 5 percent' or 'end it after five minutes regardless of outcome'. Document the environment, the account, and the exact fault before running anything, so the experiment can be repeated or explained later. Never run a first chaos experiment against production without a tested rollback and without the people who own that system aware it is happening; the goal is a controlled, boring surprise, not an actual incident. As confidence grows, the blast radius can expand gradually, the same way a test suite grows from a single smoke test to full regression coverage.
const { test, expect } = require('@playwright/test');
test('checkout page stays usable when the payment API fails', async ({ page }) => {
// Fault injection: force every call to the payment API to fail
await page.route('**/api/payment/**', (route) => {
route.fulfill({
status: 500,
contentType: 'application/json',
body: JSON.stringify({ error: 'simulated outage' }),
});
});
await page.goto('https://example-shop.test/checkout');
await page.click('text=Pay now');
// Hypothesis: the user sees a clear retry message instead of a blank screen
await expect(page.locator('text=Payment is unavailable, please try again')).toBeVisible();
await expect(page.locator('text=Pay now')).toBeEnabled();
});
A Playwright test that defines a steady state (a usable checkout page), injects a fault by forcing the payment API route to return a 500 error, and checks the hypothesis that the page degrades gracefully instead of breaking.
# Add 400ms of latency and 2% packet loss to all outbound traffic on eth0
sudo tc qdisc add dev eth0 root netem delay 400ms loss 2%
# Run your test suite or exploratory session here while the fault is active
# Always remove the fault when the experiment is over
sudo tc qdisc del dev eth0 root netem
Using the Linux tc (traffic control) tool with the netem module to simulate a slow, lossy network on a test machine, then removing the fault once the experiment is finished.
Tips
- Write the steady state and the hypothesis down before touching anything; if you cannot state what 'working' means, you are not ready to run the experiment.
- Always have a rollback ready and tested before you inject a fault, and set a stop condition you will honor no matter how interesting the results look.
- Start every new type of experiment in a staging or test environment with a small blast radius, and only widen it once the first few runs behave as expected.
Common pitfalls
- Injecting a fault with no clear steady state to compare against: without a 'before' measurement, you cannot tell whether the system actually degraded or was already behaving that way. Define and verify steady state first.
- Running a chaos experiment against production with no one watching and no rollback plan, turning a learning exercise into a real outage. Keep the first experiments small, observed, and reversible.
- Treating a failed hypothesis as a surprise rather than a finding: log it with evidence and severity just like any other defect, instead of only mentioning it in conversation.
Designing Chaos Experiments
A chaos experiment is not just 'break something and see what happens.' It is a scientific method applied to system resilience: you state what you believe is true about your system's behavior under stress, then you deliberately try to prove yourself wrong. Good experiment design turns a vague worry ('what if the payment service is slow?') into something a teammate could execute from a written plan without you ever explaining it out loud.
The design process has four parts. First, you pick a critical user journey, the path a real user takes that the business cannot afford to break, such as checkout, login or search. Second, you turn that journey into a falsifiable hypothesis: a specific, measurable claim about what should still work when a specific dependency misbehaves. Third, you choose the smallest blast radius that can test the hypothesis, usually one dependency, one component or one network path, not the whole system at once. Fourth, you decide in advance which metrics will tell you, objectively, whether the system passed or failed, so nobody is arguing about the result after the fault has already been injected and reverted.
A written experiment plan should include: the hypothesis, the steady-state metrics and their normal ranges, the exact fault to inject and for how long, the blast radius and how to contain it, the rollback procedure, and the person or on-call rotation responsible for aborting the experiment if things go worse than expected. Treat the plan as a runbook, not a memo: a teammate with no context should be able to follow it start to finish.
This same discipline applies to testing how a web application copes with a failing request. A test agent in xtest can make one of the site's own requests fail with a 500, fail as offline, slow down or hang, which lets you exercise exactly the kind of dependency-failure hypothesis described above directly against a live page.
From Critical Journey to Falsifiable Hypothesis
Start by listing the two or three journeys that, if broken, would generate support tickets or lost revenue within minutes: completing a purchase, signing in, loading a dashboard. For each one, write a hypothesis in the form: 'When [dependency] experiences [failure mode], users can still [critical action], possibly with [acceptable degradation].' For example: 'When the recommendations service times out, the product page still loads and the user can still add an item to the cart, within 3 seconds.'
A hypothesis must be falsifiable: it needs a clear pass/fail line, not a hope. Avoid hypotheses like 'the system should handle it gracefully,' because 'gracefully' cannot be measured. Instead specify the exact failure mode (timeout, 500 response, connection refused, elevated latency), the exact scope (one service, one region, one percentage of traffic) and the exact user-facing outcome you will check.
Writing the hypothesis before touching anything forces a useful conversation: does the team actually know what should happen, or is everyone guessing? If nobody can state the expected behavior, that is itself a finding, and it usually means the fallback logic was never built or never tested. Keep hypotheses narrow. One experiment should test one failure mode against one journey; a sprawling hypothesis that tries to cover five dependencies at once produces a result nobody can act on, because you cannot tell which failure caused which symptom.
Choosing a Target, Metrics and a Runnable Plan
Choose your first target by impact and reversibility, not by curiosity. A good first target is a dependency that is known to be flaky, sits behind a documented fallback, and can be faulted and restored quickly and safely, such as a single downstream API, a cache, or one network path. Avoid starting with anything that touches payments, data writes, or irreversible side effects until the team has run several lower-risk experiments successfully.
Metrics must be agreed before the fault is injected. Split them into steady-state metrics (error rate, latency percentiles, successful completions of the critical journey) and abort conditions (a hard ceiling that triggers an immediate rollback, such as error rate above a fixed threshold or any data loss). Pick metrics you can already observe; do not invent a new dashboard mid-experiment.
The written plan itself should read like a checklist: hypothesis, steady-state baseline captured beforehand, the fault to inject with exact parameters, the blast radius, the abort condition and who can pull the trigger, the expected duration, and the rollback steps. Store it somewhere the whole team can find it, and review it with at least one other engineer before running it, especially the first time. A plan that only lives in one person's head is not a plan, it is a performance, and it will not survive that person being on vacation when the next experiment is due.
const { test, expect } = require('@playwright/test');
test('checkout survives recommendations service timeout', async ({ page }) => {
// Hypothesis: when /api/recommendations times out,
// the product page still loads and checkout still works.
await page.route('**/api/recommendations**', async (route) => {
// Simulate a hang/timeout instead of fulfilling the request
await new Promise((resolve) => setTimeout(resolve, 15000));
route.abort('timedout');
});
await page.goto('https://example.com/product/42');
await expect(page.getByTestId('add-to-cart')).toBeVisible({ timeout: 5000 });
await page.getByTestId('add-to-cart').click();
await page.getByTestId('checkout-button').click();
await expect(page.getByText('Order confirmed')).toBeVisible();
});
A Playwright test that intercepts the recommendations API and forces it to hang, then checks that the product page still renders and checkout still completes, turning the hypothesis directly into an automated pass/fail check.
# Add 500ms of latency and 10% packet loss on a given network interface
# to rehearse the 'slow dependency' part of an experiment plan
sudo tc qdisc add dev eth0 root netem delay 500ms loss 10%
# ... run the experiment and capture metrics here ...
# Always include the rollback step in the written plan
sudo tc qdisc del dev eth0 root netem
Using the Linux tc/netem tool to inject network latency and packet loss for a controlled chaos experiment, with the rollback command included as part of the plan rather than left to memory.
Tips
- Capture a steady-state baseline for every metric before injecting any fault, so 'normal' is a number and not a feeling.
- Run the first few experiments in a staging environment with production-like traffic patterns before ever touching production.
- Write the abort condition and the name of the person who can invoke it directly into the plan, not just the happy path.
- Keep each experiment to one dependency and one failure mode so the result is unambiguous.
Common pitfalls
- Writing a hypothesis that cannot fail ('the system should degrade gracefully') instead of a measurable one with a clear pass/fail line; fix this by naming the exact failure mode and the exact expected user outcome.
- Starting with a high-blast-radius target like a payments or data-write path before the team has practiced on safer, reversible dependencies; fix this by sequencing experiments from low risk to high risk.
- Leaving the rollback and abort steps out of the written plan, so an experiment that goes wrong depends on someone remembering how to undo it under pressure; always write the rollback command or procedure into the plan itself.
Fault Injection Techniques and Tools
Chaos engineering for QA means deliberately breaking things in a controlled way, then watching whether the application degrades gracefully or falls over. Fault injection is the practical toolkit for doing that: making a request fail, slowing a dependency down, killing a process, or cutting a network link, all while a human or an automated check watches the result. The right technique depends on the layer you want to test.
At the browser layer, you intercept requests before they reach the network and decide what happens to them: abort, delay, or return a bad status. At the service layer, you kill or restart a process or container to see if the system recovers or if state is lost. At the network layer, you simulate the kind of conditions real users hit: packet loss, latency, jitter, or a dropped connection. Each layer answers a different question, so a thorough chaos test plan usually combines more than one.
A good fault injection exercise starts small: one request failing, one container restarting, one network link degraded. Only after the simple case is handled correctly should you combine faults, because a system that survives one failure can still fail badly when two happen together. Always pair fault injection with an assertion: a test that injects a fault but never checks the application's response has not tested anything, it has just caused an outage.
The sections below cover browser and network-level tools, service and infrastructure-level tools, and how an AI test agent can inject a fault as part of an exploratory or system run without any scripting at all.
Browser and Network-Level Fault Injection
The cheapest and most precise place to inject a fault is right in the browser, before a request leaves the page. Playwright's route interception lets you abort a specific request, return a custom status code, or delay the response by any amount, all without touching the server. This is ideal for testing how a single page handles a failed API call, a slow image, or a dropped analytics beacon, and it runs entirely inside your existing test suite.
When you need to simulate conditions below the browser, a proxy such as Toxiproxy sits between your client and a real dependency and can add latency, cut the connection, or limit bandwidth for any traffic passing through it, which is useful for testing a backend service's resilience rather than just a page's. At the operating system level, tc combined with netem can shape or corrupt traffic on a network interface, simulating packet loss, delay, or reordering, which is closer to what a user on a poor mobile connection actually experiences.
A common pitfall here is forgetting to remove the fault after the test. A Playwright route that is never unrouted, or a tc qdisc rule left on an interface, will quietly break every test that runs after it. Always inject a fault with a matching cleanup step, ideally in a finally block or an after-each hook, so one flaky test does not poison the rest of the suite.
Service and Infrastructure-Level Fault Injection
Some failures only show up when a whole process disappears, not just one request. Docker makes this straightforward in a local or CI environment: stopping, killing, or restarting a container mid-test shows whether the application reconnects cleanly, whether in-flight work is lost, and whether a load balancer or retry policy routes around the gap. This is a good way to test things like database failover, queue consumer restarts, or a cache going cold.
For broader infrastructure experiments, dedicated chaos tools such as Chaos Monkey and Litmus Chaos can terminate instances or pods on a schedule or on demand, across a whole environment rather than one container at a time. These tools are typically run against a staging environment rather than production until the team has confidence in how the application responds, and results should always be tied back to a specific hypothesis, such as 'the checkout service should queue orders if the payment service is unreachable for 30 seconds.'
A frequent mistake at this layer is testing infrastructure resilience without also checking data integrity. A service that restarts and appears healthy again has not necessarily preserved every in-flight transaction, so a thorough chaos test checks not just that the service comes back, but that nothing was silently lost or duplicated while it was down.
Fault Injection with an AI Test Agent
Scripted fault injection is powerful but requires someone to write and maintain the code. In xtest, a test agent can make one of the site's own requests fail with a 500, fail as offline, slow it down, or make it hang, to see how the app copes, all described in plain English rather than written as a script. On an Android emulator the equivalent action takes the whole emulator offline instead, and an iPhone simulator has no such tool yet, so the technique is currently strongest on web and Android.
This is useful during an exploratory or system run, where the test agent can try failing a request it notices on the page and then continue the journey to see whether the application shows an error, retries, or gets stuck, without a human having to predict which request to target in advance. Because it happens inside a live run, the resulting screenshot and console output are captured alongside the fault, which is useful evidence when writing up what actually happened. As with scripted approaches, the value of this technique comes from pairing the injected fault with a clear expectation of correct behaviour, not from the fault itself.
const { test, expect } = require('@playwright/test');
test('checkout shows a friendly error when the payment API fails', async ({ page }) => {
// Intercept the payment request and force it to fail with a 500
await page.route('**/api/payment', route =>
route.fulfill({ status: 500, body: 'Internal Server Error' })
);
await page.goto('https://example-shop.test/checkout');
await page.click('text=Pay now');
await expect(page.locator('.error-banner')).toHaveText(
'We could not process your payment. Please try again.'
);
// Clean up the route so later tests are unaffected
await page.unroute('**/api/payment');
});
Uses Playwright's route interception to force a payment API call to fail with a 500 status, then asserts that the checkout page shows a friendly error instead of crashing or hanging.
# Add 300ms of latency and 2% packet loss to the eth0 interface
sudo tc qdisc add dev eth0 root netem delay 300ms loss 2%
# Run your test suite here against the degraded network
# Remove the simulated network conditions afterwards
sudo tc qdisc del dev eth0 root netem
Uses tc with the netem module to simulate a degraded network connection (added latency and packet loss) at the operating system level, then cleans up the rule once testing is finished.
Tips
- Start with one fault at a time and confirm the application handles it correctly before combining faults, since compound failures are much harder to diagnose.
- Always write an assertion for the expected degraded behaviour (an error message, a retry, a fallback) rather than just triggering the fault and watching manually.
- Prefer the lowest layer that answers your question: a Playwright route is enough to test a page's error handling, you only need tc/netem or a proxy like Toxiproxy when you need to affect a whole service or process.
Common pitfalls
- Leaving an injected fault active after the test finishes, such as an un-removed Playwright route or a tc qdisc rule left on an interface, which silently breaks unrelated tests that run afterwards; always pair injection with explicit cleanup.
- Checking only that the service or container restarts without checking that in-flight data survived the failure, which can hide data loss or duplication behind an apparently healthy service.
Observability and Measuring the Blast Radius
Running a chaos experiment without watching the right signals turns it into theatre. Before you fail a request or take a dependency offline, decide what "coping well" looks like and what evidence would prove otherwise. That means instrumenting four layers at once: the browser console (uncaught errors, warnings, stack traces), the network tab (status codes, timing, retries), the rendered page (spinners that never resolve, stale data, broken layout), and the user-facing outcome (can the task still be completed, with what delay, with what message). A fault that trips a 500 but leaves the UI silent is often worse than one that shows a clear banner, because the user has no idea anything went wrong.
Why Blast Radius Matters
'Blast radius' is the set of things actually affected by a failure once it happens, as opposed to the set of things you predicted would be affected. The gap between those two sets is where the interesting findings live.
Turning Observations into a Verdict
Every experiment should end with a yes/no verdict backed by evidence, not a feeling. Capture a screenshot at the moment of failure, the console log, the failed request's status and timing, and the steps that led there, then compare against your hypothesis line by line.
When you test this by hand in a browser, you can open DevTools and watch the console and network panels live, or script the same checks with Playwright so the assertions run every time. Some hosted test tools fold this in automatically: xtest's test agent reads the browser console and the page's network requests as it runs, and it can fail one of the site's own requests with a 500, offline, a slowdown or a hang to see how the app copes, so the evidence for a chaos experiment is captured alongside the steps that produced it.
What to Watch While the Experiment Runs
Treat the run like an incident you're deliberately causing, and watch it the way you'd want an on-call engineer to watch a real one. Four signal sources matter most:
- Browser console: uncaught exceptions, React/Vue warnings about failed state updates, and any error your error-tracking script would normally report. A clean console during a fault often means the error was swallowed silently, which is its own finding.
- Network activity: which requests actually failed versus which ones you intended to fail, whether retries happened and how many times, and whether a slow response caused a timeout further up the chain.
- Rendered state: does a spinner replace a broken screen, does stale cached data get shown as if it were fresh, does a form lose what the user typed.
- User-facing symptoms: the actual words shown, whether the task is still completable, and how long the user waits before anything happens.
Write these down as a checklist before the run starts. Deciding afterward what you 'should' have looked at almost guarantees you'll miss the one signal that mattered, especially on a fault that only lasts a few seconds.
Timing matters too: note when the fault started and stopped relative to when the symptom appeared, since a delayed reaction (a cache expiring thirty seconds later, say) points to a different root cause than an immediate one.
From Evidence to a Resilience Verdict
A hypothesis without a falsifiable prediction isn't testable, so write it as: 'If the recommendations API fails, the product page still renders with recommendations hidden, within 2 seconds.' That gives you three concrete things to check: did the page render, was the failing section hidden rather than broken, and was the delay inside budget.
When you review the run, compare each clause against what you captured. A partial pass is still useful information: maybe the page rendered and recommendations were hidden, but it took 6 seconds because of a long retry loop, so you've found a real but narrower gap than 'the page breaks.'
Keep the record format consistent across experiments so results are comparable over time: hypothesis, fault injected, duration, console output, network outcome, rendered state, user impact, verdict. Store the screenshot and the exact request that failed alongside the verdict, because 'it failed' six months from now is much less useful than the console line and the response code.
Be skeptical of a clean pass on the first try. Rerun the same experiment once or twice, since a race condition in a retry handler might only surface one time in three, and a single green run after a chaos experiment should raise your suspicion rather than close the ticket.
const { test, expect } = require('@playwright/test');
test('product page tolerates recommendations API failure', async ({ page }) => {
const consoleErrors = [];
page.on('console', msg => {
if (msg.type() === 'error') consoleErrors.push(msg.text());
});
// Inject the fault: force the recommendations call to fail
await page.route('**/api/recommendations**', route =>
route.fulfill({ status: 500, body: 'Internal Server Error' })
);
const start = Date.now();
await page.goto('https://shop.example.com/product/42');
// Main content must still render
await expect(page.locator('[data-testid="product-title"]')).toBeVisible();
// The broken section should be hidden, not broken
await expect(page.locator('[data-testid="recommendations"]')).toHaveCount(0);
const elapsed = Date.now() - start;
expect(elapsed).toBeLessThan(2000);
expect(consoleErrors.filter(e => e.includes('Uncaught'))).toHaveLength(0);
});
A Playwright test that injects a 500 on one API call, then checks the three clauses of the hypothesis: the page still renders, the broken section is hidden, and the delay stays under budget, while also capturing console errors as evidence.
Tips
- Decide your pass/fail criteria and write the hypothesis down before the fault is injected, not after you see what happened.
- Capture console output, network status codes and a screenshot together so a finding six months later still makes sense without re-running it.
- Rerun a passing experiment once or twice before trusting it; a single clean run can hide a timing-dependent failure.
- Measure from the moment the fault starts, not from page load, so your timing numbers reflect the actual recovery delay.
Common pitfalls
- Watching only the network tab and missing a silent console error: the request can fail cleanly while a downstream script throws and breaks an unrelated part of the page, so always check both.
- Declaring success because 'nothing crashed': a blank section, a frozen spinner or stale data shown as current are all resilience gaps even though no error was thrown, so judge against the user-facing outcome, not just the absence of a crash.
Operationalizing Chaos: Game Days and CI/CD
A chaos experiment that lives only in a slide deck never finds a real weakness. This section looks at the two places chaos engineering actually earns its keep: the scheduled, team-wide exercise known as a game day, and the small, automated fault checks that can run inside a CI/CD pipeline alongside your functional and regression tests.
A game day turns chaos engineering from an occasional heroic experiment into a repeatable team habit. It needs a hypothesis, a blast radius, an owner, and a clear rollback plan before anyone touches a switch. Over time these hypotheses accumulate into a backlog: untested failure modes worth exploring, ranked by how likely they are and how bad the impact would be if nobody had checked.
CI/CD is a different animal. You are not running a full, team-watched exercise on every commit; you are running a small, fast, automated fault check that fails the build if the system cannot cope with a known, bounded failure. The discipline here is scope: a pipeline step that injects latency into one dependency and checks that the service still responds within its timeout budget is useful; a pipeline step that takes down a whole cluster is not something you want running unattended on every pull request.
Both practices share the same underlying goal as the rest of this course: turning 'we think the system is resilient' into 'we checked, and here is the evidence.' The subsections below walk through running a game day end to end, and through where fault injection safely fits in a pipeline.
Running a Game Day
A game day is a scheduled, deliberate exercise where a team injects a known fault into a system, usually in staging or a carefully scoped slice of production, and watches what happens together. The format matters more than the tooling.
Start with a written hypothesis: 'If the payments service is unreachable for 30 seconds, checkout falls back to a cached price and shows a retry banner, rather than crashing the page.' Name an owner, a start and end time, and the blast radius: which services, which users, which environment. Agree the abort conditions up front, so nobody is negotiating a rollback while the experiment is already causing pain.
During the exercise, one person injects the fault, one person watches dashboards and logs, and one person takes notes in real time: what was expected, what actually happened, how long detection took, how long recovery took. Afterwards, write up the gap between hypothesis and observation as a backlog item, not as a postmortem of a failure. A game day that confirms the hypothesis is still a success; it proves the resilience you believed existed.
Build a backlog of hypotheses rather than inventing a new one each time. Likely candidates include: a downstream API returning 500s, a database connection pool exhausting, a third-party auth provider timing out, a cache going cold under load. Rank the backlog by plausibility and by blast radius, and work through it at a steady cadence, monthly or quarterly, so resilience gets checked continuously rather than once.
Fault Injection Inside CI/CD
A full game day does not belong in a pipeline that runs on every commit. What does belong there is a small, bounded fault check: inject one known failure, assert one known behavior, and fail the build if the assertion does not hold.
A good pipeline-scale check targets a single dependency and a single expected fallback: a timeout, a retry, a circuit breaker opening, a cached response being served. Keep the fault injection tool itself out of production traffic paths in CI; run it against a disposable test environment stood up for the pipeline run.
When the thing under test is a web application's own network calls, a QA test agent can be a lighter-weight option than standing up separate fault-injection infrastructure. In xtest, a test agent can make one of the site's own requests fail with a 500, go offline, slow down, or hang, specifically to see how the application copes, and this can be scripted into a CI run through xtest's REST API alongside your regular suite.
Keep pipeline-level chaos checks fast and narrow: seconds, not minutes, and one fault per test. If a check is flaky, that is itself a finding worth a game day, not a reason to delete the check.
{
"version": "1.0.0",
"title": "Checkout survives payments API latency",
"description": "Checkout should show a retry banner, not crash, when the payments API is slow",
"steady-state-hypothesis": {
"title": "Checkout page responds",
"probes": [
{
"type": "probe",
"name": "checkout-returns-200",
"tolerance": 200,
"provider": {
"type": "http",
"url": "https://staging.example.com/checkout",
"timeout": 5
}
}
]
},
"method": [
{
"type": "action",
"name": "inject-latency-on-payments-api",
"provider": {
"type": "process",
"path": "toxiproxy-cli",
"arguments": "toxic add payments -t latency -a latency=4000"
}
}
],
"rollbacks": [
{
"type": "action",
"name": "remove-latency-toxic",
"provider": {
"type": "process",
"path": "toxiproxy-cli",
"arguments": "toxic remove payments -n latency_downstream"
}
}
]
}
A Chaos Toolkit experiment definition that uses Toxiproxy to add 4 seconds of latency to a payments API proxy, then checks that the checkout page still responds, with a rollback step that always removes the injected latency.
#!/usr/bin/env bash
set -euo pipefail
# Run inside a CI job, against a disposable staging environment
echo "Injecting 3s latency on the orders API via Toxiproxy..."
toxiproxy-cli toxic add orders_api -t latency -a latency=3000
echo "Calling checkout endpoint and checking fallback behavior..."
STATUS=$(curl -s -o /tmp/body.json -w "%{http_code}" \
--max-time 5 https://staging.example.com/api/checkout)
BODY=$(cat /tmp/body.json)
toxiproxy-cli toxic remove orders_api -n latency_downstream
if [[ "$STATUS" != "200" ]]; then
echo "FAIL: expected checkout to degrade gracefully, got status $STATUS"
exit 1
fi
if ! echo "$BODY" | grep -q "retry"; then
echo "FAIL: expected a retry message in the response body"
exit 1
fi
echo "PASS: checkout degraded gracefully under orders API latency"
A bounded CI pipeline step that injects 3 seconds of latency into one dependency, calls the affected endpoint once, checks for the expected graceful-degradation response, removes the fault, and fails the build if the fallback behavior was not observed.
Tips
- Write the hypothesis and abort conditions down before a game day starts, not during it, so nobody improvises a rollback decision under pressure.
- Keep CI-level fault checks to one dependency and one assertion each; a pipeline is the wrong place for a multi-service blast radius.
- Treat every game day's gap between hypothesis and reality as a backlog item, win or lose, so the next experiment builds on the last one instead of repeating it.
Common pitfalls
- Running chaos experiments only as one-off events: without a backlog and a cadence, resilience gets checked once and then quietly goes stale as the system changes. Schedule game days on a recurring cycle so the backlog keeps moving.
- Letting a CI fault check grow into a full chaos experiment: a step that takes down a whole cluster on every pull request will be disabled by an annoyed team within a week. Keep pipeline checks small, fast, and clearly scoped to a single known fault.
Exercises
Exercise 1: Write and Run Your First Chaos Hypothesis
In this exercise you will pick one critical user journey in a web application you have access to (your own project, a demo shop, or any site you are permitted to test), define its steady state, write a single hypothesis about what should happen if one of its dependencies fails, and then prove or disprove that hypothesis using a tool that can intercept network requests. The goal is not to find a defect, though you may find one, but to practice the discipline of defining 'working' before you break anything, and recording the outcome the same way you would a test case result.
- Choose one user journey, such as logging in, adding an item to a cart, or submitting a form, and write down its steady state as a concrete, checkable statement (for example, 'submitting the form shows a success message within 3 seconds').
- Identify one network call that journey depends on, and write a hypothesis predicting what the page will do if that call fails with a 500 error or times out.
- Using Playwright's page.route (or an equivalent proxy tool), intercept that network call and force it to fail or hang.
- Run the journey against the faulted environment and observe the actual behavior, capturing a screenshot and the browser console output.
- Compare the actual behavior to your hypothesis and write a short report: hypothesis, steady state, what happened, pass or fail, and severity if it failed.
Expected outcome: A written experiment report containing the steady state definition, the hypothesis, the fault injection method used, the observed result with a screenshot, and a clear pass/fail verdict with reasoning, in the same format you would use for a standard test case.
Exercise 2: Expand the Blast Radius Safely
Building on Exercise 1, you will now repeat the same type of experiment but widen the blast radius in a controlled way, and add a rollback and stop condition before you begin. This exercise focuses on the safety practices that separate a useful chaos experiment from an accidental outage, and on documenting an experiment plan thoroughly enough that a teammate could run it without further explanation.
- Pick a second dependency in the same journey, or widen the first experiment to cover a second page that uses the same API.
- Write a full experiment plan before running anything: the fault, the exact scope it will be applied to, the steady state metric you will watch live, the stop condition (for example, 'stop immediately if the page becomes fully unresponsive'), and the rollback steps.
- Have a teammate (or yourself, reading only the plan) run the experiment using just the written plan, without additional verbal instructions.
- During the run, actively watch the steady state metric and be ready to trigger the rollback the moment the stop condition is met.
- After the run, note anything the written plan was missing that the runner had to figure out on their own, and revise the plan.
Expected outcome: A reusable, written experiment plan that another tester could follow unaided, plus a short retrospective note on what had to be added or clarified after the first attempt to run it.
Quiz
1. What is the primary purpose of defining a 'steady state' before running a chaos experiment?
- To guarantee the system will never fail during the experiment
- To have a measurable, agreed definition of normal behavior to compare against once a fault is injected
- To satisfy a compliance requirement before testing begins
- To decide which team will be blamed if something breaks
Show answer
B. To have a measurable, agreed definition of normal behavior to compare against once a fault is injected
Steady state gives you a concrete, checkable baseline of healthy behavior. Without it, you have no reliable way to tell whether the fault you injected actually changed the system's behavior or whether what you observed was already normal.
2. Why should a chaos experiment start with the smallest possible blast radius?
- Because small experiments are always faster to set up
- Because it limits how much of the system or how many users can be affected while you learn how the system reacts
- Because automated tools cannot handle a large blast radius
- Because regulations require it in every testing environment
Show answer
B. Because it limits how much of the system or how many users can be affected while you learn how the system reacts
Starting small limits the potential damage from an unexpected result and lets you build confidence gradually. Once you understand how the system behaves at a small scale, you can widen the blast radius with far less risk.
3. A hypothesis for a chaos experiment should be:
- A general hope that the system will 'probably be fine'
- A specific, falsifiable prediction naming the fault, the affected component, and the expected outcome
- A list of every possible thing that could go wrong
- Written only after the experiment has already run
Show answer
B. A specific, falsifiable prediction naming the fault, the affected component, and the expected outcome
A good hypothesis is specific and testable, for example predicting that a particular page will show a fallback message rather than crash when a particular dependency fails. This mirrors how a clear test case states one action and one expected result.
4. In the Playwright example from this course, what does page.route achieve in a chaos experiment?
- It records a video of the test run
- It intercepts a network request so it can be forced to fail or return a specific response, simulating a dependency outage
- It navigates the browser to a new page
- It permanently blocks the application from making that request in production
Show answer
B. It intercepts a network request so it can be forced to fail or return a specific response, simulating a dependency outage
page.route lets the test intercept matching network requests and control their response, which is exactly the mechanism used to simulate a failing dependency such as a payment API returning a 500 error.
5. Why should a rollback plan and stop condition be defined before an experiment runs, rather than improvised during it?
- Because improvising is against company policy
- Because deciding them in advance, while calm, ensures the experiment can be ended quickly and safely if something unexpected happens
- Because tools like tc and Playwright require a rollback script to function at all
- Because stop conditions are only needed for production experiments, never for staging
Show answer
B. Because deciding them in advance, while calm, ensures the experiment can be ended quickly and safely if something unexpected happens
Deciding the rollback and stop condition ahead of time means you are not trying to think clearly under pressure while something is actively going wrong. It keeps the experiment safe and reversible regardless of what you observe once the fault is live.