Skip to content

Commit

Permalink
Add Makefile to run YAKS tests (#1625)
Browse files Browse the repository at this point in the history
* Add Makefile to run YAKS tests

- Adding Makefile as a wrapper for the YAKS binary
- Makes local YAKS test execution more comfortable
- Automatically set YAKS runtime options such as Camel JBang version or local Kamelets directory
- Use the Makefile in GitHub actions CI to run all YAKS tests

* Improve aws-s3-to-http.feature

Properly waiting for Camel routes to startup before triggering S3 file on bucket
  • Loading branch information
christophd committed Sep 7, 2023
1 parent 1c1bdeb commit b5ba90c
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 28 deletions.
19 changes: 2 additions & 17 deletions .github/workflows/yaks-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ concurrency:

env:
YAKS_VERSION: 0.16.0
YAKS_RUN_OPTIONS: "--timeout=15m --local -e YAKS_CAMELK_MAX_ATTEMPTS=10 -e YAKS_JBANG_CAMEL_VERSION=4.0.0 -e YAKS_JBANG_KAMELETS_VERSION=4.1.0-SNAPSHOT -e YAKS_JBANG_KAMELETS_LOCAL_DIR=../../../kamelets -e YAKS_KAMELET_API_VERSION=v1alpha1"

jobs:
test:
Expand Down Expand Up @@ -88,22 +87,8 @@ jobs:
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/avro-data-type $YAKS_RUN_OPTIONS
yaks run test/avro-serdes-action $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/timer-to-http $YAKS_RUN_OPTIONS
yaks run test/data-type-action $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
cd test
make yaks
- uses: actions/upload-artifact@v3
if: failure()
with:
Expand Down
43 changes: 43 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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.

camel-version := 4.0.0
camel-kamelets-version := 4.1.0-SNAPSHOT
kamelet-api-version := v1alpha1
kamelets-local-dir := ../../../kamelets
test := .

YAKS_RUN_OPTIONS := --timeout=15m --local -e YAKS_CAMELK_MAX_ATTEMPTS=10 -e YAKS_JBANG_CAMEL_VERSION=$(camel-version) -e YAKS_JBANG_KAMELETS_VERSION=$(camel-kamelets-version) -e YAKS_JBANG_KAMELETS_LOCAL_DIR=$(kamelets-local-dir) -e YAKS_KAMELET_API_VERSION=$(kamelet-api-version)

default: all

check-setup:
@java -version
@jbang version
@yaks version
@jbang camel@apache/camel --version
@echo "Test setup - OK"

all: check-setup
@echo "Running YAKS tests"
@echo #
yaks run . $(YAKS_RUN_OPTIONS)

yaks: check-setup
@echo "Running YAKS test"
@echo #
yaks run $(test) $(YAKS_RUN_OPTIONS)

.PHONY: all, yaks
27 changes: 27 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Kamelets YAKS Tests

This folder contains a suite of integration tests for Kamelets

You need the following tools to run the tests:
- Java 17
- [JBang](https://www.jbang.dev/)
- [Camel JBang](https://camel.apache.org/manual/camel-jbang.html)
- [YAKS](https://github.com/citrusframework/yaks)

Once everything is set you just need to run

```console
make yaks
```

This runs all available YAKS tests that are not marked as `@ignored`.

You can run individual tests when specifying its folder or feature file name.

```console
make yaks test=timer-source/timer-source.feature
```

The Makefile is a wrapper for the YAKS binary which is able to run the BDD Gherkin feature files.
You can also run YAKS tooling directly form your local machine.
By default, the YAKS tests use local runtime where Camel integrations, Kamelets, bindings and pipes are run with Camel JBang.
4 changes: 0 additions & 4 deletions test/avro-data-type/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ config:
temporary: false
runtime:
env:
- name: YAKS_JBANG_KAMELETS_LOCAL_DIR
value: "../../../kamelets"
- name: YAKS_CAMELK_KAMELET_API_VERSION
value: v1
- name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
value: false
- name: YAKS_KUBERNETES_AUTO_REMOVE_RESOURCES
Expand Down
4 changes: 0 additions & 4 deletions test/avro-serdes-action/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ config:
temporary: false
runtime:
env:
- name: YAKS_JBANG_KAMELETS_LOCAL_DIR
value: "../../../kamelets"
- name: YAKS_CAMELK_KAMELET_API_VERSION
value: v1
- name: YAKS_CAMELK_AUTO_REMOVE_RESOURCES
value: false
- name: YAKS_KUBERNETES_AUTO_REMOVE_RESOURCES
Expand Down
2 changes: 1 addition & 1 deletion test/aws-s3/aws-s3-to-http.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feature: AWS S3 Kamelet - Http sink
When load KameletBinding aws-s3-to-http.yaml
And KameletBinding aws-s3-to-http is available
And Camel K integration aws-s3-to-http is running
Then Camel K integration aws-s3-to-http should print Started aws-s3-to-http
Then Camel K integration aws-s3-to-http should print (aws-s3-to-http) started
# Verify Kamelet source
Given Camel exchange message header CamelAwsS3Key="${aws.s3.key}"
Given send Camel exchange to("aws2-s3://${aws.s3.bucketNameOrArn}?amazonS3Client=#amazonS3Client") with body: ${aws.s3.message}
Expand Down
3 changes: 1 addition & 2 deletions test/salesforce-sink/salesforce-sink.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------

@ignored
Feature: Salesforce Kamelet

Background:
Expand Down Expand Up @@ -71,7 +71,6 @@ Feature: Salesforce Kamelet
Then verify HTTP response expression: $.totalSize="0"
And receive HTTP 200 OK


Scenario: Remove Camel-K resources
Given delete KameletBinding timer-to-salesforce-binding
And delete KameletBinding direct-to-salesforce-update-binding
Expand Down
3 changes: 3 additions & 0 deletions test/salesforce-sink/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ config:
value: false
- name: YAKS_JBANG_CAMEL_DUMP_INTEGRATION_OUTPUT
value: true
cucumber:
tags:
- "not @ignored"
settings:
loggers:
- name: INTEGRATION_STATUS
Expand Down

0 comments on commit b5ba90c

Please sign in to comment.