mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(lambdaweb): check the endpoint quota after the revisions an endpoint routes to (#6888)
Lambda refuses a missing or Failed revision, a Failed latest revision and a connector revision on a PerRegion or MultiRegion endpoint before it refuses an endpoint past the maxEndpointsPerFunction quota.
This commit is contained in:
1 parent
42e7f6f2f3
commit
a682400d45
3 files changed
+30
-4
No files matched your search
@@ -474,6 +474,14 @@ class LambdaWebServiceTest {
|
||||
assertEquals(notServed.replace("PerRegion", "MultiRegion"),
|
||||
message(() -> service.updateEndpoint(REGION, "app", "mr", update)));
|
||||
assertEquals(plain, service.getEndpoint(REGION, "app", "pr").revisionWeights.get(0).revisionId);
|
||||
|
||||
for (int i = 5; i <= 10; i++) {
|
||||
service.createEndpoint(REGION, "app", weighted("ep" + i, "HomeRegion", plain));
|
||||
}
|
||||
assertEquals(notServed, message(() -> service.createEndpoint(REGION, "app",
|
||||
weighted("pr2", "PerRegion", connected))), "before the quota");
|
||||
assertEquals("ServiceQuotaExceededException", error(() -> service.createEndpoint(REGION, "app",
|
||||
weighted("home2", "HomeRegion", connected))).getErrorCode());
|
||||
}
|
||||
|
||||
private ObjectNode weighted(String name, String endpointType, String... revisionIds) {
|
||||
@@ -664,6 +672,12 @@ class LambdaWebServiceTest {
|
||||
assertEquals("ServiceQuotaExceededException", quota.getErrorCode());
|
||||
assertEquals(402, quota.getHttpStatus());
|
||||
assertEquals("The function " + ARN + " has reached the maxEndpointsPerFunction quota of 10.", quota.getMessage());
|
||||
assertEquals("The endpoint dev already exists.", message(() -> service.createEndpoint(REGION, "app",
|
||||
endpointConfig("dev"))));
|
||||
ObjectNode missing = endpointConfig("ep11").put("autoDeploymentMode", "Disabled");
|
||||
missing.putArray("revisionWeights").addObject().put("revisionId", "rev-aaaaa").put("weight", 100);
|
||||
assertEquals("The revision rev-aaaaa does not exist.", message(() -> service.createEndpoint(REGION, "app",
|
||||
missing)));
|
||||
|
||||
String revisionId = service.listRevisions(REGION, "app", mapper.createObjectNode()).items().get(0).revisionId;
|
||||
assertEquals("The revision " + revisionId + " cannot be deleted because the endpoints [dev, ep10, ep2, ep3, ep4,"
|
||||
@@ -1180,6 +1194,17 @@ class LambdaWebServiceTest {
|
||||
assertEquals(latestRefusal, message(() -> service.updateEndpoint(REGION, "app", "dev",
|
||||
mapper.createObjectNode().put("autoDeploymentMode", "LatestRevision"))));
|
||||
assertEquals(latestRefusal, message(() -> service.createEndpoint(REGION, "app", endpointConfig("auto"))));
|
||||
for (int i = 2; i <= 10; i++) {
|
||||
ObjectNode pinned = endpointConfig("ep" + i).put("autoDeploymentMode", "Disabled");
|
||||
pinned.set("revisionWeights", disabled.get("revisionWeights"));
|
||||
service.createEndpoint(REGION, "app", pinned);
|
||||
}
|
||||
assertEquals(refusal, message(() -> service.createEndpoint(REGION, "app", weighted)), "before the quota");
|
||||
assertEquals(latestRefusal, message(() -> service.createEndpoint(REGION, "app", endpointConfig("auto"))),
|
||||
"before the quota");
|
||||
for (int i = 2; i <= 10; i++) {
|
||||
service.deleteEndpoint(REGION, "app", "ep" + i);
|
||||
}
|
||||
|
||||
service.deleteRevision(REGION, "app", bad.revisionId);
|
||||
assertEquals(List.of(good), List.copyOf(service.getFunction(REGION, "app").revisions.keySet()));
|
||||
|
||||
Reference in new issue
Block a user