70/71
Sign inSign up free

815. A Smoke Test That Always Says OK

medium 20 XP ~12 minHands-on lab

After each deploy, the pipeline runs scripts/smoke.sh URL (in /home/student/repos/inventory-api) against the health endpoint. Last night it printed smoke ok while the service answered 500 to everyone; the week before, a hung server blocked the pipeline for an hour.

A fake API for experiments: /srv/lab/bin/fake-api 8080 &, then try http://127.0.0.1:8080/ok, /flaky (fails twice, then works), /degraded, /err, /html and /hang.

Task

Fix scripts/smoke.sh URL so that:

  • it tries up to SMOKE_TRIES times (default 10), waiting SMOKE_DELAY seconds (default 3) between tries,
  • each request gives up after SMOKE_TIMEOUT seconds (default 5),
  • a try succeeds only when the status is 200 and the body is JSON with "status": "ok"; then it stops trying and exits 0,
  • when all tries fail, it prints a message starting with smoke failed to stderr and exits non-zero.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.