-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e): Add AWS SQS Kamelet tests (#2026)
- Loading branch information
1 parent
5b96031
commit 1d0f4f1
Showing
19 changed files
with
517 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
tests/camel-kamelets-itest/src/test/resources/aws/sqs/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# AWS SQS Kamelet test | ||
|
||
This test verifies the AWS SQS Kamelet source defined in [aws-sqs-source.kamelet.yaml](aws-sqs-source.kamelet.yaml) | ||
|
||
## Objectives | ||
|
||
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 Kamelet and the test interact with the local AWS SQS service for validation of functionality. | ||
|
||
### Test Kamelet source | ||
|
||
The test performs the following high level steps for configs - URI, secret and property based: | ||
|
||
*Preparation* | ||
- Start the AWS SQS service as LocalStack container | ||
- Overwrite the Kamelet with the latest source | ||
- Prepare the Camel AWS SQS client | ||
|
||
*Scenario* | ||
- Create the Kamelet in the current namespace in the cluster | ||
- Create the Camel K integration that uses the Kamelet source to consume data from AWS SQS service | ||
- Wait for the Camel K integration to start and listen for AWS SQS messages | ||
- Create a new message in the AWS SQS queue | ||
- Verify that the integration has received the message event | ||
|
||
*Cleanup* | ||
- Stop the LocalStack container | ||
- Delete the Camel K integration | ||
- Delete the secret from the current namespacce | ||
|
||
## Installation | ||
|
||
The test assumes that you have access to a Kubernetes cluster and that the Camel K operator as well as the YAKS operator is installed | ||
and running. | ||
|
||
You can review the installation steps for the operators in the documentation: | ||
|
||
- [Install Camel K operator](https://camel.apache.org/camel-k/latest/installation/installation.html) | ||
- [Install YAKS operator](https://github.com/citrusframework/yaks#installation) | ||
|
||
## Run the tests | ||
|
||
To run tests with URI based configuration: | ||
|
||
```shell script | ||
$ yaks test aws-sqs-source-uri-conf.feature | ||
``` | ||
|
||
To run tests with secret based configuration: | ||
|
||
```shell script | ||
$ yaks test aws-sqs-source-secret-conf.feature | ||
``` | ||
|
||
To run tests with property based configuration: | ||
|
||
```shell script | ||
$ yaks test aws-sqs-source-property-conf.feature | ||
``` | ||
|
||
To run tests with URI binding: | ||
|
||
```shell script | ||
$ yaks test aws-sqs-uri-pipe.feature | ||
``` | ||
|
||
To run tests with binding to Knative channel: | ||
|
||
```shell script | ||
$ yaks test aws-sqs-knative-channel.feature | ||
``` | ||
|
||
You will be provided with the test log output and the test results. |
38 changes: 38 additions & 0 deletions
38
tests/camel-kamelets-itest/src/test/resources/aws/sqs/amazonSQSClient.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.sqs | ||
|
||
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.sqs.SqsClient | ||
|
||
SqsClient sqsClient = SqsClient | ||
.builder() | ||
.endpointOverride(URI.create("${YAKS_TESTCONTAINERS_LOCALSTACK_SQS_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() | ||
|
||
sqsClient.createQueue(s -> s.queueName("${aws.sqs.queueName}")) | ||
|
||
return sqsClient |
8 changes: 8 additions & 0 deletions
8
tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-credentials.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Please add your AWS SQS account credentials | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.queueNameOrArn=${aws.sqs.queueName} | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.overrideEndpoint=true | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.uriEndpointOverride=${YAKS_TESTCONTAINERS_LOCALSTACK_SQS_URL} | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.secretKey=${YAKS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY} | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.accessKey=${YAKS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY} | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.region=${YAKS_TESTCONTAINERS_LOCALSTACK_REGION} | ||
camel.kamelet.aws-sqs-source.aws-sqs-credentials.deleteAfterRead=true |
42 changes: 42 additions & 0 deletions
42
tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-knative-channel.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@knative | ||
Feature: AWS SQS Kamelet - binding to InMemoryChannel | ||
|
||
Background: | ||
Given variables | ||
| aws.sqs.queueName | myqueue | | ||
|
||
Scenario: Create infrastructure | ||
# Start LocalStack container | ||
Given Enable service SQS | ||
Given start LocalStack container | ||
# Create Knative broker and channel | ||
Given create Knative broker default | ||
And Knative broker default is running | ||
And create Knative channel messages | ||
|
||
Scenario: Verify AWS-SQS Kamelet to InMemoryChannel binding | ||
# Create AWS-SQS client | ||
Given load to Camel registry amazonSQSClient.groovy | ||
# Create binding | ||
Given load Pipe aws-sqs-to-knative-channel.yaml | ||
Given load Pipe knative-channel-to-log.yaml | ||
Then Pipe aws-sqs-to-knative-channel is available | ||
And Pipe knative-channel-to-log should be available | ||
And Camel K integration aws-sqs-to-knative-channel is running | ||
And Camel K integration knative-channel-to-log is running | ||
And Camel K integration aws-sqs-to-knative-channel should print Started aws-sqs-to-knative-channel | ||
And Camel K integration knative-channel-to-log should print Installed features | ||
# Verify Kamelet source | ||
Given variable aws.sqs.message is "Hello from SQS Kamelet" | ||
And send Camel exchange to("aws2-sqs:${aws.sqs.queueName}?amazonSQSClient=#amazonSQSClient") with body: ${aws.sqs.message} | ||
Then Camel K integration knative-channel-to-log should print ${aws.sqs.message} | ||
|
||
Scenario: Remove resources | ||
# Remove Camel K resources | ||
Given delete Pipe aws-sqs-to-knative-channel | ||
Given delete Pipe knative-channel-to-log | ||
# Remove Knative resources | ||
Given delete Knative broker default | ||
Given delete Knative channel messages | ||
# Stop LocalStack container | ||
Given stop LocalStack container |
32 changes: 32 additions & 0 deletions
32
tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-source-property-conf.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Feature: AWS SQS Kamelet - property based config | ||
|
||
Background: | ||
Given variables | ||
| aws.sqs.queueName | myqueue | | ||
|
||
Scenario: Create infrastructure | ||
# Start LocalStack container | ||
Given Enable service SQS | ||
Given start LocalStack container | ||
|
||
Scenario: Verify AWS-SQS events | ||
# Create AWS-SQS client | ||
Given load to Camel registry amazonSQSClient.groovy | ||
# Create binding | ||
Given Camel K integration property file aws-sqs-credentials.properties | ||
Given create Camel K integration aws-sqs-to-log-prop-based.groovy | ||
""" | ||
from("kamelet:aws-sqs-source/aws-sqs-credentials") | ||
.to("log:info") | ||
""" | ||
Then Camel K integration aws-sqs-to-log-prop-based should be running | ||
# Verify Kamelet source | ||
Given variable aws.sqs.message is "Hello from SQS Kamelet" | ||
And send Camel exchange to("aws2-sqs:${aws.sqs.queueName}?amazonSQSClient=#amazonSQSClient") with body: ${aws.sqs.message} | ||
Then Camel K integration aws-sqs-to-log-prop-based should print ${aws.sqs.message} | ||
|
||
Scenario: Remove resources | ||
# Remove Camel K resources | ||
Given delete Camel K integration aws-sqs-to-log-prop-based | ||
# Stop LocalStack container | ||
Given stop LocalStack container |
36 changes: 36 additions & 0 deletions
36
tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-source-secret-conf.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@ignored | ||
Feature: AWS SQS Kamelet - secret based config | ||
|
||
Background: | ||
Given variables | ||
| aws.sqs.queueName | myqueue | | ||
|
||
Scenario: Create infrastructure | ||
# Start LocalStack container | ||
Given Enable service SQS | ||
Given start LocalStack container | ||
# Create Kubernetes secret | ||
Given create Kubernetes secret aws-sqs-source-credentials | ||
| aws-sqs-credentials.properties | citrus:encodeBase64(citrus:readFile(aws-sqs-credentials.properties)) | | ||
Given create labels on Kubernetes secret aws-sqs-source-credentials | ||
| camel.apache.org/kamelet | aws-sqs-source | | ||
| camel.apache.org/kamelet.configuration | aws-sqs-credentials | | ||
|
||
Scenario: Verify AWS-SQS events | ||
# Create AWS-SQS client | ||
Given load to Camel registry amazonSQSClient.groovy | ||
# Create binding | ||
Given load Camel K integration aws-sqs-to-log-secret-based.groovy | ||
Then Camel K integration aws-sqs-to-log-secret-based should be running | ||
# Verify Kamelet source | ||
Given variable aws.sqs.message is "Hello from SQS Kamelet" | ||
And send Camel exchange to("aws2-sqs:${aws.sqs.queueName}?amazonSQSClient=#amazonSQSClient") with body: ${aws.sqs.message} | ||
Then Camel K integration aws-sqs-to-log-secret-based should print ${aws.sqs.message} | ||
|
||
Scenario: Remove resources | ||
# Remove Camel K resources | ||
Given delete Camel K integration aws-sqs-to-log-secret-based | ||
# Remove Kubernetes secret | ||
Given delete Kubernetes secret aws-sqs-source-credentials | ||
# Stop LocalStack container | ||
Given stop LocalStack container |
27 changes: 27 additions & 0 deletions
27
tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-source-uri-conf.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Feature: AWS SQS Kamelet - URI based config | ||
|
||
Background: | ||
Given variables | ||
| aws.sqs.queueName | myqueue | | ||
|
||
Scenario: Create infrastructure | ||
# Start LocalStack container | ||
Given Enable service SQS | ||
Given start LocalStack container | ||
|
||
Scenario: Verify AWS-SQS events | ||
# Create AWS-SQS client | ||
Given load to Camel registry amazonSQSClient.groovy | ||
# Create binding | ||
Given load Camel K integration aws-sqs-to-log-uri-based.groovy | ||
Then Camel K integration aws-sqs-to-log-uri-based should be running | ||
# Verify Kamelet source | ||
Given variable aws.sqs.message is "Hello from SQS Kamelet" | ||
And send Camel exchange to("aws2-sqs:${aws.sqs.queueName}?amazonSQSClient=#amazonSQSClient") with body: ${aws.sqs.message} | ||
Then Camel K integration aws-sqs-to-log-uri-based should print ${aws.sqs.message} | ||
|
||
Scenario: Remove resources | ||
# Remove Camel K resources | ||
Given delete Camel K integration aws-sqs-to-log-uri-based | ||
# Stop LocalStack container | ||
Given stop LocalStack container |
46 changes: 46 additions & 0 deletions
46
tests/camel-kamelets-itest/src/test/resources/aws/sqs/aws-sqs-to-knative-channel.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# --------------------------------------------------------------------------- | ||
# 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-sqs-to-knative-channel | ||
spec: | ||
source: | ||
ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: aws-sqs-source | ||
properties: | ||
queueNameOrArn: ${aws.sqs.queueName} | ||
overrideEndpoint: true | ||
uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_SQS_URL} | ||
accessKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY} | ||
secretKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY} | ||
region: ${YAKS_TESTCONTAINERS_LOCALSTACK_REGION} | ||
steps: | ||
- ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: log-action | ||
properties: | ||
showHeaders: true | ||
sink: | ||
ref: | ||
kind: InMemoryChannel | ||
apiVersion: messaging.knative.dev/v1 | ||
name: messages |
Oops, something went wrong.