You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2021/12/06 10:38:47 UTC

[camel-quarkus] branch main updated: Fix AWS Lambda failing itest #3356

This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 914b38f  Fix AWS Lambda failing itest #3356
914b38f is described below

commit 914b38ffd16bb54894c3414cba4e5935a76f0e29
Author: aldettinger <al...@gmail.com>
AuthorDate: Thu Dec 2 18:09:40 2021 +0100

    Fix AWS Lambda failing itest #3356
---
 .../aws2/lambda/it/Aws2LambdaResource.java         |  8 ++++---
 .../component/aws2/lambda/it/Aws2LambdaTest.java   | 26 +++++++++++++++++-----
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java b/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
index ecd0201..c5204cd 100644
--- a/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
+++ b/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
@@ -101,13 +101,13 @@ public class Aws2LambdaResource {
                 .build();
     }
 
-    @Path("/function/get/{functionName}")
+    @Path("/function/getState/{functionName}")
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     public String getFunction(@PathParam("functionName") String functionName) {
         return producerTemplate
                 .requestBody(componentUri(functionName, Lambda2Operations.getFunction), null, GetFunctionResponse.class)
-                .configuration().functionName();
+                .configuration().stateAsString();
     }
 
     @Path("/function/getArn/{functionName}")
@@ -129,7 +129,9 @@ public class Aws2LambdaResource {
                 .zipFile(SdkBytes.fromByteArray(zipFunctionBytes)).build();
         UpdateFunctionCodeResponse ufcResponse = producerTemplate.requestBody(uri, ufcRequest,
                 UpdateFunctionCodeResponse.class);
-        if (ufcResponse.lastUpdateStatus() == LastUpdateStatus.SUCCESSFUL) {
+
+        if (ufcResponse.lastUpdateStatus() == LastUpdateStatus.SUCCESSFUL
+                || ufcResponse.lastUpdateStatus() == LastUpdateStatus.IN_PROGRESS) {
             return Response.ok().build();
         }
         throw new IllegalStateException(
diff --git a/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java b/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
index 2153ac6..2bf2289 100644
--- a/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
+++ b/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
@@ -97,12 +97,26 @@ class Aws2LambdaTest {
     public void getUpdateListAndInvokeFunctionShouldSucceed(String functionName) {
         final String name = "Joe " + java.util.UUID.randomUUID().toString().replace("-", "");
 
-        RestAssured.given()
-                .accept(ContentType.JSON)
-                .get("/aws2-lambda/function/get/" + functionName)
-                .then()
-                .statusCode(200)
-                .body(is(functionName));
+        await().pollDelay(1L, TimeUnit.SECONDS)
+                .pollInterval(1L, TimeUnit.SECONDS)
+                .atMost(120, TimeUnit.SECONDS)
+                .until(() -> {
+                    String state = RestAssured.given()
+                            .get("/aws2-lambda/function/getState/" + functionName)
+                            .then()
+                            .statusCode(200)
+                            .extract().asString();
+
+                    if (!"Active".equals(state)) {
+                        String format = "The function with name '%s' has state '%s', so retrying";
+                        LOG.infof(format, functionName, state);
+                        return false;
+                    } else {
+                        String format = "The function with name '%s' has state 'Active', so moving to next step";
+                        LOG.infof(format, functionName);
+                        return true;
+                    }
+                });
 
         RestAssured.given()
                 .contentType("application/zip")