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/10/27 10:16:03 UTC

[camel] branch main updated (83c90c1e23e -> 0b7394fa9b7)

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

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


    from 83c90c1e23e Sync deps
     new 0e297cc1a88 CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS
     new 4384eb8acdd     CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS
     new 0b7394fa9b7     CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/aws2/eks/EKS2ClientHealthCheck.java   | 10 ++++++----
 ...edsTest.java => EKS2CliientHealthCheckCustomTest.java} | 15 +++++++++------
 2 files changed, 15 insertions(+), 10 deletions(-)
 copy components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/{EKS2CliientHealthCheckStaticCredsTest.java => EKS2CliientHealthCheckCustomTest.java} (88%)


[camel] 02/03: CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS

Posted by ac...@apache.org.
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 4384eb8acdd5d8597d87c4bd965a5c2fb6fce8be
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Oct 27 12:14:27 2022 +0200

        CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../aws2/eks/EKS2CliientHealthCheckCustomTest.java | 101 +++++++++++++++++++++
 1 file changed, 101 insertions(+)

diff --git a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java
new file mode 100644
index 00000000000..29245859941
--- /dev/null
+++ b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.aws2.eks;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
+import org.apache.camel.test.junit5.CamelTestSupport;
+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.eks.EksClient;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
+
+public class EKS2CliientHealthCheckCustomTest extends CamelTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(EKS2CliientHealthCheckCustomTest.class);
+
+    CamelContext context;
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        context = super.createCamelContext();
+        context.getPropertiesComponent().setLocation("ref:prop");
+        EKS2Component component = new EKS2Component(context);
+        component.getConfiguration().setEksClient(EksClient.builder().region(Region.of("Ciao")).build());
+        component.init();
+        context.addComponent("aws2-eks", component);
+
+        // install health check manually (yes a bit cumbersome)
+        HealthCheckRegistry registry = new DefaultHealthCheckRegistry();
+        registry.setCamelContext(context);
+        Object hc = registry.resolveById("context");
+        registry.register(hc);
+        hc = registry.resolveById("routes");
+        registry.register(hc);
+        hc = registry.resolveById("consumers");
+        registry.register(hc);
+        context.setExtension(HealthCheckRegistry.class, registry);
+
+        return context;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() {
+                from("direct:listClusters")
+                        .to("aws2-eks://test?operation=listClusters");
+            }
+        };
+    }
+
+    @Test
+    public void testConnectivity() {
+
+        Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
+        boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
+        Assertions.assertTrue(up, "liveness check");
+
+        // health-check readiness should be down
+        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-eks-client"))
+                    .findAny()
+                    .isPresent();
+            Assertions.assertTrue(down, "liveness check");
+            Assertions.assertTrue(containsAws2AthenaHealthCheck, "aws2-eks check");
+        });
+
+    }
+}


[camel] 03/03: CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS

Posted by ac...@apache.org.
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 0b7394fa9b7c5ec2612b584a2c5a630094c96986
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Oct 27 12:15:50 2022 +0200

        CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java
index 29245859941..cf24d4e9518 100644
--- a/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java
+++ b/components/camel-aws/camel-aws2-eks/src/test/java/org/apache/camel/component/aws2/eks/EKS2CliientHealthCheckCustomTest.java
@@ -17,13 +17,15 @@
 
 package org.apache.camel.component.aws2.eks;
 
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.health.HealthCheck;
 import org.apache.camel.health.HealthCheckHelper;
 import org.apache.camel.health.HealthCheckRegistry;
 import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
-import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -32,9 +34,6 @@ import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.eks.EksClient;
 
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
 public class EKS2CliientHealthCheckCustomTest extends CamelTestSupport {


[camel] 01/03: CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS

Posted by ac...@apache.org.
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 0e297cc1a88271b58f44df59521a0e5969875f32
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Oct 27 11:59:51 2022 +0200

    CAMEL-18131 - camel-health - Add health checks for components that has extension for connectivity verification - Fix check for region before looking for enabled services - EKS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java
index 8ce3e4db1db..4a74b29abed 100644
--- a/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java
+++ b/components/camel-aws/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2ClientHealthCheck.java
@@ -49,10 +49,12 @@ public class EKS2ClientHealthCheck extends AbstractHealthCheck {
     @Override
     protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) {
         EKS2Configuration configuration = eks2Endpoint.getConfiguration();
-        if (!EksClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
-            builder.message("The service is not supported in this region");
-            builder.down();
-            return;
+        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
+            if (!EksClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
+                builder.message("The service is not supported in this region");
+                builder.down();
+                return;
+            }
         }
         try {
             EKS2InternalClient eks2Client = EKS2ClientFactory.getEksClient(configuration);