What are smoke tests and sanity tests?
BeginnerConceptTesting in DevOps
Answer
In one line: Smoke tests are a quick, broad check that the most important parts of a system work at all after a build or deployment; sanity tests are a quick, narrow check that a specific change or fix works.
Smoke tests
- Ask: "Is the build stable enough to test further / is the deployment basically working?"
- Cover the critical paths lightly: app starts, health endpoint returns 200, login works, home page loads, the database is reachable.
- Run right after a deployment to any environment — especially production.
- If they fail, stop the pipeline and roll back.
Example post-deploy smoke test:
curl -fsS https://staging.example.com/health || exit 1
curl -fsS https://staging.example.com/api/products?limit=1 | jq -e '.items | length > 0' || exit 1
Sanity tests
- Ask: "Does this particular fix or change work, and did it obviously break anything nearby?"
- Narrow and focused, usually after a bug fix or small change.
- Example: after fixing the coupon bug, quickly check that applying and removing a coupon works.
| Smoke | Sanity | |
|---|---|---|
| Scope | Broad, shallow | Narrow, focused |
| When | After every build/deploy | After a specific fix/change |
| Goal | Is it basically working? | Does this change work? |
In DevOps pipelines: smoke tests are automated and used as deployment gates — for example Argo Rollouts or a pipeline step runs them after deploying the canary and aborts if they fail.
Where the name comes from: hardware testing — power on a new board and see if smoke comes out.
Tip for interviews: mention that you run smoke tests automatically after every production deployment and roll back if they fail.
More on Testing in DevOps
What is the testing pyramid?BeginnerWhat is the difference between unit, integration and end-to-end tests?BeginnerWhat is regression testing?BeginnerWhat is test automation, and what should (and shouldn't) be automated?BeginnerWhat is shift-left testing, and how do you apply it in a pipeline?IntermediateWhat is contract testing, and why is it useful for microservices?Intermediate