31 lines
1.4 KiB
C++
31 lines
1.4 KiB
C++
// Route: POST /agent/optimize/cluster (local failure clustering)
|
|||
|
|
#include "support/GoogleRig.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
const char* json = "application/json";
|
||
|
|
GoogleRig keyed;
|
||
|
|
Fixture f(keyed.client);
|
||
|
|
check(f.client->post("/agent/optimize/cluster", "{}", json).status == 422,
|
||
|
|
"missing failures is 422");
|
||
|
|
check(f.client->post("/agent/optimize/cluster",
|
||
|
|
"{\"failures\":\"a\\nb\",\"max_clusters\":11}", json).status == 422,
|
||
|
|
"max_clusters over 10 is 422");
|
||
|
|
check(f.client->post("/agent/optimize/cluster",
|
||
|
|
"{\"failures\":\"a\",\"max_clusters\":0}", json).status == 422,
|
||
|
|
"max_clusters 0 is 422");
|
||
|
|
check(f.client->post("/agent/optimize/cluster", "{\"failures\":\"\\n\\n\"}", json).status == 422,
|
||
|
|
"only blank lines is 422");
|
||
|
|
check(keyed.mock->send_count() == 0, "rejected input never reached Google");
|
||
|
|
check(f.client->get("/agent/optimize/cluster").status == 405, "get is 405");
|
||
|
|
|
||
|
|
GoogleRig none(false);
|
||
|
|
Fixture g(none.client);
|
||
|
|
auto res = g.client->post("/agent/optimize/cluster", "{\"failures\":\"timeout\\nwrong tool\"}", json);
|
||
|
|
check(res.status == 503 && contains(res.body, "google_not_configured"),
|
||
|
|
"no credential is a loud 503");
|
||
|
|
check(none.mock->send_count() == 0, "no network without a credential");
|
||
|
|
return finish("agent/optimize/cluster");
|
||
|
|
}
|