You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cd...@apache.org on 2024/04/30 06:24:19 UTC
(camel-kamelets) branch 4.4.x updated: chore: Add AWS Kinesis Kamelet tests
This is an automated email from the ASF dual-hosted git repository.
cdeppisch pushed a commit to branch 4.4.x
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/4.4.x by this push:
new 0f50a4a9 chore: Add AWS Kinesis Kamelet tests
0f50a4a9 is described below
commit 0f50a4a9c7fa6e7297846a3eeb4c4bdd3c5e103b
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Mon Apr 29 17:07:31 2024 +0200
chore: Add AWS Kinesis Kamelet tests
(cherry picked from commit b468cd6e8eac9031f63e83e3ed96842c6d0c1c89)
---
tests/camel-kamelets-itest/pom.xml | 6 +++
.../test/resources/aws/ddb/amazonDDBClient.groovy | 3 +-
.../test/resources/aws/ddb/aws-ddb-sink-pipe.yaml | 4 +-
.../aws/ddb/aws-ddb-source-getItem.feature | 1 +
.../resources/aws/ddb/aws-ddb-source-pipe.yaml | 4 +-
.../aws/kinesis/amazonKinesisClient.groovy | 38 ++++++++++++++
.../aws-kinesis-sink-pipe.yaml} | 24 +++++----
.../resources/aws/kinesis/aws-kinesis-sink.feature | 58 +++++++++++++++++++++
.../aws-kinesis-source-pipe.yaml} | 9 ++--
.../aws-kinesis-source.feature} | 37 ++++++-------
.../test/resources/aws/kinesis/yaks-config.yaml | 60 ++++++++++++++++++++++
11 files changed, 205 insertions(+), 39 deletions(-)
diff --git a/tests/camel-kamelets-itest/pom.xml b/tests/camel-kamelets-itest/pom.xml
index 381e05ea..49ae7eaf 100644
--- a/tests/camel-kamelets-itest/pom.xml
+++ b/tests/camel-kamelets-itest/pom.xml
@@ -96,6 +96,12 @@
<version>${camel.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-aws2-kinesis</artifactId>
+ <version>${camel.version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- Citrus -->
<dependency>
diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/amazonDDBClient.groovy b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/amazonDDBClient.groovy
index 5c1d7ef1..e471a9e8 100644
--- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/amazonDDBClient.groovy
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/amazonDDBClient.groovy
@@ -1,4 +1,3 @@
-package aws.ddb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -16,6 +15,8 @@ package aws.ddb
* limitations under the License.
*/
+package aws.ddb
+
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.regions.Region
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/ddb/aws-ddb-sink-pipe.yaml
index 91fcfe12..71136f54 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/ddb/aws-ddb-sink-pipe.yaml
@@ -33,8 +33,8 @@ spec:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-action
- properties:
- showHeaders: true
+ properties:
+ showHeaders: true
sink:
ref:
kind: Kamelet
diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature
index 51db8cf7..8f8b51c4 100644
--- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature
@@ -42,6 +42,7 @@ Feature: AWS DDB Source - GetItem
And Camel K integration aws-ddb-source-pipe should print Started aws-ddb-source-pipe
# Create item on AWS-DDB
Given run script putItem.groovy
+ # Verify event
And Camel K integration aws-ddb-source-pipe should print Star Wars IV
Scenario: Remove resources
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/ddb/aws-ddb-source-pipe.yaml
index 3dccb80e..3414147d 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/ddb/aws-ddb-source-pipe.yaml
@@ -38,5 +38,5 @@ spec:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-sink
- properties:
- showHeaders: true
+ properties:
+ showHeaders: true
diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy
new file mode 100644
index 00000000..17013bff
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy
@@ -0,0 +1,38 @@
+/*
+ * 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 aws.kinesis
+
+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.kinesis.KinesisClient
+
+KinesisClient kinesisClient = KinesisClient
+ .builder()
+ .endpointOverride(URI.create("${YAKS_TESTCONTAINERS_LOCALSTACK_KINESIS_LOCAL_URL}"))
+ .credentialsProvider(StaticCredentialsProvider.create(
+ AwsBasicCredentials.create(
+ "${YAKS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}",
+ "${YAKS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}")
+ ))
+ .region(Region.of("${YAKS_TESTCONTAINERS_LOCALSTACK_REGION}"))
+ .build()
+
+kinesisClient.createStream(s -> s.streamName("${aws.kinesis.streamName}").shardCount(1))
+
+return kinesisClient
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/kinesis/aws-kinesis-sink-pipe.yaml
similarity index 75%
copy from tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-sink-pipe.yaml
copy to tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink-pipe.yaml
index 91fcfe12..7b2584c4 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/kinesis/aws-kinesis-sink-pipe.yaml
@@ -18,7 +18,7 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
- name: aws-ddb-sink-pipe
+ name: aws-kinesis-sink-pipe
spec:
source:
ref:
@@ -26,25 +26,31 @@ spec:
apiVersion: camel.apache.org/v1
name: timer-source
properties:
- period: ${timer.source.period}
- message: '${aws.ddb.json.data}'
+ 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
+ properties:
+ showHeaders: true
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
- name: aws-ddb-sink
+ name: aws-kinesis-sink
properties:
- table: ${aws.ddb.tableName}
- operation: ${aws.ddb.operation}
+ stream: '${aws.kinesis.streamName}'
overrideEndpoint: true
- uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_DYNAMODB_LOCAL_URL}
+ uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_KINESIS_LOCAL_URL}
accessKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}
secretKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}
region: ${YAKS_TESTCONTAINERS_LOCALSTACK_REGION}
diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.feature b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.feature
new file mode 100644
index 00000000..b1d64f83
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-sink.feature
@@ -0,0 +1,58 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+Feature: AWS Kinesis - Sink
+
+ Background:
+ Given variables
+ | timer.source.period | 10000 |
+ | aws.kinesis.streamName | mystream |
+ | aws.kinesis.partitionKey | partition-1 |
+ | aws.kinesis.message | Camel rocks! |
+ | aws.kinesis.json.data | { "message":"${aws.kinesis.message}" } |
+
+ Scenario: Create infrastructure
+ # Start LocalStack container
+ Given Enable service KINESIS
+ Given start LocalStack container
+
+ Scenario: Verify Kinesis events
+ # Create AWS-KINESIS client
+ Given load to Camel registry amazonKinesisClient.groovy
+ # Create binding
+ When load Pipe aws-kinesis-sink-pipe.yaml
+ And Pipe aws-kinesis-sink-pipe is available
+ And Camel K integration aws-kinesis-sink-pipe is running
+ And Camel K integration aws-kinesis-sink-pipe should print Started aws-kinesis-sink-pipe
+ # Create vent listener
+ Given Camel route eventListener.groovy
+ """
+ from("aws2-kinesis://${aws.kinesis.streamName}?amazonKinesisClient=#amazonKinesisClient")
+ .convertBodyTo(String.class)
+ .to("seda:result")
+ """
+ # Verify event
+ Given Camel exchange message header CamelAwsKinesisPartitionKey="${aws.kinesis.partitionKey}"
+ Then receive Camel exchange from("seda:result") with body: ${aws.kinesis.json.data}
+
+ Scenario: Remove resources
+ # Remove Camel K binding
+ Given delete Pipe aws-kinesis-sink-pipe
+ # Stop event listener
+ Given stop Camel route kinesisEventListener
+ # Stop LocalStack container
+ Given stop LocalStack container
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-pipe.yaml
similarity index 87%
copy from tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-pipe.yaml
copy to tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source-pipe.yaml
index 3dccb80e..5ed67cf4 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-pipe.yaml
@@ -18,18 +18,17 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
- name: aws-ddb-source-pipe
+ name: aws-kinesis-source-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
- name: aws-ddb-streams-source
+ name: aws-kinesis-source
properties:
- table: ${aws.ddb.tableName}
- streamIteratorType: FROM_START
+ stream: ${aws.kinesis.streamName}
overrideEndpoint: true
- uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_DYNAMODB_LOCAL_URL}
+ uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_KINESIS_LOCAL_URL}
accessKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}
secretKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}
region: ${YAKS_TESTCONTAINERS_LOCALSTACK_REGION}
diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.feature
similarity index 56%
copy from tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature
copy to tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.feature
index 51db8cf7..09a98d25 100644
--- a/tests/camel-kamelets-itest/src/test/resources/aws/ddb/aws-ddb-source-getItem.feature
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/aws-kinesis-source.feature
@@ -15,37 +15,34 @@
# limitations under the License.
# ---------------------------------------------------------------------------
-Feature: AWS DDB Source - GetItem
+Feature: AWS Kinesis - Sink
Background:
Given variables
- | maxRetryAttempts | 20 |
- | timer.source.period | 10000 |
- | aws.ddb.streams | true |
- | aws.ddb.tableName | movies |
- | aws.ddb.item.id | 1 |
- | aws.ddb.item.year | 1977 |
- | aws.ddb.item.title | Star Wars IV |
+ | aws.kinesis.streamName | mystream |
+ | aws.kinesis.partitionKey | partition-1 |
Scenario: Create infrastructure
# Start LocalStack container
- Given Enable service DYNAMODB
+ Given Enable service KINESIS
Given start LocalStack container
- Scenario: Verify AWS-DDB Kamelet source binding
- # Create AWS-DDB client
- Given load to Camel registry amazonDDBClient.groovy
+ Scenario: Verify Kinesis events
+ # Create AWS-KINESIS client
+ Given load to Camel registry amazonKinesisClient.groovy
# Create binding
- When load Pipe aws-ddb-source-pipe.yaml
- And Pipe aws-ddb-source-pipe is available
- And Camel K integration aws-ddb-source-pipe is running
- And Camel K integration aws-ddb-source-pipe should print Started aws-ddb-source-pipe
- # Create item on AWS-DDB
- Given run script putItem.groovy
- And Camel K integration aws-ddb-source-pipe should print Star Wars IV
+ When load Pipe aws-kinesis-source-pipe.yaml
+ And Pipe aws-kinesis-source-pipe is available
+ And Camel K integration aws-kinesis-source-pipe is running
+ And Camel K integration aws-kinesis-source-pipe should print Started aws-kinesis-source-pipe
+ # Publish event
+ Given Camel exchange message header CamelAwsKinesisPartitionKey="${aws.kinesis.partitionKey}"
+ Given send Camel exchange to("aws2-kinesis://${aws.kinesis.streamName}?amazonKinesisClient=#amazonKinesisClient") with body: Camel rocks!
+ # Verify event
+ And Camel K integration aws-kinesis-source-pipe should print Camel rocks!
Scenario: Remove resources
# Remove Camel K binding
- Given delete Pipe aws-ddb-source-pipe
+ Given delete Pipe aws-kinesis-source-pipe
# Stop LocalStack container
Given stop LocalStack container
diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/yaks-config.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/yaks-config.yaml
new file mode 100644
index 00000000..a35c0447
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/yaks-config.yaml
@@ -0,0 +1,60 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+config:
+ namespace:
+ temporary: false
+ runtime:
+ testcontainers:
+ enabled: true
+ env:
+ - name: YAKS_CAMEL_AUTO_REMOVE_RESOURCES
+ value: false
+ - name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
+ value: false
+ - name: YAKS_KAMELETS_AUTO_REMOVE_RESOURCES
+ value: false
+ - name: YAKS_JBANG_CAMEL_DUMP_INTEGRATION_OUTPUT
+ value: true
+ - name: YAKS_TESTCONTAINERS_AUTO_REMOVE_RESOURCES
+ value: false
+ - name: CITRUS_TYPE_CONVERTER
+ value: camel
+ resources:
+ - amazonKinesisClient.groovy
+ - aws-kinesis-source-pipe.yaml
+ cucumber:
+ tags:
+ - "not @ignored"
+ settings:
+ loggers:
+ - name: INTEGRATION_STATUS
+ level: INFO
+ - name: INTEGRATION_LOGS
+ level: INFO
+ dependencies:
+ - groupId: org.apache.camel
+ artifactId: camel-aws2-kinesis
+ version: "@camel.version@"
+ - groupId: software.amazon.awssdk
+ artifactId: kinesis
+ version: "@aws-java-sdk2.version@"
+ dump:
+ enabled: true
+ failedOnly: true
+ includes:
+ - app=camel-k