QA AND TEST AUTOMATION · PART 9 · NON-FUNCTIONAL TESTING · RELIABILITY · 87 OF 112

Chaos Testing Basics for QA Engineers

Chaos testing as experiments: a steady-state hypothesis, injected faults (killed processes, latency, failed dependencies, full disks), a small blast radius and abort conditions. A real experiment that stopped ShopRung for 5 seconds under Locust load: 50 of 350 requests failed, carts and sessions survived the restart, and a first run under-reported errors because the test's own check crashed, plus tools and game days.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 12

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Steady state
  • hypothesis
  • one fault
  • small blast radius
  • ShopRung outage: 14% failed, data kept
  • check your checks

Notes

The method

Chaos testing is an experiment, not random breaking. First, define steady state: what normal looks like in numbers, such as errors under one percent. Second, a hypothesis: if this fails, users can still do that. Third, inject one fault. Fourth, keep the blast radius small, with abort conditions and a way to roll back. Then observe, compare with steady state, learn, fix, and automate the experiment so it runs again.

Chaos experiment
  • 1 steady state: measurable normal (errors < 1%, p95)
  • 2 hypothesis: "if X fails, users still Y"
  • 3 inject ONE fault
  • 4 small blast radius, abort conditions, a rollback
  • 5 observe, compare, learn
  • 6 fix, then automate it

Kinds of fault

Faults come in a few kinds. Process faults: kill or restart a service, a container or a whole node. Network faults: added latency, lost packets, or a dependency that cannot be reached. Dependency faults: the payment provider returns errors or times out. Resource faults: CPU or memory exhausted, a full disk. And time faults: clocks out of step, expired certificates. Start with the failures your system is most likely to meet.

Faults to inject
  • process: kill or restart a service, a container, a node
  • network: latency, packet loss, a dependency unreachable
  • dependencies: payment API returns 500 or times out resources: CPU, memory, full disk
  • time: clock skew, expired certs

Our experiment

Our experiment. Load: Locust with twenty shoppers, each signed up with its own account, searching and adding to cart for thirty seconds. Fault: stop the ShopRung process at ten seconds and start it again at fifteen. Hypothesis: errors happen only during the outage, and afterwards existing carts and logins still work. Blast radius: a local test copy, so nobody else is affected.

Plan
  • load: Locust, 20 shoppers, each with its own account, searching and adding to cart
  • fault: stop ShopRung at 10 s, start it again at 15 s
  • hypothesis: errors only during the outage; afterwards carts and logins still work
  • blast radius: local test copy

Results

The results. Three hundred and fifty requests, fifty failed, about fourteen percent, all during the five second outage: thirty seven searches and thirteen add to cart calls were refused. After the restart, users' existing tokens still worked, and carts and orders were intact, because ShopRung keeps its data in a database file. The hypothesis held. In production, the finding would be: a single instance means every restart is a full outage.

Locust, 30 s, ShopRung down 5 s
requests          350
failed             50  (14%)
  search          37   status 0
  add to cart     13   connection
                       refused
after restart:
  old tokens       still valid
  carts and orders kept (SQLite
                       file)

Check your checks

An honest lesson. Our first run reported only eight failures, two point six percent. The search check read the JSON body before checking the status, so when the server was down, reading the body crashed and Locust never recorded those requests at all. Checking the status first fixed it, and the second run showed the true fifty failures. Chaos experiments test your monitoring and your tests, not only the system.

A bug in the test
with catch_response as r:
  if r.json()["count"] != 2:  ✗
    r.failure(...)
→ server down: r.json() crashed,
  the request was never recorded
  first run: 8 failures, 2.6%

if r.status_code != 200:     ✓
  r.failure(f"status ...")
→ second run: 50 failures, 14%

What users see

Also test what users see during a fault. Earlier in this track, when we took ShopRung's page offline, it showed the raw browser error text, failed to fetch. A better experience explains the problem in plain words and offers a retry. Resilient systems also use timeouts, retries with backoff, cached content, and degraded modes, such as hiding a recommendations panel when its service is down instead of failing the whole page.

ShopRung in the browser
  • network offline → the page shows the raw text "Failed to fetch"
  • better: "We can't reach the shop. Check your connection and try again." + a Retry
  • also: timeouts, retries with backoff, cached pages, degraded mode (hide reviews)

Tools

Tools range from one command to full platforms. Killing a process or stopping a container is the simplest fault. Toxiproxy sits between services and adds latency, timeouts or cut connections, which works well inside automated tests. Chaos Mesh and LitmusChaos run experiments on Kubernetes. Cloud providers offer fault injection services, and Gremlin is a commercial platform.

Chaos tools
  • kill / docker stop: simplest
  • Toxiproxy: latency, timeouts, cut connections between services (great in tests)
  • Chaos Mesh, LitmusChaos: Kubernetes experiments
  • AWS Fault Injection Service, Azure Chaos Studio
  • Gremlin: commercial platform

Game days

Teams often run chaos as game days: a planned session where the whole team runs an experiment, usually on staging first, and later in production on a small share of traffic once confidence is high. Watch the dashboards and alerts: did they fire, and were they clear? Practise the runbook. Write down every surprise, and turn findings into tickets and automated tests.

A game day
  • planned session, whole team
  • run an experiment on staging (later: production, small %)
  • watch dashboards and alerts: did they fire? were they clear?
  • practise the runbook
  • write down what surprised you
  • turn findings into tickets

Common mistakes

Mistakes. Starting in production. No steady state or hypothesis, so nobody knows what the result means. Several faults at once, so you cannot tell which caused what. No abort switch. Trusting your test's numbers without checking the checks, as our first run showed. And collecting findings that are never fixed.

Avoid these
  • starting in production
  • no steady state or hypothesis
  • several faults at once
  • no abort switch
  • trusting test numbers without testing the checks
  • findings never fixed

Say it like this

In the interview: chaos testing is controlled experimentation. Define steady state in metrics, state a hypothesis, inject one fault, such as a killed process, latency or dependency errors, with a small blast radius and an abort condition, then compare, fix and automate. Start in staging with tools like Toxiproxy or Chaos Mesh, and check both what users see and whether alerts fired.

In the interview
  • "Controlled experiments: define
  • steady state in metrics, state
  • a hypothesis, inject one fault
  • (kill, latency, dependency
  • errors) with a small blast
  • radius and an abort, compare, fix, automate. Start in staging, with Toxiproxy or Chaos Mesh, and check what users see and whether alerts fired."

Interview questions

Q1What is chaos testing?

Deliberately injecting failures in a controlled experiment to learn how a system behaves and to improve its resilience.

Q2What is a steady-state hypothesis?

A measurable definition of normal behaviour (for example errors under 1%) and a prediction that it holds when a fault is injected.

Q3What is blast radius?

How much of the system and how many users an experiment can affect; start small and grow with confidence.

Q4Name common faults to inject.

Killing processes or nodes, network latency or loss, failing dependencies, CPU/memory/disk exhaustion, and clock or certificate problems.

Q5What happened when ShopRung was stopped for 5 seconds under load?

50 of 350 requests (14%) failed during the outage; after restart, tokens, carts and orders were intact.

Q6Why did the first chaos run under-report errors?

The check parsed the JSON body before checking the status; with the server down it crashed, so failed requests were not recorded.

Q7Which tools are used for chaos testing?

Simple kills or docker stop, Toxiproxy, Chaos Mesh, LitmusChaos, cloud fault injection services and Gremlin.

Q8What is a game day?

A planned team session running chaos experiments, checking alerts and runbooks, and recording findings to fix.