26 lines
1.3 KiB
C++
26 lines
1.3 KiB
C++
// Route: /operability/slo (error budget burn)
|
|||
|
|
#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/slo").status == 200, "status 200");
|
||
|
|
for (int i = 0; i < 20; ++i) f.client->post("/operability/slo/good", "", kForm);
|
||
|
|
check(contains(f.client->get("/operability/slo").body, "healthy"), "healthy without bad events");
|
||
|
|
f.client->post("/operability/slo/bad", "", kForm);
|
||
|
|
check(contains(f.client->get("/operability/slo").body, "burning"), "one bad of 21 is within budget");
|
||
|
|
f.client->post("/operability/slo/bad", "", kForm);
|
||
|
|
f.client->post("/operability/slo/bad", "", kForm);
|
||
|
|
check(contains(f.client->get("/operability/slo").body, "exhausted"), "budget exhausted");
|
||
|
|
f.client->post("/operability/slo/reset", "", kForm);
|
||
|
|
check(contains(f.client->get("/operability/slo").body, "0/100"), "side effect: window emptied");
|
||
|
|
for (int i = 0; i < 105; ++i) f.client->request(Method::Post, "/operability/slo/good", "", {{"Accept", "application/json"}});
|
||
|
|
check(contains(f.client->get("/operability/slo").body, "100/100"), "limit: window capped at 100");
|
||
|
|
check(f.client->request(Method::Put, "/operability/slo").status == 405, "405 on put");
|
||
|
|
return finish("operability/slo");
|
||
|
|
}
|