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: Use pure Citrus instead of YAKS #2360

Merged
merged 2 commits into from
Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

name: YAKS Tests
name: Integration Tests

on:
pull_request:
Expand Down Expand Up @@ -60,25 +60,27 @@ jobs:
- name: Build Kamelet libraries
run: |
./mvnw clean install -DskipTests -DskipITs
- name: YAKS Tests
- name: Run Tests
env:
CITRUS_TESTCONTAINERS_LOCALSTACK_IMAGE_NAME: "mirror.gcr.io/localstack/localstack"
run: |
echo "Install JBang via SDKMAN"

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/citrusframework/citrus/
jbang trust add https://github.com/apache/camel/

jbang yaks@citrusframework/yaks --version
jbang citrus@citrusframework/citrus --version
jbang camel@apache/camel --version

echo "Running YAKS tests for Kamelets"
echo "Running Citrus tests for Kamelets"

./mvnw clean verify -pl :camel-kamelets-itest -Denable.yaks.tests
./mvnw clean verify -pl :camel-kamelets-itest -Denable.integration.tests
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
if: failure()
with:
name: dumps
path: tests/camel-kamelets-itest/.yaks-jbang
path: tests/camel-kamelets-itest/.citrus-jbang
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ terraform.*
.terraform*
.camel-jbang*
.yaks-jbang*
.citrus-jbang*

_output
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
- Fix AWS DDB Streams Source Kamelet [\#2008](https://github.com/apache/camel-kamelets/pull/2008) ([christophd](https://github.com/christophd))
- Generated sources regen for SBOM [\#2007](https://github.com/apache/camel-kamelets/pull/2007) ([github-actions[bot]](https://github.com/apps/github-actions))
- Replace IBM bean by the IBM jakarta version [\#2006](https://github.com/apache/camel-kamelets/pull/2006) ([gansheer](https://github.com/gansheer))
- Bump org.citrusframework.yaks:yaks-bom from 0.19.0 to 0.19.1 [\#2004](https://github.com/apache/camel-kamelets/pull/2004) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump org.citrusframework.citrus:yaks-bom from 0.19.0 to 0.19.1 [\#2004](https://github.com/apache/camel-kamelets/pull/2004) ([dependabot[bot]](https://github.com/apps/dependabot))
- Kamelet Catalog: Provide a method in the catalog API to get DataType … [\#2002](https://github.com/apache/camel-kamelets/pull/2002) ([oscerd](https://github.com/oscerd))
- Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.3 to 3.2.4 [\#2001](https://github.com/apache/camel-kamelets/pull/2001) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump org.apache.maven.resolver:maven-resolver-api from 1.9.18 to 1.9.19 [\#2000](https://github.com/apache/camel-kamelets/pull/2000) ([dependabot[bot]](https://github.com/apps/dependabot))
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ Kamelets **MAY** choose not to declare a `mediaType` when it varies depending on

### Testing

Kamelets **SHOULD** be accompanied with testing code that verifies their correct behavior.
Kamelets **SHOULD** be accompanied by tests that verify their correct behavior.

[Yaks](https://github.com/citrusframework/yaks) is the testing framework of choice for Kamelets and the one implemented in the CI.
[Citrus](https://github.com/citrusframework/citrus) is the testing framework of choice for Kamelets and the one implemented in the CI.

Test code must be submitted in the `test/<kamelet-name>/` directory in the root of this repository.
Test code must be submitted in the `tests/camel-kamelets-itests/src/test/resources/<kamelet-name>/` directory in the root of this repository.

Kamelets submitted with tests that verify their correctness **MUST** be labeled with `camel.apache.org/kamelet.verified=true`.

> [!NOTE]
> There's no way at the moment to inject credentials for external systems into the CI in order to write more advanced tests, but we can expect we'll find an usable strategy in the long run.
> There's no way at the moment to inject credentials for external systems into the CI in order to write more advanced tests, but we can expect we'll find a usable strategy in the long run.

### Kamelet Pipe Examples

Expand Down
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/development.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1422,8 +1422,8 @@ This will create a new integration that forwards the Apache Camel logo to your p

The most obvious way to test a Kamelet is via an e2e tests that verifies if the Kamelet respects its specification.

https://github.com/citrusframework/yaks[YAKS] is the framework of choice for such e2e tests. You can find more information and
documentation starting from the https://github.com/citrusframework/yaks[YAKS GitHub repository]. Here we'll provide examples for the Kamelets above.
https://github.com/citrusframework/citrus[Citrus] is the framework of choice for such e2e tests. You can find more information and
documentation starting from the https://github.com/citrusframework/citrus[Citrus GitHub repository]. Here we'll provide examples for the Kamelets above.

=== Testing a source

Expand All @@ -1445,7 +1445,7 @@ Feature: Kamelet earthquake-source works

Scenario: Bind Kamelet to service
Given create Kubernetes service test-service with target port 8080
And bind Kamelet earthquake-source to uri http://test-service.${YAKS_NAMESPACE}.svc.cluster.local/test
And bind Kamelet earthquake-source to uri http://test-service.${CITRUS_NAMESPACE}.svc.cluster.local/test
When create Pipe earthquake-source-uri
Then Pipe earthquake-source-uri should be available
And Camel K integration earthquake-source-uri should be running
Expand Down Expand Up @@ -1543,7 +1543,7 @@ Feature: Kamelet telegram-sink works


Scenario: Send a message to the Telegram Chat
Given URL: http://webhook-to-telegram.${YAKS_NAMESPACE}.svc.cluster.local
Given URL: http://webhook-to-telegram.${CITRUS_NAMESPACE}.svc.cluster.local
And HTTP request timeout is 60000 milliseconds
And wait for GET on path / to return 404
Given HTTP request headers
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dependencies</artifactId>
<version>4.9.0</version>
<version>4.9.0</version>
</parent>

<groupId>org.apache.camel.kamelets</groupId>
Expand Down Expand Up @@ -64,9 +64,8 @@

<camel.version>4.9.0</camel.version>

<citrus.version>4.3.2</citrus.version>
<cucumber.version>7.18.1</cucumber.version>
<yaks.version>0.20.0</yaks.version>
<citrus.version>4.5.0</citrus.version>
<cucumber.version>7.20.1</cucumber.version>

<!-- Versions used inside Kamelets (add them also to the dependencyManagement section and the groovy script below) -->
<!-- These properties must keep this same format "version.<groupId>.<artifactId>" -->
Expand Down
14 changes: 7 additions & 7 deletions tests/camel-kamelets-itest/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Kamelets YAKS Tests
# Kamelets Citrus 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)
- [Citrus JBang App](https://citrusframework.org/citrus/reference/html/index.html#runtime-jbang-install)

Once everything is set you just need to run

```console
mvn verify -Denable.yaks.tests
mvn verify -Denable.integration.tests
```

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

You can run individual tests when specifying its folder or feature file name.
You can run individual tests when specifying its folder name on the class `KameletsIT` (e.g. `aws`).

```console
mvn verify -Dcucumber.feature=aws/s3/aws-s3-to-http.feature -Denable.yaks.tests
mvn verify -Dtest=KameletsIT#aws
```

You can run the tests also from your favorite Java IDE.
By default, the YAKS tests use local runtime where Camel integrations, Kamelets, bindings and pipes are run with Camel JBang.
By default, the Citrus tests use local runtime where Camel integrations, Kamelets, bindings and pipes are run with Camel JBang.
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#!/bin/sh

#
# 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
# 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.
#

# delete Kafka cluster
kubectl delete kafka/my-cluster -n $YAKS_NAMESPACE

# delete default topic
kubectl delete kafkatopic/my-topic -n $YAKS_NAMESPACE
# Declare required additional dependencies
run.deps=org.apache.camel:camel-jackson-avro:4.9.0,\
org.apache.camel:camel-jackson-protobuf:4.9.0
82 changes: 17 additions & 65 deletions tests/camel-kamelets-itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<description>Camel Kamelets Integration Tests</description>

<properties>
<enable.yaks.tests>*YaksIT</enable.yaks.tests>
<enable.integration.tests>*KameletsIT</enable.integration.tests>
</properties>

<dependencyManagement>
Expand All @@ -46,31 +46,10 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-bom</artifactId>
<version>${yaks.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- Test scoped dependencies -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>

<!-- Apache Camel -->
<dependency>
<groupId>org.apache.camel</groupId>
Expand Down Expand Up @@ -117,79 +96,52 @@
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-spring</artifactId>
<artifactId>citrus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-junit</artifactId>
<artifactId>citrus-jbang-connector</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-mail</artifactId>
<artifactId>citrus-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-validation-text</artifactId>
<artifactId>citrus-yaml</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-validation-json</artifactId>
<scope>test</scope>
</dependency>

<!-- YAKS -->
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-standard</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-http</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-kubernetes</artifactId>
<artifactId>citrus-groovy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-knative</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-kafka</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-groovy</artifactId>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-camel</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-camel</artifactId>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-kafka</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-camel-k</artifactId>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-mail</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-testcontainers</artifactId>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-validation-text</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.citrusframework.yaks</groupId>
<artifactId>yaks-jdbc</artifactId>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-validation-json</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -223,7 +175,7 @@
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<excludes>
<exclude>${enable.yaks.tests}</exclude>
<exclude>${enable.integration.tests}</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 java.nio.file.Path;

import org.citrusframework.annotations.CitrusConfiguration;
import org.citrusframework.camel.jbang.CamelJBangSettings;
import org.citrusframework.container.SequenceBeforeSuite;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.http.server.HttpServer;
import org.citrusframework.spi.BindToRegistry;
import org.springframework.http.HttpStatus;

import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http;

@CitrusConfiguration
public class EndpointAutoConfiguration {

@BindToRegistry
public HttpServer httpServer() {
return http()
.server()
.port(8081)
.defaultStatus(HttpStatus.CREATED)
.timeout(120000L)
.autoStart(true)
.build();
}

@BindToRegistry
public SequenceBeforeSuite setup() {
// TODO: Workaround - remove when Citrus 4.5.1 is released
return SequenceBeforeSuite.Builder.beforeSuite()
.actions(context -> {
Path workDir = CamelJBangSettings.getWorkDir();
if (!workDir.toFile().exists() && !workDir.toFile().mkdirs()) {
throw new CitrusRuntimeException("Failed to create JBang working directory: %s".formatted(workDir.toAbsolutePath().toString()));
}
})
.build();
}

}
Loading
Loading