You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "lopushen (via GitHub)" <gi...@apache.org> on 2024/05/30 22:34:45 UTC
[PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
lopushen opened a new pull request, #309:
URL: https://github.com/apache/camel-karaf/pull/309
Fixes https://github.com/apache/camel-karaf/issues/308
Motivation
During testing using an OSGI blueprint, it turned out that the camel-aws2-ses is missing bundles to successfully execute the route.
Modifications:
Add the missing bundles with appropriate SPI provide/consume statements
To run localstack (AWS emulator):
`docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack`
In the emulator run
`aws configure --profile localstack`
and enter in the prompt:
```
test
test
us-east-1
json
```
to get
```
AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test
Default region name [None]: us-east-1
Default output format [None]: json
```
And verify the sender's email in localstack console
`aws --endpoint-url=http://localhost:4566 ses verify-email-identity --email-address sender@example.com --region us-east-1 --profile localstack`
Deploy the following blueprint (the endpoint is producer-only, so only one route):
```
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="ses2Configuration" class="org.apache.camel.component.aws2.ses.Ses2Configuration">
<property name="accessKey" value="test"/>
<property name="secretKey" value="test"/>
<property name="region" value="us-east-1"/>
<property name="overrideEndpoint" value="true"/>
<property name="uriEndpointOverride" value="http://localhost:4566"/>
</bean>
<bean id="aws2-ses" class="org.apache.camel.component.aws2.ses.Ses2Component">
<property name="configuration" ref="ses2Configuration"/>
</bean>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint">
<route id="sendEmailRoute">
<from uri="timer:sendEmailTimer?period=5000"/>
<setHeader name="CamelAwsSesFrom">
<constant>sender@example.com</constant>
</setHeader>
<setHeader name="CamelAwsSesTo">
<constant>recipient@example.com</constant>
</setHeader>
<setHeader name="CamelAwsSesSubject">
<constant>Test Email</constant>
</setHeader>
<setBody>
<constant>Hello, this is a test email sent from Apache Camel using AWS SES!</constant>
</setBody>
<to uri="aws2-ses://default"/>
<log message="Sent email: ${body}"/>
</route>
</camelContext>
</blueprint>
```
Observe the following output:
```
01:32:04.093 INFO [Camel (camel-4) thread #7 - timer://sendEmailTimer] Sent email: Hello, this is a test email sent from Apache Camel using AWS SES!
01:32:09.090 INFO [Camel (camel-4) thread #7 - timer://sendEmailTimer] Sent email: Hello, this is a test email sent from Apache Camel using AWS SES!
01:32:14.136 INFO [Camel (camel-4) thread #7 - timer://sendEmailTimer] Sent email: Hello, this is a test email sent from Apache Camel using AWS SES!
```
And the following output in localstack:
```
2024-05-30T22:32:34.111 INFO --- [et.reactor-0] localstack.request.aws : AWS ses.SendEmail => 200
2024-05-30T22:32:39.103 INFO --- [et.reactor-1] localstack.request.aws : AWS ses.SendEmail => 200
2024-05-30T22:32:44.117 INFO --- [et.reactor-1] localstack.request.aws : AWS ses.SendEmail => 200
```
The features and bundles were added to awssdk feature as these dependencies are common with other aws features, e.g. camel-aws2-sns and camel-aws2-sqs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo merged PR #309:
URL: https://github.com/apache/camel-karaf/pull/309
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo commented on PR #309:
URL: https://github.com/apache/camel-karaf/pull/309#issuecomment-2141310076
This integration test https://github.com/apache/camel-karaf/tree/main/tests/features/camel-amqp as example could help
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
Posted by "lopushen (via GitHub)" <gi...@apache.org>.
lopushen commented on PR #309:
URL: https://github.com/apache/camel-karaf/pull/309#issuecomment-2147468550
> Could you please add an integration test that automatically does what you describe?
Added a blueprint-based integration test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo commented on code in PR #309:
URL: https://github.com/apache/camel-karaf/pull/309#discussion_r1625986537
##########
tests/features/camel-aws2-ses/src/test/java/org/apache/karaf/camel/itest/CamelAws2SesITest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed 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.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.itests.CamelKarafTestHint;
+import org.apache.karaf.camel.itests.GenericContainerResource;
+import org.apache.karaf.camel.itests.PaxExamWithExternalResource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.testcontainers.containers.localstack.LocalStackContainer;
+import org.testcontainers.utility.DockerImageName;
+
+@CamelKarafTestHint(externalResourceProvider = CamelAws2SesITest.ExternalResourceProviders.class, isBlueprintTest = true)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelAws2SesITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("OK");
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+ public static final class ExternalResourceProviders {
+
+ private static final int LOCALSTACK_ORIGINAL_PORT = 4566;
+ private static final String ACCESS_KEY = "test";
+ private static final String SECRET_KEY = "test";
+ private static final String REGION = "us-east-1";
+
+ public static GenericContainerResource<LocalStackContainer> createAws2SesContainer() {
+
+ final LocalStackContainer localStackContainer =
+ new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest")).withServices(
+ LocalStackContainer.Service.SES);
Review Comment:
```suggestion
new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
.withServices(LocalStackContainer.Service.SES);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo commented on code in PR #309:
URL: https://github.com/apache/camel-karaf/pull/309#discussion_r1626049606
##########
tests/features/camel-aws2-ses/src/test/java/org/apache/karaf/camel/itest/CamelAws2SesITest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed 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.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.itests.CamelKarafTestHint;
+import org.apache.karaf.camel.itests.GenericContainerResource;
+import org.apache.karaf.camel.itests.PaxExamWithExternalResource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.testcontainers.containers.localstack.LocalStackContainer;
+import org.testcontainers.utility.DockerImageName;
+
+@CamelKarafTestHint(externalResourceProvider = CamelAws2SesITest.ExternalResourceProviders.class, isBlueprintTest = true)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelAws2SesITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("OK");
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+ public static final class ExternalResourceProviders {
+
+ private static final int LOCALSTACK_ORIGINAL_PORT = 4566;
+ private static final String ACCESS_KEY = "test";
+ private static final String SECRET_KEY = "test";
+ private static final String REGION = "us-east-1";
+
+ public static GenericContainerResource<LocalStackContainer> createAws2SesContainer() {
+
+ final LocalStackContainer localStackContainer =
+ new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
Review Comment:
```suggestion
new LocalStackContainer(DockerImageName.parse("localstack/localstack:3.4.0"))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add missing bundles and features for camel-aws2-ses to awssdk [camel-karaf]
Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo commented on code in PR #309:
URL: https://github.com/apache/camel-karaf/pull/309#discussion_r1625989099
##########
tests/features/camel-aws2-ses/src/test/java/org/apache/karaf/camel/itest/CamelAws2SesITest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed 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.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.itests.CamelKarafTestHint;
+import org.apache.karaf.camel.itests.GenericContainerResource;
+import org.apache.karaf.camel.itests.PaxExamWithExternalResource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.testcontainers.containers.localstack.LocalStackContainer;
+import org.testcontainers.utility.DockerImageName;
+
+@CamelKarafTestHint(externalResourceProvider = CamelAws2SesITest.ExternalResourceProviders.class, isBlueprintTest = true)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelAws2SesITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("OK");
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+ public static final class ExternalResourceProviders {
+
+ private static final int LOCALSTACK_ORIGINAL_PORT = 4566;
+ private static final String ACCESS_KEY = "test";
+ private static final String SECRET_KEY = "test";
+ private static final String REGION = "us-east-1";
+
+ public static GenericContainerResource<LocalStackContainer> createAws2SesContainer() {
+
+ final LocalStackContainer localStackContainer =
+ new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
Review Comment:
Could you please set a specific tag instead of latest to avoid future failures due to regressions with the latest tag instead of the code itself
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org