← All Exercises
Gate a Blue/Green Traffic Switch
basicjavascript
Background
Blue/green releases are safe only when the decision is explicit. Ad-hoc promotion turns a reversible switch into an outage with a manual rollback.
Problem
Given the candidate environment health checks, error rate and p95 latency against thresholds, decide to switch, hold, or roll back.
Input
JSON object: { candidate: { healthChecks, errorRate, p95Ms }, thresholds: { maxErrorRate, maxP95Ms } }Output
JSON object: { action, reason }Sample tests
Sample 1
Input: {"candidate":{"healthChecks":"pass","errorRate":0.002,"p95Ms":180},"thresholds":{"maxErrorRate":0.01,"maxP95Ms":250}}Expected: {"action":"switch","reason":"all-gates-passed"}Sample 2
Input: {"candidate":{"healthChecks":"fail","errorRate":0.002,"p95Ms":180},"thresholds":{"maxErrorRate":0.01,"maxP95Ms":250}}Expected: {"action":"rollback","reason":"health-check-failed"}Your solution
Learning objective
Make release promotion a decision with explicit gates.