QA AND TEST AUTOMATION · PART 8 · CI/CD AND TEST INFRASTRUCTURE · STRATEGY · 79 OF 112

Testing in Production: Feature Flags, Canaries, Monitors

Testing safely where real users are: feature flags and how to test both sides of a flag, canary and blue-green releases with automatic rollback, synthetic monitors that run a read-only journey every few minutes, smoke tests after each deploy, observability for testers (logs, metrics, traces, error tracking), and the rules that keep production testing safe, with ShopRung examples.

  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 / 11

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

Key takeaways

  • Feature flags, both sides
  • canary and blue-green
  • smoke after deploy
  • synthetic monitors
  • observability
  • safety

Notes

Feature flags

A feature flag separates deploying code from releasing a feature. The new code ships turned off, and a flag decides at run time who sees it: nobody, staff only, five percent of users, one region, or everyone. If something goes wrong, turning the flag off is a kill switch that works in seconds, without a new deploy. Flag tools include LaunchDarkly, Unleash and OpenFeature based libraries.

A flag in code
if (flags.isOn("freeship-coupon",
                 user)) {
  // new coupon rules
} else {
  // current rules
}

flag targets: off, staff only,
  5% of users, a region, 100%
kill switch: off in seconds

Testing flags

Testing flags means testing both sides. Flag off must keep the old behaviour, which is what most users see. Flag on gives the new behaviour. Test switching while a user is in the middle of checkout, and that targeting reaches only the right users. Tests should set the flag explicitly, through an API, configuration or an override, never depend on its current state. And push to remove old flags; each one doubles the paths to test.

What to test
  • flag OFF: old behaviour still works (the default!)
  • flag ON: new behaviour
  • switching while a user is mid-checkout
  • targeting: right users only tests set the flag explicitly (API, config, or override)
  • remove old flags: each one doubles the paths

Canary releases

A canary release sends a small share of traffic, say five percent, to the new version, and compares its error rate and response times with the old one. If it is healthy, the share grows step by step to everyone; if it is worse, the platform rolls back automatically. Blue green keeps two complete environments and switches all traffic at once, so switching back is just as fast. Testers help define what healthy means.

Canary and blue-green
  • canary: new version gets 5% of traffic; compare error rate and latency with the old one → healthy: 25%, 50%, 100% → worse: automatic rollback
  • blue-green: two full environments; switch traffic at once, switch back fast

Synthetic monitors

A synthetic monitor is a small automated test that runs against production every few minutes, often from several regions. Here it opens ShopRung, searches for mug and expects the two mugs; we ran it against ShopRung and it passed in under a second. Monitors stay read only, or use dedicated test accounts and data that are cleaned up. Alert after two failures in a row, not one, to avoid waking people for a single network hiccup. Checkly, Datadog and similar tools run Playwright scripts like this.

A read-only monitor
test("shop is usable", async
    ({ page }) => {
  await page.goto("/");
  const q = page.getByRole("searchbox");
  await q.fill("mug");
  await q.press("Enter");
  await expect(page.getByRole(
    "article")).toHaveCount(2);
});
// every 5 min; alert after 2 fails

Smoke after deploy

Right after each deploy, a short smoke suite checks the new version is alive and usable. Does the health endpoint answer up, with the new version number? ShopRung's health endpoint returns its name and version, which is exactly what this check needs. Do the home page and search load? Can a test account log in and add to cart, without placing a real order? It should take under two minutes, and a failure stops the rollout.

Post-deploy smoke
  • GET /api/health → UP and the NEW version number
  • home page and search load
  • log in with a test account
  • add to cart (no order placed)
  • under 2 minutes
  • fail → stop the rollout or roll back

Observability

Observability is how you see inside production. Logs say what happened, searchable by request id. Metrics show rates and times, like the error rate, ninety fifth percentile latency, and orders per minute, a business signal that drops when checkout breaks. Traces follow one request across services. Error tracking groups new errors after a release. Testers who read these find bugs no test environment shows.

Signals
  • logs: what happened, per request id
  • metrics: error rate, latency p95, orders per minute
  • traces: one request across services
  • error tracking: new errors grouped (e.g. Sentry)
  • dashboards + alerts

Safety rules

Rules that keep it safe. Never create real payments or orders, or make sure they are cancelled and refunded automatically. Mark test traffic with a header or dedicated test accounts, and exclude it from business analytics. Never run a load test against production without a plan and approval. Clean up test data. And never copy real customer data into tests or reports.

Rules
  • never real payments or orders (or refund automatically)
  • mark test traffic: header or test accounts, excluded from analytics
  • no load tests without a plan and approval
  • clean up test data
  • no real customer data in tests

Common mistakes

Mistakes. Flags that are never removed, so nobody knows which paths are live. Testing only the flag on side. Monitors that alert on a single blip until people mute them. Monitors that place real orders. Test traffic counted in sales reports. And canary releases without a clear health rule, so nobody knows when to stop.

Avoid these
  • flags never removed
  • only testing flag ON
  • monitors that alert on one blip (alert fatigue)
  • monitors placing real orders
  • test traffic counted as sales
  • canary with no clear health rule

Say it like this

In the interview: carefully. Features ship behind flags, and we test both sides. Rollouts are canaries with automatic rollback when error rate or latency gets worse. A smoke suite runs after every deploy, and read only synthetic monitors run every few minutes from several regions. Test traffic is marked, we never place real orders, and every production bug becomes a new automated test.

In the interview
  • "Carefully. Features ship behind
  • flags and we test both sides;
  • rollouts are canaries with automatic rollback on error
  • rate and latency. A smoke suite
  • runs after each deploy, and read-only synthetic monitors run
  • every few minutes. Test traffic
  • is marked, no real orders, and production bugs become tests."

Interview questions

Q1What is a feature flag?

A runtime switch that turns a feature on or off for chosen users without a new deploy, separating deployment from release.

Q2How do you test a feature behind a flag?

Test both flag states, switching mid-flow, and targeting; set the flag explicitly in tests and push to remove old flags.

Q3What is a canary release?

Sending a small share of traffic to a new version, comparing errors and latency, then increasing or rolling back automatically.

Q4What is the difference between canary and blue-green?

Canary shifts traffic gradually; blue-green keeps two full environments and switches all traffic at once, with fast switch-back.

Q5What is a synthetic monitor?

A small scripted journey run against production on a schedule, often from several regions, alerting on repeated failures.

Q6What does a post-deploy smoke test check?

Health and version, key pages load, a test login and a basic action work, within a couple of minutes; failure stops the rollout.

Q7Which observability signals matter to testers?

Logs with request ids, metrics (error rate, latency, business rates), traces and error tracking grouped by release.

Q8How do you keep production testing safe?

No real payments or orders, marked test traffic excluded from analytics, test data cleaned up, no load tests without approval.