mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(apigateway): delete the authorizer tests' Lambda functions concurrently in cleanup (#3976)
This commit is contained in:
1 parent
8af15a71c4
commit
7c6cb265dc
2 files changed
+48
-16
No files matched your search
+25
-11
@@ -11,8 +11,13 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -979,23 +984,17 @@ class ApiGatewayRequestAuthorizerIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(99)
|
||||
void cleanup() {
|
||||
void cleanup() throws Exception {
|
||||
if (apiId != null) given().when().delete("/restapis/" + apiId).then().statusCode(202);
|
||||
if (tokenApiId != null) given().when().delete("/restapis/" + tokenApiId).then().statusCode(202);
|
||||
if (noneApiId != null) given().when().delete("/restapis/" + noneApiId).then().statusCode(202);
|
||||
if (denyApiId != null) given().when().delete("/restapis/" + denyApiId).then().statusCode(202);
|
||||
if (stageVarApiId != null) given().when().delete("/restapis/" + stageVarApiId).then().statusCode(202);
|
||||
if (apiKeyApiId != null) given().when().delete("/restapis/" + apiKeyApiId).then().statusCode(202);
|
||||
deleteFunction(AUTHORIZER_FUNCTION);
|
||||
deleteFunction(PROXY_FUNCTION);
|
||||
deleteFunction(TOKEN_AUTHORIZER_FUNCTION);
|
||||
deleteFunction(TOKEN_PROXY_FUNCTION);
|
||||
deleteFunction(NONE_INTEGRATION_FUNCTION);
|
||||
deleteFunction(DENY_AUTHORIZER_FUNCTION);
|
||||
deleteFunction("apigw-stagevar-auth-echo");
|
||||
deleteFunction("apigw-stagevar-proxy");
|
||||
deleteFunction("apigw-apikey-auth-echo");
|
||||
deleteFunction("apigw-apikey-proxy");
|
||||
deleteFunctions(AUTHORIZER_FUNCTION, PROXY_FUNCTION, TOKEN_AUTHORIZER_FUNCTION, TOKEN_PROXY_FUNCTION,
|
||||
NONE_INTEGRATION_FUNCTION, DENY_AUTHORIZER_FUNCTION,
|
||||
"apigw-stagevar-auth-echo", "apigw-stagevar-proxy",
|
||||
"apigw-apikey-auth-echo", "apigw-apikey-proxy");
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
@@ -1033,6 +1032,21 @@ class ApiGatewayRequestAuthorizerIntegrationTest {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private static void deleteFunctions(String... functionNames) throws Exception {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(functionNames.length);
|
||||
try {
|
||||
List<Future<?>> deletions = new ArrayList<>();
|
||||
for (String functionName : functionNames) {
|
||||
deletions.add(executor.submit(() -> deleteFunction(functionName)));
|
||||
}
|
||||
for (Future<?> deletion : deletions) {
|
||||
deletion.get();
|
||||
}
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteFunction(String functionName) {
|
||||
int statusCode = given()
|
||||
.when().delete(LAMBDA_BASE_PATH + "/" + functionName)
|
||||
|
||||
+23
-5
@@ -11,8 +11,13 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -708,13 +713,11 @@ class HttpApiRequestAuthorizerTest {
|
||||
|
||||
@Test
|
||||
@Order(999)
|
||||
void cleanup() {
|
||||
void cleanup() throws Exception {
|
||||
if (routeId != null) given().when().delete("/v2/apis/" + httpApiId + "/routes/" + routeId);
|
||||
if (httpApiId != null) given().when().delete("/v2/apis/" + httpApiId);
|
||||
for (String fn : new String[]{BACKEND_FN, ALLOW_FN, DENY_FN, ERROR_FN, SIMPLE_ALLOW_FN,
|
||||
SIMPLE_DENY_FN, ECHO_FN, NESTED_CTX_FN, CONTEXTLESS_FN}) {
|
||||
deleteFunction(fn);
|
||||
}
|
||||
deleteFunctions(BACKEND_FN, ALLOW_FN, DENY_FN, ERROR_FN, SIMPLE_ALLOW_FN,
|
||||
SIMPLE_DENY_FN, ECHO_FN, NESTED_CTX_FN, CONTEXTLESS_FN);
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
@@ -742,6 +745,21 @@ class HttpApiRequestAuthorizerTest {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private static void deleteFunctions(String... functionNames) throws Exception {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(functionNames.length);
|
||||
try {
|
||||
List<Future<?>> deletions = new ArrayList<>();
|
||||
for (String functionName : functionNames) {
|
||||
deletions.add(executor.submit(() -> deleteFunction(functionName)));
|
||||
}
|
||||
for (Future<?> deletion : deletions) {
|
||||
deletion.get();
|
||||
}
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteFunction(String functionName) {
|
||||
int statusCode = given()
|
||||
.when().delete("/2015-03-31/functions/" + functionName)
|
||||
|
||||
Reference in new issue
Block a user