You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/07/28 05:37:00 UTC

[camel] branch main updated (af8945f6c5e -> e81a0c1ccc0)

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

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


    from af8945f6c5e CAMEL-19491: aws2-sqs - use
     new 291575854de CAMEL-19491: aws2-sqs - use ScheduledPollConsumerHealthCheck
     new e81a0c1ccc0 CAMEL-19491: aws2-sqs - use ScheduledPollConsumerHealthCheck

The 2 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:
 .../aws2/ddbstream/Ddb2StreamEndpoint.java         |  62 ------------
 ...T.java => Ddb2StreamConsumerHealthCheckIT.java} |  17 +---
 ...db2StreamConsumerHealthCheckProfileCredsIT.java | 106 ---------------------
 .../Ddb2StreamConsumerHealthCustomClientIT.java    | 104 --------------------
 4 files changed, 4 insertions(+), 285 deletions(-)
 rename components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/{Ddb2StreamConsumerHealthCheckStaticCredsIT.java => Ddb2StreamConsumerHealthCheckIT.java} (82%)
 delete mode 100644 components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckProfileCredsIT.java
 delete mode 100644 components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCustomClientIT.java


[camel] 01/02: CAMEL-19491: aws2-sqs - use ScheduledPollConsumerHealthCheck

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 291575854de540a73ec87461ac32d0a53e293d5a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 07:29:27 2023 +0200

    CAMEL-19491: aws2-sqs - use ScheduledPollConsumerHealthCheck
---
 .../aws2/ddbstream/Ddb2StreamEndpoint.java         | 62 ----------------------
 1 file changed, 62 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java
index 3a36f8e1adb..1349e2efd67 100644
--- a/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java
+++ b/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamEndpoint.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.aws2.ddbstream;
 
-import java.net.URI;
-
 import org.apache.camel.Category;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
@@ -27,16 +25,7 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.ScheduledPollEndpoint;
 import org.apache.camel.util.ObjectHelper;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient;
-import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
 
 /**
  * Receive messages from AWS DynamoDB Stream service using AWS SDK version 2.x.
@@ -100,57 +89,6 @@ public class Ddb2StreamEndpoint extends ScheduledPollEndpoint {
         return ddbStreamClient;
     }
 
-    DynamoDbStreamsClient createDdbStreamClient() {
-        DynamoDbStreamsClient client = null;
-        DynamoDbStreamsClientBuilder clientBuilder = DynamoDbStreamsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-
     @Override
     public String toString() {
         return "DdbStreamEndpoint{" + "tableName=" + configuration.getTableName()


[camel] 02/02: CAMEL-19491: aws2-sqs - use ScheduledPollConsumerHealthCheck

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e81a0c1ccc078dd9b793548a374a389a146c22ba
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 07:36:51 2023 +0200

    CAMEL-19491: aws2-sqs - use ScheduledPollConsumerHealthCheck
---
 ...T.java => Ddb2StreamConsumerHealthCheckIT.java} |  17 +---
 ...db2StreamConsumerHealthCheckProfileCredsIT.java | 106 ---------------------
 .../Ddb2StreamConsumerHealthCustomClientIT.java    | 104 --------------------
 3 files changed, 4 insertions(+), 223 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckStaticCredsIT.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckIT.java
similarity index 82%
rename from components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckStaticCredsIT.java
rename to components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckIT.java
index 2533a7e20a5..7d1308ce4cf 100644
--- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckStaticCredsIT.java
+++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckIT.java
@@ -31,18 +31,14 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
-public class Ddb2StreamConsumerHealthCheckStaticCredsIT extends CamelTestSupport {
+public class Ddb2StreamConsumerHealthCheckIT extends CamelTestSupport {
 
     @RegisterExtension
     public static AWSService service = AWSServiceFactory.createS3Service();
 
-    private static final Logger LOG = LoggerFactory.getLogger(Ddb2StreamConsumerHealthCheckStaticCredsIT.class);
-
     CamelContext context;
 
     @Override
@@ -87,14 +83,9 @@ public class Ddb2StreamConsumerHealthCheckStaticCredsIT extends CamelTestSupport
             Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
             boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
             boolean containsKinesis2HealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ddbstream-consumer"))
-                    .findAny()
-                    .isPresent();
-            boolean hasRegionMessage = res2.stream()
-                    .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
-            Assertions.assertTrue(down, "liveness check");
-            Assertions.assertTrue(containsKinesis2HealthCheck, "aws2-ddbstream check");
-            Assertions.assertTrue(hasRegionMessage, "aws2-ddbstream check error message");
+                    .anyMatch(result -> result.getCheck().getId().startsWith("consumer:test-health-it"));
+            Assertions.assertTrue(containsKinesis2HealthCheck, "readiness check");
+            Assertions.assertTrue(down, "readiness check");
         });
 
     }
diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckProfileCredsIT.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckProfileCredsIT.java
deleted file mode 100644
index 4cdfb6e313d..00000000000
--- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCheckProfileCredsIT.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.ddbstream;
-
-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.aws.common.services.AWSService;
-import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient;
-
-import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
-
-public class Ddb2StreamConsumerHealthCheckProfileCredsIT extends CamelTestSupport {
-
-    @RegisterExtension
-    public static AWSService service = AWSServiceFactory.createS3Service();
-
-    private static final Logger LOG = LoggerFactory.getLogger(Ddb2StreamConsumerHealthCheckProfileCredsIT.class);
-
-    CamelContext context;
-
-    @Override
-    protected CamelContext createCamelContext() throws Exception {
-        context = super.createCamelContext();
-        context.getPropertiesComponent().setLocation("ref:prop");
-        Ddb2StreamComponent component = new Ddb2StreamComponent(context);
-        component.getConfiguration().setAmazonDynamoDbStreamsClient(DynamoDbStreamsClient.builder().build());
-        component.init();
-        context.addComponent("aws2-ddbstream", component);
-
-        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.getCamelContextExtension().addContextPlugin(HealthCheckRegistry.class, registry);
-
-        return context;
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-
-            @Override
-            public void configure() {
-                from("aws2-ddbstream://stream?region=l&useDefaultCredentialsProvider=true")
-                        .startupOrder(2).log("${body}").routeId("test-health-it");
-            }
-        };
-    }
-
-    @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 containsDdb2StreamHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ddbstream-consumer"))
-                    .findAny()
-                    .isPresent();
-            boolean hasRegionMessage = res2.stream()
-                    .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
-            Assertions.assertTrue(down, "liveness check");
-            Assertions.assertTrue(containsDdb2StreamHealthCheck, "aws2-ddbstream check");
-            Assertions.assertTrue(hasRegionMessage, "aws2-ddbstream check error message");
-        });
-
-    }
-}
diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCustomClientIT.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCustomClientIT.java
deleted file mode 100644
index cdd91f97cb1..00000000000
--- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/Ddb2StreamConsumerHealthCustomClientIT.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.ddbstream;
-
-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.aws.common.services.AWSService;
-import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient;
-
-import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
-
-@DisabledIfSystemProperty(named = "ci.env.name", matches = "github.com", disabledReason = "Flaky on GitHub Actions")
-public class Ddb2StreamConsumerHealthCustomClientIT extends CamelTestSupport {
-
-    @RegisterExtension
-    public static AWSService service = AWSServiceFactory.createS3Service();
-
-    private static final Logger LOG = LoggerFactory.getLogger(Ddb2StreamConsumerHealthCustomClientIT.class);
-
-    CamelContext context;
-
-    @Override
-    protected CamelContext createCamelContext() throws Exception {
-        context = super.createCamelContext();
-        context.getRegistry().bind("ddbClient", DynamoDbStreamsClient.builder().build());
-
-        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.getCamelContextExtension().addContextPlugin(HealthCheckRegistry.class, registry);
-
-        return context;
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-
-            @Override
-            public void configure() {
-                from("aws2-ddbstream://stream")
-                        .startupOrder(2).log("${body}").routeId("test-health-it");
-            }
-        };
-    }
-
-    @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 containsAws2DdbStreamHealthCheck = res2.stream()
-                    .filter(result -> result.getCheck().getId().startsWith("aws2-ddbstream-consumer"))
-                    .findAny()
-                    .isPresent();
-            boolean hasRegionMessage = res2.stream()
-                    .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
-            Assertions.assertTrue(down, "liveness check");
-            Assertions.assertTrue(containsAws2DdbStreamHealthCheck, "aws2-ddbstream check");
-            Assertions.assertFalse(hasRegionMessage, "aws2-ddbstream check error message");
-        });
-
-    }
-}