// Route: GET /healthz /readyz /startupz (probes, startup gate, 503) #include "support/Assert.hpp" using namespace molo::example::test; using molo::example::fw::Method; int main() { Fixture f; auto live = f.client->get("/healthz"); check(live.status == 200 && contains(live.body, "alive"), "liveness 200"); check(contains(live.headers.get("Content-Type"), "application/json"), "json"); check(f.client->get("/readyz").status == 200, "ready at start"); check(f.client->get("/startupz").status == 200, "started"); auto gate = f.client->request(Method::Post, "/startupz/tasks/seed-data?state=pending"); check(gate.status == 503 && contains(gate.body, "pending"), "gate closed is 503"); check(f.client->get("/readyz").status == 503, "not ready while starting"); check(f.client->get("/healthz").status == 200, "liveness unaffected"); f.client->request(Method::Post, "/startupz/tasks/seed-data?state=done"); auto down = f.client->request(Method::Post, "/readyz/checks/database?state=down"); check(down.status == 503 && contains(down.body, "\"database\":\"down\""), "failed check 503"); check(f.client->request(Method::Post, "/readyz/checks/database?state=up").status == 200, "recovers"); check(f.client->request(Method::Post, "/readyz/checks/database?state=meh").status == 422, "bad state 422"); check(f.client->request(Method::Post, "/readyz/checks/nothing?state=up").status == 404, "unknown check 404"); check(f.client->request(Method::Post, "/healthz").status == 405, "post is 405"); return finish("healthz/probes"); }