You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/11/04 10:35:57 UTC

[camel] 03/05: CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - DynamoDB

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

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

commit 98d72142fa3c06b02f245331b1a860b5c4456d14
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Nov 4 11:09:04 2022 +0100

    CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - DynamoDB
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../aws2/ddb/Ddb2ClientHealthCheckCustomTest.java} | 31 ++++++++++++----------
 .../Ddb2ClientHealthCheckProfileCredsTest.java}    | 18 ++++++-------
 .../ddb/Ddb2ClientHealthCheckStaticCredsTest.java} | 16 +++++------
 3 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckCustomTest.java
similarity index 78%
copy from components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckProfileCredsTest.java
copy to components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckCustomTest.java
index 638f0e9d787..24810c5436c 100644
--- a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckCustomTest.java
@@ -15,10 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.camel.component.aws2.cw;
-
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
+package org.apache.camel.component.aws2.ddb;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
@@ -31,12 +28,17 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
 
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
-public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
+public class Ddb2ClientHealthCheckCustomTest extends CamelTestSupport {
 
-    private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientHealthCheckProfileCredsTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(Ddb2ClientHealthCheckCustomTest.class);
 
     CamelContext context;
 
@@ -44,6 +46,10 @@ public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
     protected CamelContext createCamelContext() throws Exception {
         context = super.createCamelContext();
         context.getPropertiesComponent().setLocation("ref:prop");
+        Ddb2Component component = new Ddb2Component(context);
+        component.getConfiguration().setAmazonDDBClient(DynamoDbClient.builder().region(Region.of("Ciao")).build());
+        component.init();
+        context.addComponent("aws2-ddb", component);
 
         // install health check manually (yes a bit cumbersome)
         HealthCheckRegistry registry = new DefaultHealthCheckRegistry();
@@ -65,8 +71,8 @@ public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
 
             @Override
             public void configure() {
-                from("direct:listClusters")
-                        .to("aws2-cw://test?region=l&useDefaultCredentialsProvider=true");
+                from("direct:listTables")
+                        .to("aws2-ddb://test?enabledInitialDescribeTable=false");
             }
         };
     }
@@ -82,15 +88,12 @@ public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
         await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
-            boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-cw-client"))
+            boolean containsAws2DdbHealthCheck = res2.stream()
+                    .filter(result -> result.getCheck().getId().startsWith("aws2-ddb-client"))
                     .findAny()
                     .isPresent();
-            boolean hasRegionMessage = res2.stream()
-                    .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
-            Assertions.assertTrue(containsAws2AthenaHealthCheck, "aws2-cw check");
-            Assertions.assertTrue(hasRegionMessage, "aws2-eks check error message");
+            Assertions.assertTrue(containsAws2DdbHealthCheck, "aws2-ddb   check");
         });
 
     }
diff --git a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckStaticCredsTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckProfileCredsTest.java
similarity index 83%
rename from components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckStaticCredsTest.java
rename to components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckProfileCredsTest.java
index eb2553d91a0..7fe444595ba 100644
--- a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckStaticCredsTest.java
+++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckProfileCredsTest.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.camel.component.aws2.cw;
+package org.apache.camel.component.aws2.ddb;
 
 import java.util.Collection;
 import java.util.concurrent.TimeUnit;
@@ -34,9 +34,9 @@ import org.slf4j.LoggerFactory;
 
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
-public class Cw2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
+public class Ddb2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
 
-    private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientHealthCheckStaticCredsTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(Ddb2ClientHealthCheckProfileCredsTest.class);
 
     CamelContext context;
 
@@ -65,8 +65,8 @@ public class Cw2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
 
             @Override
             public void configure() {
-                from("direct:listClusters")
-                        .to("aws2-cw://test?region=l&secretKey=l&accessKey=k");
+                from("direct:listTables")
+                        .to("aws2-ddb://test?region=l&useDefaultCredentialsProvider=true&enabledInitialDescribeTable=false");
             }
         };
     }
@@ -82,15 +82,15 @@ public class Cw2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
         await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
-            boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-cw-client"))
+            boolean containsAws2DdbHealthCheck = res2.stream()
+                    .filter(result -> result.getCheck().getId().startsWith("aws2-ddb-client"))
                     .findAny()
                     .isPresent();
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
-            Assertions.assertTrue(containsAws2AthenaHealthCheck, "aws2-cw check");
-            Assertions.assertTrue(hasRegionMessage, "aws2-eks check error message");
+            Assertions.assertTrue(containsAws2DdbHealthCheck, "aws2-ddb check");
+            Assertions.assertTrue(hasRegionMessage, "aws2-ddb check error message");
         });
 
     }
diff --git a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckProfileCredsTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckStaticCredsTest.java
similarity index 85%
rename from components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckProfileCredsTest.java
rename to components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckStaticCredsTest.java
index 638f0e9d787..7a8f41c93a0 100644
--- a/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/Cw2ClientHealthCheckProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddb/Ddb2ClientHealthCheckStaticCredsTest.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.camel.component.aws2.cw;
+package org.apache.camel.component.aws2.ddb;
 
 import java.util.Collection;
 import java.util.concurrent.TimeUnit;
@@ -34,9 +34,9 @@ import org.slf4j.LoggerFactory;
 
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
-public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
+public class Ddb2ClientHealthCheckStaticCredsTest extends CamelTestSupport {
 
-    private static final Logger LOG = LoggerFactory.getLogger(Cw2ClientHealthCheckProfileCredsTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(Ddb2ClientHealthCheckStaticCredsTest.class);
 
     CamelContext context;
 
@@ -66,7 +66,7 @@ public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
             @Override
             public void configure() {
                 from("direct:listClusters")
-                        .to("aws2-cw://test?region=l&useDefaultCredentialsProvider=true");
+                        .to("aws2-ddb://test?region=l&secretKey=l&accessKey=k&enabledInitialDescribeTable=false");
             }
         };
     }
@@ -82,15 +82,15 @@ public class Cw2ClientHealthCheckProfileCredsTest extends CamelTestSupport {
         await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
-            boolean containsAws2AthenaHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-cw-client"))
+            boolean containsAws2DdbHealthCheck = res2.stream()
+                    .filter(result -> result.getCheck().getId().startsWith("aws2-ddb-client"))
                     .findAny()
                     .isPresent();
             boolean hasRegionMessage = res2.stream()
                     .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
             Assertions.assertTrue(down, "liveness check");
-            Assertions.assertTrue(containsAws2AthenaHealthCheck, "aws2-cw check");
-            Assertions.assertTrue(hasRegionMessage, "aws2-eks check error message");
+            Assertions.assertTrue(containsAws2DdbHealthCheck, "aws2-ddb check");
+            Assertions.assertTrue(hasRegionMessage, "aws2-ddb check error message");
         });
 
     }