diff --git a/tests/camel-kamelets-itest/pom.xml b/tests/camel-kamelets-itest/pom.xml index e2ac3b1fc..edf3884fc 100644 --- a/tests/camel-kamelets-itest/pom.xml +++ b/tests/camel-kamelets-itest/pom.xml @@ -98,6 +98,11 @@ camel-aws2-eventbridge test + + org.apache.camel + camel-aws2-sns + test + diff --git a/tests/camel-kamelets-itest/src/test/java/AwsIT.java b/tests/camel-kamelets-itest/src/test/java/AwsIT.java index ee67f5826..b1a364815 100644 --- a/tests/camel-kamelets-itest/src/test/java/AwsIT.java +++ b/tests/camel-kamelets-itest/src/test/java/AwsIT.java @@ -84,4 +84,9 @@ public Stream awsEventBridge() { return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("aws.eventbridge"); } + @CitrusTestFactory + public Stream awsSns() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("aws.sns"); + } + } diff --git a/tests/camel-kamelets-itest/src/test/resources-filtered/citrus-application.properties b/tests/camel-kamelets-itest/src/test/resources-filtered/citrus-application.properties index 970d0593b..1d5528b21 100644 --- a/tests/camel-kamelets-itest/src/test/resources-filtered/citrus-application.properties +++ b/tests/camel-kamelets-itest/src/test/resources-filtered/citrus-application.properties @@ -32,6 +32,10 @@ citrus.camel.jbang.kamelets.version=${project.version} # Enable dump of Camel JBang integration output citrus.camel.jbang.dump.integration.output=true +# Use Floci as the AWS emulator (drop-in replacement for LocalStack) +citrus.testcontainers.localstack.image.name=floci/floci +citrus.testcontainers.localstack.version=latest + # Use general registry mirror for Docker images (e.g. Testcontainers) citrus.testcontainers.registry.mirror=mirror.gcr.io citrus.testcontainers.registry.mirror.enabled=false diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-delete-item.citrus.it.yaml.disabled b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-delete-item.citrus.it.yaml.disabled index 5d8e87d5c..e9ddacdc6 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-delete-item.citrus.it.yaml.disabled +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-delete-item.citrus.it.yaml.disabled @@ -26,7 +26,7 @@ variables: - name: "timer.source.period" value: "10000" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -86,7 +86,7 @@ actions: jbang: run: integration: - file: "aws/ddb/aws-ddb-sink-pipe.yaml" + file: "aws/ddb/aws-ddb-sink-route.yaml" systemProperties: properties: - name: "timer.source.period" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-put-item.citrus.it.yaml.disabled b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-put-item.citrus.it.yaml.disabled index 93146ea4d..83b85c5e3 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-put-item.citrus.it.yaml.disabled +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-put-item.citrus.it.yaml.disabled @@ -26,7 +26,7 @@ variables: - name: "timer.source.period" value: "10000" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -73,7 +73,7 @@ actions: jbang: run: integration: - file: "aws/ddb/aws-ddb-sink-pipe.yaml" + file: "aws/ddb/aws-ddb-sink-route.yaml" systemProperties: properties: - name: "timer.source.period" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-sqs-event-listener-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml similarity index 57% rename from tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-sqs-event-listener-pipe.yaml rename to tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml index 6e4fe1695..a1dbca82f 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-sqs-event-listener-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-route.yaml @@ -15,27 +15,25 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-sqs-event-listener-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-sqs-source - properties: - queueNameOrArn: "{{aws.sqs.queueName}}" - uriEndpointOverride: "{{aws.eventbridge.uriEndpointOverride}}" - overrideEndpoint: "{{aws.eventbridge.overrideEndpoint}}" - accessKey: "{{aws.eventbridge.accessKey}}" - secretKey: "{{aws.eventbridge.secretKey}}" - region: "{{aws.eventbridge.region}}" - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-sink - properties: - showHeaders: true +- route: + from: + uri: "timer:tick" + parameters: + period: "{{timer.source.period}}" + repeatCount: 1 + steps: + - setBody: + constant: "{{aws.ddb.json.data}}" + - log: + message: "${body}" + showHeaders: true + - to: + uri: "kamelet:aws-ddb-sink" + parameters: + table: "{{aws.ddb.tableName}}" + operation: "{{aws.ddb.operation}}" + overrideEndpoint: "{{aws.ddb.overrideEndpoint}}" + uriEndpointOverride: "{{aws.ddb.uriEndpointOverride}}" + accessKey: "{{aws.ddb.accessKey}}" + secretKey: "{{aws.ddb.secretKey}}" + region: "{{aws.ddb.region}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-update-item.citrus.it.yaml.disabled b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-update-item.citrus.it.yaml.disabled index 0765021e8..d00e46924 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-update-item.citrus.it.yaml.disabled +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-update-item.citrus.it.yaml.disabled @@ -26,7 +26,7 @@ variables: - name: "timer.source.period" value: "10000" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -91,7 +91,7 @@ actions: jbang: run: integration: - file: "aws/ddb/aws-ddb-sink-pipe.yaml" + file: "aws/ddb/aws-ddb-sink-route.yaml" systemProperties: properties: - name: "timer.source.period" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-route.yaml similarity index 60% rename from tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.yaml rename to tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-route.yaml index 7155c8c50..d02c29974 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-route.yaml @@ -15,27 +15,19 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-sqs-uri-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-sqs-source - properties: - queueNameOrArn: "{{aws.sqs.queueName}}" - uriEndpointOverride: "{{aws.sqs.uriEndpointOverride}}" - overrideEndpoint: "{{aws.sqs.overrideEndpoint}}" - accessKey: "{{aws.sqs.accessKey}}" - secretKey: "{{aws.sqs.secretKey}}" - region: "{{aws.sqs.region}}" - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-sink - properties: - showHeaders: true +- route: + from: + uri: "kamelet:aws-ddb-streams-source" + parameters: + streamIteratorType: "FROM_START" + table: "{{aws.ddb.tableName}}" + overrideEndpoint: "{{aws.ddb.overrideEndpoint}}" + uriEndpointOverride: "{{aws.ddb.uriEndpointOverride}}" + accessKey: "{{aws.ddb.accessKey}}" + secretKey: "{{aws.ddb.secretKey}}" + region: "{{aws.ddb.region}}" + steps: + - to: + uri: "kamelet:log-sink" + parameters: + showHeaders: true diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source.citrus.it.yaml.disabled b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source.citrus.it.yaml.disabled index a133e36b6..0c309905b 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source.citrus.it.yaml.disabled +++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source.citrus.it.yaml.disabled @@ -30,7 +30,7 @@ variables: - name: "aws.ddb.item.title" value: "Star Wars IV" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -50,7 +50,7 @@ actions: jbang: run: integration: - file: "aws/ddb/aws-ddb-source-pipe.yaml" + file: "aws/ddb/aws-ddb-source-route.yaml" systemProperties: file: "aws/ddb/application.properties" @@ -62,6 +62,6 @@ actions: - camel: jbang: verify: - integration: "aws-ddb-source-pipe" + integration: "aws-ddb-source-route" logMessage: | "Star Wars IV" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink-pipe.yaml deleted file mode 100644 index d73252705..000000000 --- a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink-pipe.yaml +++ /dev/null @@ -1,51 +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. -# --------------------------------------------------------------------------- - -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-eventbridge-sink-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: timer-source - properties: - period: '{{timer.source.period}}' - message: '{{aws.eventbridge.json.data}}' - steps: - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-action - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-eventbridge-sink - properties: - eventbusNameOrArn: '{{aws.eventbridge.eventbusName}}' - overrideEndpoint: '{{aws.eventbridge.overrideEndpoint}}' - uriEndpointOverride: '{{aws.eventbridge.uriEndpointOverride}}' - accessKey: '{{aws.eventbridge.accessKey}}' - secretKey: '{{aws.eventbridge.secretKey}}' - region: '{{aws.eventbridge.region}}' - resourcesArn: '{{aws.eventbridge.resourcesArn}}' - eventSource: '{{aws.eventbridge.eventSource}}' - eventSourcePrefix: '{{aws.eventbridge.eventSourcePrefix}}' - detailType: '{{aws.eventbridge.detailType}}' diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink-route.yaml similarity index 50% rename from tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-pipe.yaml rename to tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink-route.yaml index e473e75a3..76642738c 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink-route.yaml @@ -15,36 +15,26 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-ddb-sink-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: timer-source - properties: - period: "{{timer.source.period}}" - message: "{{aws.ddb.json.data}}" - steps: - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-action - properties: - showHeaders: true - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-ddb-sink - properties: - table: "{{aws.ddb.tableName}}" - operation: "{{aws.ddb.operation}}" - overrideEndpoint: "{{aws.ddb.overrideEndpoint}}" - uriEndpointOverride: "{{aws.ddb.uriEndpointOverride}}" - accessKey: "{{aws.ddb.accessKey}}" - secretKey: "{{aws.ddb.secretKey}}" - region: "{{aws.ddb.region}}" +- route: + from: + uri: "timer:tick" + parameters: + period: "{{timer.source.period}}" + repeatCount: 1 + steps: + - setBody: + constant: "{{aws.eventbridge.json.data}}" + - log: "${body}" + - to: + uri: "kamelet:aws-eventbridge-sink" + parameters: + eventbusNameOrArn: "{{aws.eventbridge.eventbusName}}" + overrideEndpoint: "{{aws.eventbridge.overrideEndpoint}}" + uriEndpointOverride: "{{aws.eventbridge.uriEndpointOverride}}" + accessKey: "{{aws.eventbridge.accessKey}}" + secretKey: "{{aws.eventbridge.secretKey}}" + region: "{{aws.eventbridge.region}}" + resourcesArn: "{{aws.eventbridge.resourcesArn}}" + eventSource: "{{aws.eventbridge.eventSource}}" + eventSourcePrefix: "{{aws.eventbridge.eventSourcePrefix}}" + detailType: "{{aws.eventbridge.detailType}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink.citrus.it.yaml index ae5c09944..cc197dcd0 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-sink.citrus.it.yaml @@ -37,7 +37,7 @@ variables: - name: "timer.source.period" value: "10000" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -59,7 +59,7 @@ actions: jbang: run: integration: - file: "aws/eventbridge/aws-eventbridge-sink-pipe.yaml" + file: "aws/eventbridge/aws-eventbridge-sink-route.yaml" systemProperties: properties: - name: "timer.source.period" @@ -73,7 +73,7 @@ actions: jbang: run: integration: - file: "aws/eventbridge/aws-sqs-event-listener-pipe.yaml" + file: "aws/eventbridge/aws-sqs-event-listener-route.yaml" systemProperties: properties: - name: "aws.sqs.queueName" @@ -84,6 +84,6 @@ actions: - camel: jbang: verify: - integration: "aws-sqs-event-listener-pipe" + integration: "aws-sqs-event-listener-route" logMessage: | "detail":{"message":"Hello AWS EventBridge!"} diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-sqs-event-listener-route.yaml similarity index 59% rename from tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-pipe.yaml rename to tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-sqs-event-listener-route.yaml index f85692cc6..8809635e8 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-sqs-event-listener-route.yaml @@ -15,27 +15,18 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-kinesis-source-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-kinesis-source - properties: - stream: '{{aws.kinesis.streamName}}' - overrideEndpoint: '{{aws.kinesis.overrideEndpoint}}' - uriEndpointOverride: '{{aws.kinesis.uriEndpointOverride}}' - accessKey: '{{aws.kinesis.accessKey}}' - secretKey: '{{aws.kinesis.secretKey}}' - region: '{{aws.kinesis.region}}' - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-sink - properties: - showHeaders: true +- route: + from: + uri: "kamelet:aws-sqs-source" + parameters: + queueNameOrArn: "{{aws.sqs.queueName}}" + uriEndpointOverride: "{{aws.eventbridge.uriEndpointOverride}}" + overrideEndpoint: "{{aws.eventbridge.overrideEndpoint}}" + accessKey: "{{aws.eventbridge.accessKey}}" + secretKey: "{{aws.eventbridge.secretKey}}" + region: "{{aws.eventbridge.region}}" + steps: + - to: + uri: "kamelet:log-sink" + parameters: + showHeaders: true diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-pipe.yaml deleted file mode 100644 index 8de1b46cf..000000000 --- a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-pipe.yaml +++ /dev/null @@ -1,56 +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. -# --------------------------------------------------------------------------- - -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-kinesis-sink-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: timer-source - properties: - period: '{{timer.source.period}}' - message: '{{aws.kinesis.json.data}}' - steps: - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: insert-header-action - properties: - name: "partition" - value: '{{aws.kinesis.partitionKey}}' - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-action - properties: - showHeaders: true - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-kinesis-sink - properties: - stream: '{{aws.kinesis.streamName}}' - overrideEndpoint: '{{aws.kinesis.overrideEndpoint}}' - uriEndpointOverride: '{{aws.kinesis.uriEndpointOverride}}' - accessKey: '{{aws.kinesis.accessKey}}' - secretKey: '{{aws.kinesis.secretKey}}' - region: '{{aws.kinesis.region}}' diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-route.yaml new file mode 100644 index 000000000..81a257282 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-route.yaml @@ -0,0 +1,39 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "timer:tick" + parameters: + period: "{{timer.source.period}}" + repeatCount: 1 + steps: + - setBody: + constant: "{{aws.kinesis.json.data}}" + - setHeader: + name: "partition" + constant: "{{aws.kinesis.partitionKey}}" + - log: "${body}" + - to: + uri: "kamelet:aws-kinesis-sink" + parameters: + stream: "{{aws.kinesis.streamName}}" + overrideEndpoint: "{{aws.kinesis.overrideEndpoint}}" + uriEndpointOverride: "{{aws.kinesis.uriEndpointOverride}}" + accessKey: "{{aws.kinesis.accessKey}}" + secretKey: "{{aws.kinesis.secretKey}}" + region: "{{aws.kinesis.region}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.citrus.it.yaml index 57ab64e0f..01154a846 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.citrus.it.yaml @@ -31,7 +31,7 @@ variables: - name: "timer.source.period" value: "10000" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -52,7 +52,7 @@ actions: jbang: run: integration: - file: "aws/kinesis/aws-kinesis-sink-pipe.yaml" + file: "aws/kinesis/aws-kinesis-sink-route.yaml" systemProperties: properties: - name: "timer.source.period" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-route.yaml similarity index 58% rename from tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-pipe.yaml rename to tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-route.yaml index 3d25229c4..951b20efd 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-route.yaml @@ -15,28 +15,18 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-ddb-source-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-ddb-streams-source - properties: - streamIteratorType: FROM_START - table: "{{aws.ddb.tableName}}" - overrideEndpoint: "{{aws.ddb.overrideEndpoint}}" - uriEndpointOverride: "{{aws.ddb.uriEndpointOverride}}" - accessKey: "{{aws.ddb.accessKey}}" - secretKey: "{{aws.ddb.secretKey}}" - region: "{{aws.ddb.region}}" - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-sink - properties: - showHeaders: true +- route: + from: + uri: "kamelet:aws-kinesis-source" + parameters: + stream: "{{aws.kinesis.streamName}}" + overrideEndpoint: "{{aws.kinesis.overrideEndpoint}}" + uriEndpointOverride: "{{aws.kinesis.uriEndpointOverride}}" + accessKey: "{{aws.kinesis.accessKey}}" + secretKey: "{{aws.kinesis.secretKey}}" + region: "{{aws.kinesis.region}}" + steps: + - to: + uri: "kamelet:log-sink" + parameters: + showHeaders: true diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.citrus.it.yaml index 457ab1794..0ef1ce273 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.citrus.it.yaml @@ -24,7 +24,7 @@ variables: - name: "aws.kinesis.streamData" value: "Camel rocks!" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -45,7 +45,7 @@ actions: jbang: run: integration: - file: "aws/kinesis/aws-kinesis-source-pipe.yaml" + file: "aws/kinesis/aws-kinesis-source-route.yaml" systemProperties: file: "aws/kinesis/application.properties" @@ -63,5 +63,5 @@ actions: - camel: jbang: verify: - integration: "aws-kinesis-source-pipe" + integration: "aws-kinesis-source-route" logMessage: "${aws.kinesis.streamData}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/README.md b/tests/camel-kamelets-itest/src/test/resources/aws/s3/README.md index b5e8f53f0..5285d55b1 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/README.md +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/README.md @@ -7,7 +7,7 @@ This test verifies the AWS S3 Kamelet source defined in [aws-s3-source.kamelet.y The test verifies the AWS S3 Kamelet source by creating a Camel K integration that uses the Kamelet and listens for messages on the AWS S3 bucket. -The test uses a [LocalStack Testcontainers](https://www.testcontainers.org/modules/localstack/) instance to start a local AWS S3 service for mocking reasons. +The test uses a [Testcontainers](https://www.testcontainers.org/modules/localstack/) instance to start a local AWS S3 service for mocking reasons. The Kamelet and the test interact with the local AWS S3 service for validation of functionality. ### Test Kamelet source @@ -15,7 +15,7 @@ The Kamelet and the test interact with the local AWS S3 service for validation o The test performs the following high level steps for configs - URI, secret and property based: *Preparation* -- Start the AWS S3 service as LocalStack container +- Start the AWS S3 service as Testcontainers container - Overwrite the Kamelet with the latest source - Prepare the Camel AWS S3 client @@ -27,7 +27,7 @@ The test performs the following high level steps for configs - URI, secret and p - Verify that the integration has received the message event *Cleanup* -- Stop the LocalStack container +- Stop the Testcontainers container - Delete the Camel K integration - Delete the secret from the current namespacce diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-sink-route.citrus.it.yaml new file mode 100644 index 000000000..f33d2bbe0 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-sink-route.citrus.it.yaml @@ -0,0 +1,67 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +name: aws-s3-sink-route-test +variables: + - name: "aws.s3.bucketNameOrArn" + value: "sink-bucket" + - name: "aws.s3.key" + value: "test-sink.txt" + - name: "test.message" + value: "Hello from S3 sink test" +actions: + # Create AWS infrastructure (Floci container) + - testcontainers: + start: + localstack: + services: + - "S3" + - waitFor: + http: + url: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + + # Create AWS-S3 client + - camel: + createComponent: + name: amazonS3Client + file: "aws/s3/amazonS3Client.groovy" + + # Create Camel JBang integration + - camel: + jbang: + run: + integration: + file: "aws/s3/aws-s3-sink-route.yaml" + systemProperties: + file: "aws/s3/application.properties" + properties: + - name: "test.message" + value: "${test.message}" + - name: "aws.s3.key" + value: "${aws.s3.key}" + + # Verify S3 sink wrote the object + - camel: + jbang: + verify: + integration: "aws-s3-sink-route" + logMessage: "${test.message}" + + # Verify object exists in S3 by reading it back + - groovy: + script: + file: "aws/s3/getS3Object.groovy" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-sink-route.yaml similarity index 58% rename from tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.yaml rename to tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-sink-route.yaml index 70a998636..67b08ab95 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-sink-route.yaml @@ -15,28 +15,23 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-s3-uri-pipe -spec: - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-s3-source - properties: - bucketNameOrArn: "{{aws.s3.bucketNameOrArn}}" - uriEndpointOverride: "{{aws.s3.uriEndpointOverride}}" - overrideEndpoint: "{{aws.s3.overrideEndpoint}}" - forcePathStyle: "{{aws.s3.forcePathStyle}}" - accessKey: "{{aws.s3.accessKey}}" - secretKey: "{{aws.s3.secretKey}}" - region: "{{aws.s3.region}}" - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-sink - properties: - showHeaders: true +- route: + from: + uri: "timer:tick" + parameters: + period: "10000" + repeatCount: 1 + steps: + - setBody: + constant: "{{test.message}}" + - to: + uri: "kamelet:aws-s3-sink" + parameters: + bucketNameOrArn: "{{aws.s3.bucketNameOrArn}}" + accessKey: "{{aws.s3.accessKey}}" + secretKey: "{{aws.s3.secretKey}}" + region: "{{aws.s3.region}}" + overrideEndpoint: "{{aws.s3.overrideEndpoint}}" + uriEndpointOverride: "{{aws.s3.uriEndpointOverride}}" + forcePathStyle: "{{aws.s3.forcePathStyle}}" + keyName: "{{aws.s3.key}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-source-route.yaml new file mode 100644 index 000000000..5ffc1f0ea --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-source-route.yaml @@ -0,0 +1,33 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:aws-s3-source" + parameters: + bucketNameOrArn: "{{aws.s3.bucketNameOrArn}}" + uriEndpointOverride: "{{aws.s3.uriEndpointOverride}}" + overrideEndpoint: "{{aws.s3.overrideEndpoint}}" + forcePathStyle: "{{aws.s3.forcePathStyle}}" + accessKey: "{{aws.s3.accessKey}}" + secretKey: "{{aws.s3.secretKey}}" + region: "{{aws.s3.region}}" + steps: + - to: + uri: "kamelet:log-sink" + parameters: + showHeaders: true diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-source-to-http-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-source-to-http-route.yaml new file mode 100644 index 000000000..39e60ad9a --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-source-to-http-route.yaml @@ -0,0 +1,54 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:aws-s3-source" + parameters: + bucketNameOrArn: "{{aws.s3.bucketNameOrArn}}" + uriEndpointOverride: "{{aws.s3.uriEndpointOverride}}" + overrideEndpoint: "{{aws.s3.overrideEndpoint}}" + forcePathStyle: "{{aws.s3.forcePathStyle}}" + accessKey: "{{aws.s3.accessKey}}" + secretKey: "{{aws.s3.secretKey}}" + region: "{{aws.s3.region}}" + steps: + - to: + uri: "kamelet:data-type-action" + parameters: + scheme: "aws2-s3" + format: "application-cloudevents" + - to: + uri: "kamelet:data-type-action" + parameters: + scheme: "http" + format: "application-cloudevents" + - to: + uri: "kamelet:data-type-action" + parameters: + scheme: "text" + format: "plain" + - removeHeaders: + pattern: "Camel*" + - to: + uri: "kamelet:log-sink" + parameters: + showHeaders: true + - to: + uri: "kamelet:http-sink" + parameters: + url: "{{http.sink.url}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.citrus.it.yaml index 13f815e8e..58531f373 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.citrus.it.yaml @@ -24,7 +24,7 @@ variables: - name: "aws.s3.key" value: "hello.txt" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -45,7 +45,7 @@ actions: jbang: run: integration: - file: "aws/s3/aws-s3-to-http.yaml" + file: "aws/s3/aws-s3-source-to-http-route.yaml" systemProperties: file: "aws/s3/application.properties" properties: @@ -89,5 +89,5 @@ actions: - camel: jbang: verify: - integration: "aws-s3-to-http" + integration: "aws-s3-source-to-http-route" logMessage: "${aws.s3.message}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.yaml deleted file mode 100644 index 70ddfcc21..000000000 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.yaml +++ /dev/null @@ -1,79 +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. -# --------------------------------------------------------------------------- - -apiVersion: camel.apache.org/v1 -kind: Pipe -metadata: - name: aws-s3-to-http -spec: - integration: - dependencies: - - "camel:cloudevents" - source: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: aws-s3-source - properties: - bucketNameOrArn: "{{aws.s3.bucketNameOrArn}}" - uriEndpointOverride: "{{aws.s3.uriEndpointOverride}}" - overrideEndpoint: "{{aws.s3.overrideEndpoint}}" - forcePathStyle: "{{aws.s3.forcePathStyle}}" - accessKey: "{{aws.s3.accessKey}}" - secretKey: "{{aws.s3.secretKey}}" - region: "{{aws.s3.region}}" - steps: - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: data-type-action - properties: - scheme: "aws2-s3" - format: "application-cloudevents" - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: data-type-action - properties: - scheme: "http" - format: "application-cloudevents" - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: data-type-action - properties: - scheme: "text" - format: "plain" - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: drop-headers-action - properties: - pattern: "Camel*" - - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: log-sink - properties: - showHeaders: true - sink: - ref: - kind: Kamelet - apiVersion: camel.apache.org/v1 - name: http-sink - properties: - url: "{{http.sink.url}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-log-uri-based.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-log-uri-based.citrus.it.yaml index fcdc5127b..a78d56024 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-log-uri-based.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-log-uri-based.citrus.it.yaml @@ -24,7 +24,7 @@ variables: - name: "aws.s3.key" value: "hello.txt" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.citrus.it.yaml index fc63613f2..1a70bbcab 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-uri-pipe.citrus.it.yaml @@ -24,7 +24,7 @@ variables: - name: "aws.s3.key" value: "hello.txt" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -45,7 +45,7 @@ actions: jbang: run: integration: - file: "aws/s3/aws-s3-uri-pipe.yaml" + file: "aws/s3/aws-s3-source-route.yaml" systemProperties: properties: - name: "aws.s3.bucketNameOrArn" @@ -77,5 +77,5 @@ actions: - camel: jbang: verify: - integration: "aws-s3-uri-pipe" + integration: "aws-s3-source-route" logMessage: "${aws.s3.message}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/getS3Object.groovy b/tests/camel-kamelets-itest/src/test/resources/aws/s3/getS3Object.groovy new file mode 100644 index 000000000..5b6a482ec --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/getS3Object.groovy @@ -0,0 +1,42 @@ +/* + * 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. + */ + +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.s3.S3Client +import software.amazon.awssdk.services.s3.model.GetObjectRequest + +S3Client s3 = S3Client + .builder() + .endpointOverride(URI.create('${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}')) + .credentialsProvider(StaticCredentialsProvider.create( + AwsBasicCredentials.create( + '${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}', + '${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}') + )) + .forcePathStyle(true) + .region(Region.of('${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}')) + .build() + +def response = s3.getObjectAsBytes(GetObjectRequest.builder() + .bucket('${aws.s3.bucketNameOrArn}') + .key('${aws.s3.key}') + .build()) + +String content = response.asUtf8String() +assert content == '${test.message}' : "Expected '${test.message}' but got '" + content + "'" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sns-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sns-sink-route.citrus.it.yaml new file mode 100644 index 000000000..8d3f69e9b --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sns-sink-route.citrus.it.yaml @@ -0,0 +1,92 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +name: aws-sns-sink-route-test +variables: + - name: "aws.sns.topicName" + value: "sns-test-topic" + - name: "aws.sqs.queueName" + value: "sns-test-queue" + - name: "test.message" + value: "Hello from SNS sink test" +actions: + # Create AWS infrastructure (Floci container) + - testcontainers: + start: + localstack: + services: + - "SNS" + - "SQS" + - waitFor: + http: + url: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + + # Create SNS topic, SQS queue, and subscribe SQS to SNS + - groovy: + script: + file: "aws/sns/setupSnsToSqs.groovy" + + # Create Camel JBang integration for the SNS sink + - camel: + jbang: + run: + integration: + file: "aws/sns/aws-sns-sink-route.yaml" + systemProperties: + properties: + - name: "test.message" + value: "${test.message}" + - name: "aws.sns.topicName" + value: "${aws.sns.topicName}" + - name: "aws.sns.uriEndpointOverride" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + - name: "aws.sns.overrideEndpoint" + value: "true" + - name: "aws.sns.secretKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}" + - name: "aws.sns.accessKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}" + - name: "aws.sns.region" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}" + + # Create event listener to consume the message forwarded from SNS to SQS + - camel: + jbang: + run: + integration: + file: "aws/sns/aws-sqs-sns-event-listener.yaml" + systemProperties: + properties: + - name: "aws.sqs.queueName" + value: "${aws.sqs.queueName}" + - name: "aws.sqs.uriEndpointOverride" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + - name: "aws.sqs.overrideEndpoint" + value: "true" + - name: "aws.sqs.secretKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}" + - name: "aws.sqs.accessKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}" + - name: "aws.sqs.region" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}" + + # Verify message received by the SQS listener + - camel: + jbang: + verify: + integration: "aws-sqs-sns-event-listener" + logMessage: "${test.message}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sns-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sns-sink-route.yaml new file mode 100644 index 000000000..913cabd64 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sns-sink-route.yaml @@ -0,0 +1,36 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "timer:tick" + parameters: + period: "10000" + repeatCount: 1 + steps: + - setBody: + constant: "{{test.message}}" + - to: + uri: "kamelet:aws-sns-sink" + parameters: + topicNameOrArn: "{{aws.sns.topicName}}" + accessKey: "{{aws.sns.accessKey}}" + secretKey: "{{aws.sns.secretKey}}" + region: "{{aws.sns.region}}" + overrideEndpoint: "{{aws.sns.overrideEndpoint}}" + uriEndpointOverride: "{{aws.sns.uriEndpointOverride}}" + autoCreateTopic: "true" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sqs-sns-event-listener.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sqs-sns-event-listener.yaml new file mode 100644 index 000000000..0ba9d0c7c --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sns/aws-sqs-sns-event-listener.yaml @@ -0,0 +1,29 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "aws2-sqs:{{aws.sqs.queueName}}" + parameters: + accessKey: "{{aws.sqs.accessKey}}" + secretKey: "{{aws.sqs.secretKey}}" + region: "{{aws.sqs.region}}" + overrideEndpoint: "{{aws.sqs.overrideEndpoint}}" + uriEndpointOverride: "{{aws.sqs.uriEndpointOverride}}" + steps: + - to: + uri: "log:aws-sqs-sns-event-listener" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sns/setupSnsToSqs.groovy b/tests/camel-kamelets-itest/src/test/resources/aws/sns/setupSnsToSqs.groovy new file mode 100644 index 000000000..3e953f125 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sns/setupSnsToSqs.groovy @@ -0,0 +1,53 @@ +/* + * 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. + */ + +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.sns.SnsClient +import software.amazon.awssdk.services.sqs.SqsClient +import software.amazon.awssdk.services.sqs.model.QueueAttributeName + +def credentials = StaticCredentialsProvider.create( + AwsBasicCredentials.create( + '${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}', + '${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}')) + +def region = Region.of('${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}') +def endpoint = URI.create('${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}') + +SnsClient snsClient = SnsClient.builder() + .endpointOverride(endpoint) + .credentialsProvider(credentials) + .region(region) + .build() + +SqsClient sqsClient = SqsClient.builder() + .endpointOverride(endpoint) + .credentialsProvider(credentials) + .region(region) + .build() + +def topicArn = snsClient.createTopic(b -> b.name('${aws.sns.topicName}')).topicArn() + +def queueUrl = sqsClient.createQueue(b -> b.queueName('${aws.sqs.queueName}')).queueUrl() +def queueArn = sqsClient.getQueueAttributes(b -> b.queueUrl(queueUrl) + .attributeNames(QueueAttributeName.QUEUE_ARN)) + .attributes().get(QueueAttributeName.QUEUE_ARN) + +snsClient.subscribe(b -> b.topicArn(topicArn).protocol("sqs").endpoint(queueArn) + .attributes(Collections.singletonMap("RawMessageDelivery", "true"))) diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/README.md b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/README.md index 974dc5114..0b2351757 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/README.md +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/README.md @@ -7,7 +7,7 @@ This test verifies the AWS SQS Kamelet source defined in [aws-sqs-source.kamelet The test verifies the AWS SQS Kamelet source by creating a Camel K integration that uses the Kamelet and listens for messages on the AWS SQS channel. -The test uses a [LocalStack Testcontainers](https://www.testcontainers.org/modules/localstack/) instance to start a local AWS SQS service for mocking reasons. +The test uses a [Testcontainers](https://www.testcontainers.org/modules/localstack/) instance to start a local AWS SQS service for mocking reasons. The Kamelet and the test interact with the local AWS SQS service for validation of functionality. ### Test Kamelet source @@ -15,7 +15,7 @@ The Kamelet and the test interact with the local AWS SQS service for validation The test performs the following high level steps for configs - URI, secret and property based: *Preparation* -- Start the AWS SQS service as LocalStack container +- Start the AWS SQS service as Testcontainers container - Overwrite the Kamelet with the latest source - Prepare the Camel AWS SQS client @@ -27,7 +27,7 @@ The test performs the following high level steps for configs - URI, secret and p - Verify that the integration has received the message event *Cleanup* -- Stop the LocalStack container +- Stop the Testcontainers container - Delete the Camel K integration - Delete the secret from the current namespacce diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-event-listener.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-event-listener.yaml new file mode 100644 index 000000000..da26e400c --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-event-listener.yaml @@ -0,0 +1,29 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "aws2-sqs:{{aws.sqs.queueName}}" + parameters: + accessKey: "{{aws.sqs.accessKey}}" + secretKey: "{{aws.sqs.secretKey}}" + region: "{{aws.sqs.region}}" + overrideEndpoint: "{{aws.sqs.overrideEndpoint}}" + uriEndpointOverride: "{{aws.sqs.uriEndpointOverride}}" + steps: + - to: + uri: "log:aws-sqs-sink-event-listener" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-route.citrus.it.yaml new file mode 100644 index 000000000..51c27f994 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-route.citrus.it.yaml @@ -0,0 +1,90 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +name: aws-sqs-sink-route-test +variables: + - name: "aws.sqs.queueName" + value: "sink-queue" + - name: "test.message" + value: "Hello from SQS sink test" +actions: + # Create AWS infrastructure (Floci container) + - testcontainers: + start: + localstack: + services: + - "SQS" + - waitFor: + http: + url: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + + # Create AWS-SQS client + - camel: + createComponent: + name: amazonSQSClient + file: "aws/sqs/amazonSQSClient.groovy" + + # Create Camel JBang integration + - camel: + jbang: + run: + integration: + file: "aws/sqs/aws-sqs-sink-route.yaml" + systemProperties: + properties: + - name: "test.message" + value: "${test.message}" + - name: "aws.sqs.queueName" + value: "${aws.sqs.queueName}" + - name: "aws.sqs.uriEndpointOverride" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + - name: "aws.sqs.overrideEndpoint" + value: "true" + - name: "aws.sqs.secretKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}" + - name: "aws.sqs.accessKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}" + - name: "aws.sqs.region" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}" + + # Create event listener to consume the message from SQS + - camel: + jbang: + run: + integration: + file: "aws/sqs/aws-sqs-sink-event-listener.yaml" + systemProperties: + properties: + - name: "aws.sqs.queueName" + value: "${aws.sqs.queueName}" + - name: "aws.sqs.uriEndpointOverride" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}" + - name: "aws.sqs.overrideEndpoint" + value: "true" + - name: "aws.sqs.secretKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}" + - name: "aws.sqs.accessKey" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}" + - name: "aws.sqs.region" + value: "${CITRUS_TESTCONTAINERS_LOCALSTACK_REGION}" + + # Verify message received by the listener + - camel: + jbang: + verify: + integration: "aws-sqs-sink-event-listener" + logMessage: "${test.message}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-route.yaml new file mode 100644 index 000000000..62c3e4418 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-sink-route.yaml @@ -0,0 +1,36 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "timer:tick" + parameters: + period: "10000" + repeatCount: 1 + steps: + - setBody: + constant: "{{test.message}}" + - to: + uri: "kamelet:aws-sqs-sink" + parameters: + queueNameOrArn: "{{aws.sqs.queueName}}" + accessKey: "{{aws.sqs.accessKey}}" + secretKey: "{{aws.sqs.secretKey}}" + region: "{{aws.sqs.region}}" + overrideEndpoint: "{{aws.sqs.overrideEndpoint}}" + uriEndpointOverride: "{{aws.sqs.uriEndpointOverride}}" + autoCreateQueue: "true" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-source-route.yaml new file mode 100644 index 000000000..0313cd426 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-source-route.yaml @@ -0,0 +1,32 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:aws-sqs-source" + parameters: + queueNameOrArn: "{{aws.sqs.queueName}}" + uriEndpointOverride: "{{aws.sqs.uriEndpointOverride}}" + overrideEndpoint: "{{aws.sqs.overrideEndpoint}}" + accessKey: "{{aws.sqs.accessKey}}" + secretKey: "{{aws.sqs.secretKey}}" + region: "{{aws.sqs.region}}" + steps: + - to: + uri: "kamelet:log-sink" + parameters: + showHeaders: true diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-to-log-uri-based.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-to-log-uri-based.citrus.it.yaml index 7466bc6c1..2c95af6f8 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-to-log-uri-based.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-to-log-uri-based.citrus.it.yaml @@ -22,7 +22,7 @@ variables: - name: "aws.sqs.message" value: "Hello from SQS Kamelet" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.citrus.it.yaml index 90e944650..83385e3d4 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.citrus.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-uri-pipe.citrus.it.yaml @@ -22,7 +22,7 @@ variables: - name: "aws.sqs.message" value: "Hello from SQS Kamelet" actions: - # Create LocalStack infrastructure + # Create AWS infrastructure (Floci container) - testcontainers: start: localstack: @@ -43,7 +43,7 @@ actions: jbang: run: integration: - file: "aws/sqs/aws-sqs-uri-pipe.yaml" + file: "aws/sqs/aws-sqs-source-route.yaml" systemProperties: properties: - name: "aws.sqs.queueName" @@ -70,5 +70,5 @@ actions: - camel: jbang: verify: - integration: "aws-sqs-uri-pipe" + integration: "aws-sqs-source-route" logMessage: "${aws.sqs.message}"