Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix YAKS tests #1322

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 27 additions & 45 deletions .github/workflows/yaks-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,23 @@ concurrency:
cancel-in-progress: true

env:
CAMEL_K_VERSION: 1.12.0-nightly
YAKS_VERSION: 0.14.1
YAKS_IMAGE_NAME: "docker.io/citrusframework/yaks"
YAKS_RUN_OPTIONS: "--timeout=15m"
YAKS_VERSION: 0.14.2
YAKS_RUN_OPTIONS: "--timeout=15m --local -e YAKS_CAMELK_MAX_ATTEMPTS=10 -e YAKS_JBANG_CAMEL_VERSION=4.0.0-M1"

jobs:
test:
if: ${{ false }} # disable until YAKS support Camel 4

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Set JitPack coordinates for pull requests
if: github.event_name == 'pull_request'
env:
Expand All @@ -67,14 +70,6 @@ jobs:
# Overwrite JitPack coordinates in the local Kamelets so the tests can use the utility classes in this PR
find kamelets -maxdepth 1 -name '*.kamelet.yaml' -exec sed -i "s/github:apache.camel-kamelets:camel-kamelets-utils:${PROJECT_VERSION}/github:${HEAD_REPO/\//.}:camel-kamelets-utils:${HEAD_REF//\//'~'}-SNAPSHOT/g" {} +
- name: Get Camel K CLI
run: |
curl --fail -L --silent https://github.com/apache/camel-k/releases/download/${CAMEL_K_VERSION}/camel-k-client-${CAMEL_K_VERSION}-linux-64bit.tar.gz -o kamel.tar.gz
mkdir -p _kamel
tar -zxf kamel.tar.gz --directory ./_kamel
sudo mv ./_kamel/kamel /usr/local/bin/
rm kamel.tar.gz
rm -r _kamel
- name: Get YAKS CLI
run: |
curl --fail -L --silent https://github.com/citrusframework/yaks/releases/download/v${YAKS_VERSION}/yaks-${YAKS_VERSION}-linux-64bit.tar.gz -o yaks.tar.gz
Expand All @@ -83,51 +78,38 @@ jobs:
sudo mv ./_yaks/yaks /usr/local/bin/
rm yaks.tar.gz
rm -r _yaks
- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@v1
with:
version: v0.14.0
node_image: kindest/node:v1.23.6@sha256:b1fa224cc6c7ff32455e0b1fd9cbfd3d3bc87ecaa8fcb06961ed1afb3db0f9ae
- name: Info
run: |
kubectl version
kubectl cluster-info
kubectl describe nodes
- name: Install Knative
uses: ./.github/actions/install-knative
- name: Install Camel K
yaks version
- name: YAKS Tests
run: |
# Configure install options
export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum
export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
export KAMEL_INSTALL_REGISTRY_INSECURE=true
echo "Install JBang via SDKMAN"
kamel install -w --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false --maven-repository=https://repository.apache.org/content/repositories/snapshots@id=apache-snapshots@snapshots
curl -s "https://get.sdkman.io" | bash
source "/home/runner/.sdkman/bin/sdkman-init.sh"
sdk install jbang
jbang trust add https://github.com/citrusframework/yaks/
jbang trust add https://github.com/apache/camel/
# Install the local kamelets
find kamelets -maxdepth 1 -name '*.kamelet.yaml' -exec kubectl apply -f {} \;
- name: Install YAKS
run: |
yaks install --operator-image $YAKS_IMAGE_NAME:$YAKS_VERSION
- name: YAKS Tests
run: |
echo "Running tests for Kamelets"
jbang yaks@citrusframework/yaks --version
jbang camel@apache/camel --version
echo "Running YAKS tests for Kamelets"
yaks run test/aws-ddb-sink $YAKS_RUN_OPTIONS
yaks run test/aws-s3 $YAKS_RUN_OPTIONS
yaks run test/extract-field-action $YAKS_RUN_OPTIONS
yaks run test/insert-field-action $YAKS_RUN_OPTIONS
yaks run test/mail-sink $YAKS_RUN_OPTIONS
yaks run test/timer-source $YAKS_RUN_OPTIONS
yaks run test/earthquake-source $YAKS_RUN_OPTIONS
yaks run test/rest-openapi-sink $YAKS_RUN_OPTIONS
yaks run test/kafka $YAKS_RUN_OPTIONS
- name: YAKS Report
if: failure()
run: |
yaks report
- uses: actions/upload-artifact@v2
if: failure()
with:
name: dumps
path: _output/*-dump.log
path: test/**/.yaks-jbang/*-output.txt
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ node_modules/
terraform.*
.terraform*
.camel-jbang*
.yaks-jbang*

_output
2 changes: 1 addition & 1 deletion test/aws-ddb-sink/aws-ddb-sink-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
table: ${aws.ddb.tableName}
operation: ${aws.ddb.operation}
overrideEndpoint: true
uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_DYNAMODB_URL}
uriEndpointOverride: ${YAKS_TESTCONTAINERS_LOCALSTACK_DYNAMODB_LOCAL_URL}
accessKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_ACCESS_KEY}
secretKey: ${YAKS_TESTCONTAINERS_LOCALSTACK_SECRET_KEY}
region: ${YAKS_TESTCONTAINERS_LOCALSTACK_REGION}
27 changes: 11 additions & 16 deletions test/aws-ddb-sink/aws-ddb-sink-deleteItem.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
Feature: AWS DDB Sink - DeleteItem

Background:
Given Kamelet aws-ddb-sink is available
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
Given variables
| timer.source.period | 10000 |
| aws.ddb.operation | DeleteItem |
Expand All @@ -31,36 +27,35 @@ Feature: AWS DDB Sink - DeleteItem
| aws.ddb.item.title | Back to the future |
| aws.ddb.json.data | {"id": ${aws.ddb.item.id}} |

Scenario: Start LocalStack container
Scenario: Create infrastructure
# Start LocalStack container
Given Enable service DYNAMODB
Given start LocalStack container
And log 'Started LocalStack container: ${YAKS_TESTCONTAINERS_LOCALSTACK_CONTAINER_NAME}'

Scenario: Create AWS-DDB client
# Create AWS-DDB client
Given New global Camel context
Given load to Camel registry amazonDDBClient.groovy

Scenario: Create item on AWS-DDB
Given run script putItem.groovy
Given variables
| maxRetryAttempts | 20 |
| aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
| aws.ddb.items | [[year:AttributeValue(N=${aws.ddb.item.year}), id:AttributeValue(N=${aws.ddb.item.id}), title:AttributeValue(S=${aws.ddb.item.title})]] |
Then apply actions verifyItems.groovy

Scenario: Create AWS-DDB Kamelet sink binding
Scenario: Verify AWS-DDB Kamelet sink binding
# Create binding
When load KameletBinding aws-ddb-sink-binding.yaml
And KameletBinding aws-ddb-sink-binding is available
And Camel K integration aws-ddb-sink-binding is running
And Camel K integration aws-ddb-sink-binding should print Routes startup

Scenario: Verify Kamelet sink
And Camel K integration aws-ddb-sink-binding should print Started aws-ddb-sink-binding
# Verify Kamelet sink
Given variables
| maxRetryAttempts | 20 |
| aws.ddb.items | [] |
Then apply actions verifyItems.groovy

Scenario: Remove Camel K resources
Scenario: Remove resources
# Remove Camel K resources
Given delete KameletBinding aws-ddb-sink-binding

Scenario: Stop container
# Stop LocalStack container
Given stop LocalStack container
33 changes: 17 additions & 16 deletions test/aws-ddb-sink/aws-ddb-sink-putItem.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
Feature: AWS DDB Sink - PutItem

Background:
Given Kamelet aws-ddb-sink is available
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
Given variables
| timer.source.period | 10000 |
| aws.ddb.operation | PutItem |
Expand All @@ -31,29 +27,34 @@ Feature: AWS DDB Sink - PutItem
| aws.ddb.item.title | Star Wars IV |
| aws.ddb.json.data | { "id":${aws.ddb.item.id}, "year":${aws.ddb.item.year}, "title":"${aws.ddb.item.title}" } |

Scenario: Start LocalStack container
Scenario: Create infrastructure
# Start LocalStack container
Given Enable service DYNAMODB
Given start LocalStack container
And log 'Started LocalStack container: ${YAKS_TESTCONTAINERS_LOCALSTACK_CONTAINER_NAME}'

Scenario: Create AWS-DDB client
# Create AWS-DDB client
Given New global Camel context
Given load to Camel registry amazonDDBClient.groovy

Scenario: Create AWS-DDB Kamelet sink binding
Scenario: Verify empty items on AWS-DDB
Given variables
| maxRetryAttempts | 20 |
| aws.ddb.items | [] |
Then apply actions verifyItems.groovy

Scenario: Verify AWS-DDB Kamelet sink binding
# Create binding
When load KameletBinding aws-ddb-sink-binding.yaml
And KameletBinding aws-ddb-sink-binding is available
And Camel K integration aws-ddb-sink-binding is running
And Camel K integration aws-ddb-sink-binding should print Routes startup

Scenario: Verify Kamelet sink
And Camel K integration aws-ddb-sink-binding should print Started aws-ddb-sink-binding
# Verify Kamelet sink
Given variables
| maxRetryAttempts | 20 |
| aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
| aws.ddb.items | [[year:AttributeValue(N=${aws.ddb.item.year}), id:AttributeValue(N=${aws.ddb.item.id}), title:AttributeValue(S=${aws.ddb.item.title})]] |
Then apply actions verifyItems.groovy

Scenario: Remove Camel K resources
Scenario: Remove resources
# Remove Camel K binding
Given delete KameletBinding aws-ddb-sink-binding

Scenario: Stop container
# Stop LocalStack container
Given stop LocalStack container
29 changes: 12 additions & 17 deletions test/aws-ddb-sink/aws-ddb-sink-updateItem.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
Feature: AWS DDB Sink - UpdateItem

Background:
Given Kamelet aws-ddb-sink is available
Given Camel K resource polling configuration
| maxAttempts | 200 |
| delayBetweenAttempts | 2000 |
Given variables
| timer.source.period | 10000 |
| aws.ddb.operation | UpdateItem |
Expand All @@ -33,37 +29,36 @@ Feature: AWS DDB Sink - UpdateItem
| aws.ddb.item.directors | ["Merian C. Cooper", "Ernest B. Schoedsack"] |
| aws.ddb.json.data | { "key": {"id": ${aws.ddb.item.id}}, "item": {"title": "${aws.ddb.item.title.new}", "year": ${aws.ddb.item.year}, "directors": ${aws.ddb.item.directors}} } |

Scenario: Start LocalStack container
Scenario: Create infrastructure
# Start LocalStack container
Given Enable service DYNAMODB
Given start LocalStack container
And log 'Started LocalStack container: ${YAKS_TESTCONTAINERS_LOCALSTACK_CONTAINER_NAME}'

Scenario: Create AWS-DDB client
# Create AWS-DDB client
Given New global Camel context
Given load to Camel registry amazonDDBClient.groovy

Scenario: Create item on AWS-DDB
Given run script putItem.groovy
Given variables
| maxRetryAttempts | 20 |
| aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title})}] |
| aws.ddb.items | [[year:AttributeValue(N=${aws.ddb.item.year}), id:AttributeValue(N=${aws.ddb.item.id}), title:AttributeValue(S=${aws.ddb.item.title})]] |
Then apply actions verifyItems.groovy

Scenario: Create AWS-DDB Kamelet sink binding
Scenario: Verify AWS-DDB Kamelet sink binding
# Create binding
When load KameletBinding aws-ddb-sink-binding.yaml
And KameletBinding aws-ddb-sink-binding is available
And Camel K integration aws-ddb-sink-binding is running
And Camel K integration aws-ddb-sink-binding should print Routes startup

Scenario: Verify Kamelet sink
And Camel K integration aws-ddb-sink-binding should print Started aws-ddb-sink-binding
# Verify Kamelet sink
Given variables
| maxRetryAttempts | 200 |
| aws.ddb.item.directors | [Ernest B. Schoedsack, Merian C. Cooper] |
| aws.ddb.items | [{year=AttributeValue(N=${aws.ddb.item.year}), directors=AttributeValue(SS=${aws.ddb.item.directors}), id=AttributeValue(N=${aws.ddb.item.id}), title=AttributeValue(S=${aws.ddb.item.title.new})}] |
| aws.ddb.items | [[year:AttributeValue(N=${aws.ddb.item.year}), directors:AttributeValue(SS=${aws.ddb.item.directors}), id:AttributeValue(N=${aws.ddb.item.id}), title:AttributeValue(S=${aws.ddb.item.title.new})]] |
Then apply actions verifyItems.groovy

Scenario: Remove Camel K resources
Scenario: Remove resources
# Remove Camel K resources
Given delete KameletBinding aws-ddb-sink-binding

Scenario: Stop container
# Stop LocalStack container
Given stop LocalStack container
27 changes: 12 additions & 15 deletions test/aws-ddb-sink/verifyItems.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@
* limitations under the License.
*/

$actions {
$(repeatOnError()
.until('i > ${maxRetryAttempts}')
.actions(new com.consol.citrus.TestAction() {
@Override
void execute(com.consol.citrus.context.TestContext context) {
try {
assert context.getVariable('aws.ddb.items')
.equals(amazonDDBClient.scan(b -> b.tableName(context.getVariable('aws.ddb.tableName')))?.items()?.toString())
} catch (AssertionError e) {
throw new com.consol.citrus.exceptions.CitrusRuntimeException("AWS DDB item verification failed", e)
}
$(repeatOnError()
.until('i > ${maxRetryAttempts}')
.actions(new com.consol.citrus.TestAction() {
@Override
void execute(com.consol.citrus.context.TestContext context) {
try {
assert context.getVariable('aws.ddb.items').equals(amazonDDBClient.scan(b -> b.tableName(context.getVariable('aws.ddb.tableName')))?.items()?.toListString())
} catch (AssertionError e) {
throw new com.consol.citrus.exceptions.CitrusRuntimeException("AWS DDB item verification failed", e)
}
})
)
}
}
})
)
2 changes: 2 additions & 0 deletions test/aws-ddb-sink/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ config:
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
Expand Down
Loading