diff --git a/src/test/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayRequestAuthorizerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayRequestAuthorizerIntegrationTest.java index fcaf8c89f9..cec2b77631 100644 --- a/src/test/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayRequestAuthorizerIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayRequestAuthorizerIntegrationTest.java @@ -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> 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) diff --git a/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/HttpApiRequestAuthorizerTest.java b/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/HttpApiRequestAuthorizerTest.java index ee208bbf30..ebd5db6b58 100644 --- a/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/HttpApiRequestAuthorizerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/HttpApiRequestAuthorizerTest.java @@ -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> 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)