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 2020/09/11 16:30:31 UTC

[camel] branch master updated (d335e5b -> 613dcba)

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

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


    from d335e5b  Camel-AWS2-S3: Use localstack edge service
     new 1aa4105  Camel-AWS2-EC2: Adding tests with localstack and Testcontainers
     new 55cc320  Camel-AWS2-SNS: Adding tests with localstack and Testcontainers
     new 613dcba  Camel-AWS2-SNS: It's snsclient not sqsclient

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:
 components/camel-aws2-ec2/pom.xml                  | 70 +++++++++++++++++
 .../aws2/ec2/localstack/Aws2EC2BaseTest.java}      | 20 ++---
 .../ec2/localstack/EC2ComponentLocalstackTest.java | 88 ++++++++++++++++++++++
 .../aws2/sns/localstack/Aws2SNSBaseTest.java       |  4 +-
 4 files changed, 170 insertions(+), 12 deletions(-)
 copy components/{camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java => camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/Aws2EC2BaseTest.java} (81%)
 create mode 100644 components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/EC2ComponentLocalstackTest.java


[camel] 01/03: Camel-AWS2-EC2: Adding tests with localstack and Testcontainers

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

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

commit 1aa4105500360bb8c4267fa61da4485c02779fc2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Sep 11 18:28:13 2020 +0200

    Camel-AWS2-EC2: Adding tests with localstack and Testcontainers
---
 components/camel-aws2-ec2/pom.xml | 70 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/components/camel-aws2-ec2/pom.xml b/components/camel-aws2-ec2/pom.xml
index a01517b..a5c2626 100644
--- a/components/camel-aws2-ec2/pom.xml
+++ b/components/camel-aws2-ec2/pom.xml
@@ -62,5 +62,75 @@
             <artifactId>log4j-slf4j-impl</artifactId>
             <scope>test</scope>
         </dependency>
+       <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-testcontainers-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
+
+    <profiles>
+        <profile>
+            <id>aws2-ec2-skip-tests</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>true</skipTests>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <!-- activate test if the docker socket file is accessible -->
+        <profile>
+            <id>aws2-ec2-tests-docker-file</id>
+            <activation>
+                <file>
+                    <exists>/var/run/docker.sock</exists>
+                </file>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <!-- activate test if the DOCKER_HOST env var is set -->
+        <profile>
+            <id>aws2-ec2-tests-docker-env</id>
+            <activation>
+                <property>
+                    <name>env.DOCKER_HOST</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>


[camel] 03/03: Camel-AWS2-SNS: It's snsclient not sqsclient

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

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

commit 613dcba2f8446bc54aaa62ee3ad77d6a0b67a1ee
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Sep 11 18:29:50 2020 +0200

    Camel-AWS2-SNS: It's snsclient not sqsclient
---
 .../apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java b/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java
index 94c5ec5..bbc05bd 100644
--- a/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java
+++ b/components/camel-aws2-sns/src/test/java/org/apache/camel/component/aws2/sns/localstack/Aws2SNSBaseTest.java
@@ -57,13 +57,13 @@ public class Aws2SNSBaseTest extends ContainerAwareTestSupport {
     }
 
     public SnsClient getSNSClient() {
-        SnsClient sqsClient = SnsClient
+        SnsClient snsClient = SnsClient
                 .builder()
                 .endpointOverride(URI.create("http://" + getS3Url()))
                 .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
                 .region(Region.EU_WEST_1)
                 .build();
-        return sqsClient;
+        return snsClient;
     }
 
     @Override


[camel] 02/03: Camel-AWS2-SNS: Adding tests with localstack and Testcontainers

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

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

commit 55cc3205c9c6bc6b45aa3544603c72b3bf104f6b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Sep 11 18:28:33 2020 +0200

    Camel-AWS2-SNS: Adding tests with localstack and Testcontainers
---
 .../aws2/ec2/localstack/Aws2EC2BaseTest.java       | 76 +++++++++++++++++++
 .../ec2/localstack/EC2ComponentLocalstackTest.java | 88 ++++++++++++++++++++++
 2 files changed, 164 insertions(+)

diff --git a/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/Aws2EC2BaseTest.java b/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/Aws2EC2BaseTest.java
new file mode 100644
index 0000000..024db7a
--- /dev/null
+++ b/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/Aws2EC2BaseTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.ec2.localstack;
+
+import java.net.URI;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.ec2.AWS2EC2Component;
+import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
+import org.apache.camel.test.testcontainers.junit5.Wait;
+import org.junit.jupiter.api.TestInstance;
+import org.testcontainers.containers.GenericContainer;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.ec2.Ec2Client;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class Aws2EC2BaseTest extends ContainerAwareTestSupport {
+
+    public static final String CONTAINER_IMAGE = "localstack/localstack:0.11.4";
+    public static final String CONTAINER_NAME = "ec2";
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return localstackContainer();
+    }
+
+    public static GenericContainer localstackContainer() {
+        return new GenericContainer(CONTAINER_IMAGE)
+                .withNetworkAliases(CONTAINER_NAME)
+                .withEnv("SERVICES", "ec2")
+                .withExposedPorts(4566)
+                .waitingFor(Wait.forListeningPort())
+                .waitingFor(Wait.forLogMessageContaining("Ready.", 1));
+    }
+
+    public String getS3Url() {
+        return String.format(
+                "%s:%d",
+                getContainerHost(CONTAINER_NAME),
+                getContainerPort(CONTAINER_NAME, 4566));
+    }
+
+    public Ec2Client getEc2Client() {
+        Ec2Client sqsClient = Ec2Client
+                .builder()
+                .endpointOverride(URI.create("http://" + getS3Url()))
+                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("xxx", "yyy")))
+                .region(Region.EU_WEST_1)
+                .build();
+        return sqsClient;
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        AWS2EC2Component ec2 = context.getComponent("aws2-ec2", AWS2EC2Component.class);
+        ec2.getConfiguration().setAmazonEc2Client(getEc2Client());
+        return context;
+    }
+}
diff --git a/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/EC2ComponentLocalstackTest.java b/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/EC2ComponentLocalstackTest.java
new file mode 100644
index 0000000..592dd35
--- /dev/null
+++ b/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/localstack/EC2ComponentLocalstackTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.ec2.localstack;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws2.ec2.AWS2EC2Constants;
+import org.apache.camel.component.aws2.ec2.AWS2EC2Operations;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.ec2.model.InstanceType;
+
+public class EC2ComponentLocalstackTest extends Aws2EC2BaseTest {
+
+    @Test
+    public void createAndRunInstancesTest() {
+
+        template.send("direct:createAndRun", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(AWS2EC2Constants.IMAGE_ID, "ami-fd65ba94");
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_TYPE, InstanceType.T2_MICRO);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_MIN_COUNT, 1);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_MAX_COUNT, 1);
+            }
+        });
+    }
+
+    @Test
+    public void createAndRunInstancesWithSecurityGroupsTest() {
+
+        template.send("direct:createAndRun", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(AWS2EC2Constants.IMAGE_ID, "ami-fd65ba94");
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_TYPE, InstanceType.T2_MICRO);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_MIN_COUNT, 1);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_MAX_COUNT, 1);
+                Collection<String> secGroups = new ArrayList<>();
+                secGroups.add("secgroup-1");
+                secGroups.add("secgroup-2");
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_SECURITY_GROUPS, secGroups);
+            }
+        });
+    }
+
+    @Test
+    public void ec2CreateAndRunTestWithKeyPair() throws Exception {
+
+        template.request("direct:createAndRun", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(AWS2EC2Constants.OPERATION, AWS2EC2Operations.createAndRunInstances);
+                exchange.getIn().setHeader(AWS2EC2Constants.IMAGE_ID, "ami-fd65ba94");
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_TYPE, InstanceType.T2_MICRO);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_MIN_COUNT, 1);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCE_MAX_COUNT, 1);
+                exchange.getIn().setHeader(AWS2EC2Constants.INSTANCES_KEY_PAIR, "keypair-1");
+            }
+        });
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:createAndRun")
+                        .to("aws2-ec2://TestDomain?operation=createAndRunInstances");
+            }
+        };
+    }
+}