Files
moloapp/tests/example/operability/deploy_test.cpp
T

29 lines
1.6 KiB
C++
Raw Normal View History

// Route: /operability/deploy (rolling, blue-green, rollback)
#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/deploy").status == 200, "status 200");
f.client->post("/operability/deploy/start", "strategy=rolling&version=v2", kForm);
f.client->post("/operability/deploy/step", "", kForm);
check(contains(f.client->get("/operability/deploy").body, "v2,v1,v1,v1"), "one instance replaced");
auto again = f.client->post("/operability/deploy/start", "strategy=rolling", kForm);
check(contains(again.body, "already in progress"), "second rollout refused");
auto rb = f.client->post("/operability/deploy/rollback", "", kForm);
check(contains(rb.body, "v1,v1,v1,v1") && contains(rb.body, "rolled back"), "rollback restores fleet");
f.client->post("/operability/deploy/start", "strategy=bluegreen&version=v3", kForm);
f.client->post("/operability/deploy/step", "", kForm);
check(contains(f.client->get("/operability/deploy").body, "v1,v1,v1,v1"), "green prepared, blue serves");
f.client->post("/operability/deploy/step", "", kForm);
auto done = f.client->get("/operability/deploy");
check(contains(done.body, "v3,v3,v3,v3") && contains(done.body, "done"), "switched");
auto bad = f.client->post("/operability/deploy/start", "strategy=canary", kForm);
check(bad.status == 422 && contains(bad.body, "must be one of: rolling, bluegreen"), "422 unknown strategy");
return finish("operability/deploy");
}