// Route: /operability/chaos (dry run default, hard blast radius) #include "support/Assert.hpp" using namespace molo::example::test; using molo::example::fw::Method; static const char* kForm = "application/x-www-form-urlencoded"; int main() { Fixture f; check(f.client->get("/operability/chaos").status == 200, "status 200"); auto dry = f.client->post("/operability/chaos/run", "percent=40&max_faults=3", kForm); check(contains(dry.body, "dry run: 0 injected, 3 planned"), "default is a dry run"); auto armed = f.client->post("/operability/chaos/run", "percent=40&max_faults=2&armed=1", kForm); check(contains(armed.body, "armed: 2 injected, 2 planned"), "armed run capped at max_faults"); auto big = f.client->post("/operability/chaos/run", "percent=90&max_faults=9", kForm); check(big.status == 422 && contains(big.body, "must be between 0 and 50"), "percent above cap rejected"); check(contains(big.body, "must be between 1 and 5"), "faults above cap rejected"); check(contains(f.client->get("/operability/chaos").body, "total_injected"), "side effect: totals tracked"); check(contains(f.client->get("/operability/chaos").body, ">2<"), "only the armed run injected"); return finish("operability/chaos"); }