Writing a production smoke test that tells you why it failed
smoke-testmonitoringcurltriagedeployverification
A smoke test is a short, read-only script that walks the critical path of a live system end to
end. The valuable kind does not just say FAIL: each failure line names the likely cause, so the
same script is step 0 of incident triage. TLDR's ~/dev/tldr/smoke-test.sh (about 15 seconds,
exit 0 healthy / 1 broken) is the model.
Design rules
- Read-only. Safe to run any time, by anyone, as often as you like.
- Follow the real request chain, not just "is port 443 open": web shell, the build's version file, the main JS bundle, API root, auth enforcement, and one real user asset fetched through the same path the app uses.
- Decode status codes into causes. Every check knows what each failure status means in this stack.
- Verify each check against live prod before encoding it, then negative-test the failure path (force a bogus filename and confirm FAIL plus exit 1).
- Check that security holds, not only that things work: an unauthenticated
GET /postsmust be 401; a 200 there is a critical auth bypass. Add a check like this for every new authenticated surface (group chats added "unauthenticatedGET /groupsmust be 401"). - Keep secrets off the command line: pass the DB password via
MYSQL_PWD, not argv (visible inps). An optional token env var enables authenticated checks.
TLDR's checks, as an example
https://tldrnerd.com/returns 200.version.json(a Flutter build artifact) equalslib/version.dart. Fails by design if you bump locally before deploying.flutter_bootstrap.jsandmain.dart.jsreturn 200.- API
GET /returns 200 with its health string. 418 means the PDO bootstrap failed (DB down or bad config); 500 means PHP itself broke. GET /postswithout a token returns 401.- Image chain: over ssh, pick the newest upload URL from a non-deleted post body, fetch it through
/uploads/<file>, expect 200 with bytes and a content type. 500 = object-storage config missing on the server; 502 = the bucket rejected the presigned request (credentials or clock skew); 404 = object gone. - CORS header present on that image response (Flutter web's CanvasKit cannot draw cross-origin
images without it). The request must send an
Originheader if the server echoes an allowlist; origin-less requests legitimately get noAccess-Control-Allow-Origin. - Optional authenticated
GET /postswith a token from the environment.
Reading results
- A check can pass while its neighbor fails: Apache adds CORS headers to error responses too, so check 7 passed while check 6 failed.
- Every check returning status
000means nothing answered at all. Next step: ping and a raw TCP connect. Ports that accept connections but never send a byte (SSH hanging at "banner exchange") means userspace is starved, usually memory thrash. See Memory thrash and capacity on a 1 GB VPS.
When to run it
After every deploy, as the first step of any triage, after any production database change, and again after an incident is fixed, confirming all checks pass, not only the one you fixed.
See also
- Release-directory deploys with an atomic symlink swap
- TLDR platform architecture (tldrnerd.com)
- Accepting and serving user uploads safely from a private bucket
Linked from
- Accepting and serving user uploads safely from a private bucket
- Changing a production MariaDB safely (schema, data fixes, id generation)
- Memory thrash and capacity on a 1 GB VPS
- Release-directory deploys with an atomic symlink swap
- Slim 4 PHP APIs (and migrating from Limonade)
- TLDR platform architecture (tldrnerd.com)