You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/11 09:27:41 UTC
[camel] branch camel-4.0.x updated: CAMEL-19732 - Support Pipe in CRDs, replacing KameletBinding (#11067)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.0.x by this push:
new 7407fff9c9f CAMEL-19732 - Support Pipe in CRDs, replacing KameletBinding (#11067)
7407fff9c9f is described below
commit 7407fff9c9f2dacbc4daa2a7d88431f2b4d6e084
Author: Aurélien Pupier <ap...@redhat.com>
AuthorDate: Fri Aug 11 11:22:27 2023 +0200
CAMEL-19732 - Support Pipe in CRDs, replacing KameletBinding (#11067)
keeping KameletBinding working to let transition times for users
Signed-off-by: Aurélien Pupier <ap...@redhat.com>
---
.../modules/ROOT/pages/camel-jbang.adoc | 8 +-
.../apache/camel/dsl/jbang/core/commands/Bind.java | 4 +-
.../apache/camel/dsl/jbang/core/commands/Run.java | 3 +-
.../camel/dsl/jbang/core/common/GitHubHelper.java | 7 +-
...et.yaml.tmpl => pipe-kamelet-kamelet.yaml.tmpl} | 4 +-
...et-uri.yaml.tmpl => pipe-kamelet-uri.yaml.tmpl} | 4 +-
...amelet.yaml.tmpl => pipe-uri-kamelet.yaml.tmpl} | 4 +-
...ng-uri-uri.yaml.tmpl => pipe-uri-uri.yaml.tmpl} | 4 +-
.../camel/dsl/yaml/YamlRoutesBuilderLoader.java | 20 +-
.../camel/dsl/yaml/KameletBindingLoaderTest.groovy | 686 ---------------------
...dingLoaderTest.groovy => PipeLoaderTest.groovy} | 114 ++--
11 files changed, 86 insertions(+), 772 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index f589de71d4a..36375fefdae 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -853,17 +853,17 @@ camel version list --runtime=quarkus
TIP: See more options with `camel version list --help`.
-=== Running Camel K integrations or bindings
+=== Running Camel K integrations or pipes
Camel also supports running Camel K integrations and binding files, which are in CRD format (Kubernetes Custom Resource Definitions).
-For example a kamelet binding file named `joke.yaml`:
+For example a pipe file named `joke.yaml`:
[source,yaml]
----
#!/usr/bin/env jbang camel@apache/camel run
-apiVersion: camel.apache.org/v1alpha1
-kind: KameletBinding
+apiVersion: camel.apache.org/v1
+kind: Pipe
metadata:
name: joke
spec:
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Bind.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Bind.java
index b2bb634aef6..d47da404793 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Bind.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Bind.java
@@ -71,7 +71,7 @@ public class Bind extends CamelCommand {
@Override
public Integer doCall() throws Exception {
- // the kamelet binding source and sink can either be a kamelet or an uri
+ // the pipe source and sink can either be a kamelet or an uri
String in = "kamelet";
String out = "kamelet";
if (source.contains(":")) {
@@ -81,7 +81,7 @@ public class Bind extends CamelCommand {
out = "uri";
}
- InputStream is = Bind.class.getClassLoader().getResourceAsStream("templates/binding-" + in + "-" + out + ".yaml.tmpl");
+ InputStream is = Bind.class.getClassLoader().getResourceAsStream("templates/pipe-" + in + "-" + out + ".yaml.tmpl");
String context = IOHelper.loadText(is);
IOHelper.close(is);
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index e06e7b4dbb9..6e56380f37b 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -1051,10 +1051,11 @@ public class Run extends CamelCommand {
return ACCEPTED_XML_ROOT_ELEMENTS.contains(info.getRootElementName());
} else {
String data = IOHelper.loadText(fis);
- // also support Camel K integrations and Kamelet bindings
+ // also support Camel K integrations and Pipes. And KameletBinding for backward compatibility
return data.contains("- from:") || data.contains("- route:") || data.contains("- route-configuration:")
|| data.contains("- rest:") || data.contains("- beans:")
|| data.contains("KameletBinding")
+ || data.contains("Pipe")
|| data.contains("kind: Integration");
}
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/GitHubHelper.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/GitHubHelper.java
index 4aa62cb6ad9..5763bcc2bca 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/GitHubHelper.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/GitHubHelper.java
@@ -63,11 +63,6 @@ public final class GitHubHelper {
// this is a directory, so we need to query github which files are there and filter them
- // URL: https://api.github.com/repos/apache/camel-k/contents/examples/kamelets/kameletbindings
- // URL: https://api.github.com/repos/apache/camel-k/contents/examples/kamelets/kameletbindings?ref=v1.7.0
- // https://github.com/apache/camel-k/tree/main/examples/kamelets/kameletbindings
- // https://github.com/apache/camel-k/tree/v1.7.0/examples/kamelets/kameletbindings
-
// strip https://github.com/
url = url.substring(19);
@@ -96,7 +91,7 @@ public final class GitHubHelper {
path = sj.toString();
if ("tree".equals(action)) {
- // https://api.github.com/repos/apache/camel-k/contents/examples/kamelets/kameletbindings?ref=v1.7.0
+ // https://api.github.com/repos/apache/camel-k-examples/contents/examples/generic-examples
url = "https://api.github.com/repos/" + org + "/" + repo + "/contents/" + path;
if (!"main".equals(branch) && !"master".equals(branch)) {
url = url + "?ref=" + branch;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-kamelet-kamelet.yaml.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-kamelet-kamelet.yaml.tmpl
similarity index 83%
rename from dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-kamelet-kamelet.yaml.tmpl
rename to dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-kamelet-kamelet.yaml.tmpl
index 70d277ed005..1583542184a 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-kamelet-kamelet.yaml.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-kamelet-kamelet.yaml.tmpl
@@ -1,5 +1,5 @@
-apiVersion: camel.apache.org/v1alpha1
-kind: KameletBinding
+apiVersion: camel.apache.org/v1
+kind: Pipe
metadata:
name: {{ .Name }}
spec:
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-kamelet-uri.yaml.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-kamelet-uri.yaml.tmpl
similarity index 80%
rename from dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-kamelet-uri.yaml.tmpl
rename to dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-kamelet-uri.yaml.tmpl
index 05c830d5854..7e6b69967c4 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-kamelet-uri.yaml.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-kamelet-uri.yaml.tmpl
@@ -1,5 +1,5 @@
-apiVersion: camel.apache.org/v1alpha1
-kind: KameletBinding
+apiVersion: camel.apache.org/v1
+kind: Pipe
metadata:
name: {{ .Name }}
spec:
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-uri-kamelet.yaml.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-uri-kamelet.yaml.tmpl
similarity index 80%
rename from dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-uri-kamelet.yaml.tmpl
rename to dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-uri-kamelet.yaml.tmpl
index b2f5be3ee01..06dd6b0ee67 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-uri-kamelet.yaml.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-uri-kamelet.yaml.tmpl
@@ -1,5 +1,5 @@
-apiVersion: camel.apache.org/v1alpha1
-kind: KameletBinding
+apiVersion: camel.apache.org/v1
+kind: Pipe
metadata:
name: {{ .Name }}
spec:
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-uri-uri.yaml.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-uri-uri.yaml.tmpl
similarity index 75%
rename from dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-uri-uri.yaml.tmpl
rename to dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-uri-uri.yaml.tmpl
index 04c98c6d48c..c88aade2e25 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/binding-uri-uri.yaml.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/pipe-uri-uri.yaml.tmpl
@@ -1,5 +1,5 @@
-apiVersion: camel.apache.org/v1alpha1
-kind: KameletBinding
+apiVersion: camel.apache.org/v1
+kind: Pipe
metadata:
name: {{ .Name }}
spec:
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/main/java/org/apache/camel/dsl/yaml/YamlRoutesBuilderLoader.java b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/main/java/org/apache/camel/dsl/yaml/YamlRoutesBuilderLoader.java
index dd6a306aef7..ed2883dd982 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/main/java/org/apache/camel/dsl/yaml/YamlRoutesBuilderLoader.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/main/java/org/apache/camel/dsl/yaml/YamlRoutesBuilderLoader.java
@@ -98,10 +98,11 @@ public class YamlRoutesBuilderLoader extends YamlRoutesBuilderLoaderSupport {
private static final Logger LOG = LoggerFactory.getLogger(YamlRoutesBuilderLoader.class);
- // API versions for Camel-K Integration and Kamelet Binding
+ // API versions for Camel-K Integration and Pipe
// we are lenient so lets just assume we can work with any of the v1 even if they evolve
private static final String INTEGRATION_VERSION = "camel.apache.org/v1";
- private static final String BINDING_VERSION = "camel.apache.org/v1";
+ private static final String BINDING_VERSION = "camel.apache.org/v1alpha1";
+ private static final String PIPE_VERSION = "camel.apache.org/v1";
private static final String STRIMZI_VERSION = "kafka.strimzi.io/v1";
private static final String KNATIVE_VERSION = "messaging.knative.dev/v1";
@@ -297,13 +298,16 @@ public class YamlRoutesBuilderLoader extends YamlRoutesBuilderLoaderSupport {
// camel-k: integration
boolean integration = anyTupleMatches(mn.getValue(), "apiVersion", v -> v.startsWith(INTEGRATION_VERSION)) &&
anyTupleMatches(mn.getValue(), "kind", "Integration");
- // camel-k: kamelet binding are still at v1alpha1
+ // camel-k: kamelet binding
boolean binding = anyTupleMatches(mn.getValue(), "apiVersion", v -> v.startsWith(BINDING_VERSION)) &&
anyTupleMatches(mn.getValue(), "kind", "KameletBinding");
+ // camel-k: pipe
+ boolean pipe = anyTupleMatches(mn.getValue(), "apiVersion", v -> v.startsWith(PIPE_VERSION)) &&
+ anyTupleMatches(mn.getValue(), "kind", "Pipe");
if (integration) {
target = preConfigureIntegration(root, ctx, target, preParse);
- } else if (binding) {
- target = preConfigureKameletBinding(root, ctx, target, preParse);
+ } else if (binding || pipe) {
+ target = preConfigurePipe(root, ctx, target, preParse);
}
}
@@ -599,9 +603,9 @@ public class YamlRoutesBuilderLoader extends YamlRoutesBuilderLoaderSupport {
}
/**
- * Camel K Kamelet Binding file
+ * Camel K Pipe file
*/
- private Object preConfigureKameletBinding(Node root, YamlDeserializationContext ctx, Object target, boolean preParse) {
+ private Object preConfigurePipe(Node root, YamlDeserializationContext ctx, Object target, boolean preParse) {
// when in pre-parse phase then we only want to gather /metadata/annotations
List<Object> answer = new ArrayList<>();
@@ -627,7 +631,7 @@ public class YamlRoutesBuilderLoader extends YamlRoutesBuilderLoaderSupport {
route.routeId(routeId);
}
- // kamelet binding is a bit more complex, so grab the source and sink
+ // Pipe is a bit more complex, so grab the source and sink
// and map those to Camel route definitions
MappingNode source = asMappingNode(nodeAt(root, "/spec/source"));
MappingNode sink = asMappingNode(nodeAt(root, "/spec/sink"));
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy
index 5437768777e..e3111c427f7 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy
@@ -68,690 +68,4 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
}
-
- def "kamelet binding from uri to kamelet"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- uri: timer:foo
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- ''')
- then:
- context.routeDefinitions.size() == 2
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'timer:foo'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'kamelet:log-sink'
- }
- }
- }
-
- def "kamelet binding from uri to uri"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- uri: timer:foo
- sink:
- uri: log:bar
- ''')
- then:
- context.routeDefinitions.size() == 1
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'timer:foo'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'log:bar'
- }
- }
- }
-
- def "kamelet binding steps"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: steps-binding
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Camel"
- steps:
- - ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: prefix-action
- properties:
- prefix: "Apache"
- - ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: prefix-action
- properties:
- prefix: "Hello"
- sink:
- uri: log:info
- ''')
- then:
- context.routeDefinitions.size() == 4
-
- with (context.routeDefinitions[0]) {
- routeId == 'steps-binding'
- input.endpointUri == 'kamelet:timer-source?message=Camel'
- input.lineNumber == 7
- outputs.size() == 3
- with (outputs[0], KameletDefinition) {
- name == 'prefix-action?prefix=Apache'
- lineNumber == 14
- }
- with (outputs[1], KameletDefinition) {
- name == 'prefix-action?prefix=Hello'
- lineNumber == 20
- }
- with (outputs[2], ToDefinition) {
- endpointUri == 'log:info'
- lineNumber == 27
- }
- }
- }
-
- def "kamelet binding steps kamelet uri"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: steps-binding
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Camel"
- steps:
- - ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: prefix-action
- properties:
- prefix: "Apache"
- - uri: mock:dummy
- sink:
- uri: log:info
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- routeId == 'steps-binding'
- input.endpointUri == 'kamelet:timer-source?message=Camel'
- outputs.size() == 3
- with (outputs[0], KameletDefinition) {
- name == 'prefix-action?prefix=Apache'
- }
- with (outputs[1], ToDefinition) {
- endpointUri == 'mock:dummy'
- }
- with (outputs[2], ToDefinition) {
- endpointUri == 'log:info'
- }
- }
- }
-
- def "kamelet binding steps uri uri"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: steps-binding
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Camel"
- steps:
- - uri: mock:dummy
- - uri: kamelet:prefix-action?prefix=Apache
- - uri: mock:dummy2
- properties:
- reportGroup: 5
- sink:
- uri: log:info
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- routeId == 'steps-binding'
- input.endpointUri == 'kamelet:timer-source?message=Camel'
- outputs.size() == 4
- with (outputs[0], ToDefinition) {
- endpointUri == 'mock:dummy'
- }
- with (outputs[1], KameletDefinition) {
- name == 'prefix-action?prefix=Apache'
- }
- with (outputs[2], ToDefinition) {
- endpointUri == 'mock:dummy2?reportGroup=5'
- }
- with (outputs[3], ToDefinition) {
- endpointUri == 'log:info'
- }
- }
- }
-
- def "kamelet binding from kamelet to strimzi"() {
- when:
-
- // stub kafka for testing as it requires to setup connection to a real kafka broker
- context.removeComponent("kafka")
- context.addComponent("kafka", context.getComponent("stub"))
-
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: KafkaTopic
- apiVersion: kafka.strimzi.io/v1beta2
- name: my-topic
- ''')
- then:
- context.routeDefinitions.size() == 2
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'kafka:my-topic'
- }
- }
- }
-
- def "kamelet binding with error handler"() {
- when:
-
- // stub kafka for testing as it requires to setup connection to a real kafka broker
- context.addComponent("kafka", context.getComponent("stub"))
-
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- errorHandler:
- sink:
- endpoint:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: error-handler
- properties:
- log-message: "ERROR!"
- kafka-brokers: my-broker
- kafka-topic: my-first-test
- kafka-service-account-id: scott
- kafka-service-account-secret: tiger
- parameters:
- maximumRedeliveries: 1
- redeliveryDelay: 2000
- ''')
- then:
- context.routeDefinitions.size() == 4
-
- with (context.routeDefinitions[0]) {
- errorHandlerFactory != null
- errorHandlerFactory instanceof DeadLetterChannelDefinition
- var eh = errorHandlerFactory as DeadLetterChannelDefinition
- eh.deadLetterUri == 'kamelet:error-handler?kafkaTopic=my-first-test&logMessage=ERROR%21&kafkaServiceAccountId=scott&kafkaBrokers=my-broker&kafkaServiceAccountSecret=tiger'
- eh.redeliveryPolicy.maximumRedeliveries == "1"
- eh.redeliveryPolicy.redeliveryDelay == "2000"
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'kamelet:log-sink'
- }
- }
- }
-
- def "kamelet binding with error handler move to dlq"() {
- when:
-
- context.registry.bind 'chaos', new Processor() {
- @Override
- void process(Exchange exchange) throws Exception {
- throw new IllegalArgumentException("Forced");
- }
- };
-
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- steps:
- - uri: bean:chaos
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- errorHandler:
- sink:
- endpoint:
- uri: mock:dead
- parameters:
- maximumRedeliveries: 3
- redeliveryDelay: 100
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- MockEndpoint mock = context.getEndpoint("mock:dead", MockEndpoint.class)
- mock.expectedMinimumMessageCount(1)
-
- mock.assertIsSatisfied()
-
- with (context.routeDefinitions[0]) {
- errorHandlerFactory != null
- errorHandlerFactory instanceof DeadLetterChannelDefinition
- var eh = errorHandlerFactory as DeadLetterChannelDefinition
- eh.deadLetterUri == 'mock:dead'
- eh.redeliveryPolicy.maximumRedeliveries == "3"
- eh.redeliveryPolicy.redeliveryDelay == "100"
- }
- }
-
- def "kamelet binding with log error handler"() {
- when:
-
- // stub kafka for testing as it requires to setup connection to a real kafka broker
- context.addComponent("kafka", context.getComponent("stub"))
-
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- errorHandler:
- log:
- parameters:
- use-original-message: true
- maximumRedeliveries: 1
- redeliveryDelay: 2000
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- errorHandlerFactory != null
- errorHandlerFactory instanceof DefaultErrorHandlerDefinition
- var eh = errorHandlerFactory as DefaultErrorHandlerDefinition
- eh.redeliveryPolicy.maximumRedeliveries == "1"
- eh.redeliveryPolicy.redeliveryDelay == "2000"
- eh.getUseOriginalMessage() == "true"
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'kamelet:log-sink'
- }
- }
- }
-
- def "kamelet binding with none error handler"() {
- when:
-
- // stub kafka for testing as it requires to setup connection to a real kafka broker
- context.addComponent("kafka", context.getComponent("stub"))
-
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- errorHandler:
- none:
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- errorHandlerFactory != null
- errorHandlerFactory instanceof NoErrorHandlerDefinition
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'kamelet:log-sink'
- }
- }
- }
-
- def "kamelet binding from kamelet to knative"() {
- when:
-
- // stub knative for testing as it requires to setup connection to a real knative broker
- context.removeComponent("knative")
- context.addComponent("knative", context.getComponent("stub"))
-
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: InMemoryChannel
- apiVersion: messaging.knative.dev/v1
- name: my-messages
- ''')
- then:
- context.routeDefinitions.size() == 2
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'knative:channel/my-messages'
- }
- }
- }
-
- def "kamelet start route"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: route-timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- // global stream caching enabled
- context.isStreamCaching() == true
-
- with (context.routeDefinitions[1]) {
- template == true
- // stream-caching is disabled in the kamelet
- streamCache == "false"
- messageHistory == "true"
- }
- }
-
- def "kamelet binding with trait properties"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- annotations:
- trait.camel.apache.org/camel.properties: "foo=howdy,bar=123"
- trait.camel.apache.org/environment.vars: "MY_ENV=cheese"
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- context.resolvePropertyPlaceholders("{{foo}}") == "howdy"
- context.resolvePropertyPlaceholders("{{bar}}") == "123"
- context.resolvePropertyPlaceholders("{{MY_ENV}}") == "cheese"
- }
-
- def "kamelet binding no sink"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- properties:
- message: "Hello world!"
- steps:
- - ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-action
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- input.lineNumber == 7
- outputs.size() == 1
- with (outputs[0], KameletDefinition) {
- name == 'log-action'
- lineNumber == 14
- }
- }
- }
-
- def "kamelet binding with input/output data types"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- dataTypes:
- in:
- format: plain/text
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- dataTypes:
- out:
- format: application/octet-stream
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- input.lineNumber == 7
- inputType.urn == 'plain/text'
- outputType.urn == 'application/octet-stream'
- outputs.size() == 1
- with (outputs[0], ToDefinition) {
- endpointUri == 'kamelet:log-sink'
- lineNumber == 17
- }
- }
- }
-
- def "kamelet binding with data type transformation"() {
- when:
- loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
- metadata:
- name: timer-event-source
- spec:
- source:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: timer-source
- dataTypes:
- out:
- format: application/octet-stream
- properties:
- message: "Hello world!"
- sink:
- ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1
- name: log-sink
- dataTypes:
- in:
- format: plain/text
- ''')
- then:
- context.routeDefinitions.size() == 3
-
- with (context.routeDefinitions[0]) {
- routeId == 'timer-event-source'
- input.endpointUri == 'kamelet:timer-source?message=Hello+world%21'
- input.lineNumber == 7
- outputs.size() == 3
- with (outputs[0], TransformDefinition) {
- fromType == 'camel:any'
- toType == 'application/octet-stream'
- lineNumber == -1
- }
- with (outputs[1], TransformDefinition) {
- fromType == 'camel:any'
- toType == 'plain/text'
- lineNumber == -1
- }
- with (outputs[2], ToDefinition) {
- endpointUri == 'kamelet:log-sink'
- lineNumber == 17
- }
- }
- }
-
}
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
similarity index 90%
copy from dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy
copy to dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
index 5437768777e..f2581179ce1 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/KameletBindingLoaderTest.groovy
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
@@ -27,17 +27,17 @@ import org.apache.camel.model.errorhandler.DeadLetterChannelDefinition
import org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition
import org.apache.camel.model.errorhandler.NoErrorHandlerDefinition
-class KameletBindingLoaderTest extends YamlTestSupport {
+class PipeLoaderTest extends YamlTestSupport {
@Override
def doSetup() {
context.start()
}
- def "kamelet binding from kamelet to kamelet"() {
+ def "Pipe from kamelet to kamelet"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -69,11 +69,11 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding from uri to kamelet"() {
+ def "Pipe from uri to kamelet"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -98,11 +98,11 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding from uri to uri"() {
+ def "Pipe from uri to uri"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -124,13 +124,13 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding steps"() {
+ def "Pipe steps"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
- name: steps-binding
+ name: steps-pipe
spec:
source:
ref:
@@ -159,7 +159,7 @@ class KameletBindingLoaderTest extends YamlTestSupport {
context.routeDefinitions.size() == 4
with (context.routeDefinitions[0]) {
- routeId == 'steps-binding'
+ routeId == 'steps-pipe'
input.endpointUri == 'kamelet:timer-source?message=Camel'
input.lineNumber == 7
outputs.size() == 3
@@ -178,13 +178,13 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding steps kamelet uri"() {
+ def "Pipe steps kamelet uri"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
- name: steps-binding
+ name: steps-pipe
spec:
source:
ref:
@@ -208,7 +208,7 @@ class KameletBindingLoaderTest extends YamlTestSupport {
context.routeDefinitions.size() == 3
with (context.routeDefinitions[0]) {
- routeId == 'steps-binding'
+ routeId == 'steps-pipe'
input.endpointUri == 'kamelet:timer-source?message=Camel'
outputs.size() == 3
with (outputs[0], KameletDefinition) {
@@ -223,13 +223,13 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding steps uri uri"() {
+ def "Pipe steps uri uri"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
- name: steps-binding
+ name: steps-pipe
spec:
source:
ref:
@@ -251,7 +251,7 @@ class KameletBindingLoaderTest extends YamlTestSupport {
context.routeDefinitions.size() == 3
with (context.routeDefinitions[0]) {
- routeId == 'steps-binding'
+ routeId == 'steps-pipe'
input.endpointUri == 'kamelet:timer-source?message=Camel'
outputs.size() == 4
with (outputs[0], ToDefinition) {
@@ -269,7 +269,7 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding from kamelet to strimzi"() {
+ def "Pipe from kamelet to strimzi"() {
when:
// stub kafka for testing as it requires to setup connection to a real kafka broker
@@ -277,8 +277,8 @@ class KameletBindingLoaderTest extends YamlTestSupport {
context.addComponent("kafka", context.getComponent("stub"))
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -308,15 +308,15 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with error handler"() {
+ def "Pipe with error handler"() {
when:
// stub kafka for testing as it requires to setup connection to a real kafka broker
context.addComponent("kafka", context.getComponent("stub"))
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -368,7 +368,7 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with error handler move to dlq"() {
+ def "Pipe with error handler move to dlq"() {
when:
context.registry.bind 'chaos', new Processor() {
@@ -379,8 +379,8 @@ class KameletBindingLoaderTest extends YamlTestSupport {
};
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -424,15 +424,15 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with log error handler"() {
+ def "Pipe with log error handler"() {
when:
// stub kafka for testing as it requires to setup connection to a real kafka broker
context.addComponent("kafka", context.getComponent("stub"))
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -474,15 +474,15 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with none error handler"() {
+ def "Pipe with none error handler"() {
when:
// stub kafka for testing as it requires to setup connection to a real kafka broker
context.addComponent("kafka", context.getComponent("stub"))
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -516,7 +516,7 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding from kamelet to knative"() {
+ def "Pipe from kamelet to knative"() {
when:
// stub knative for testing as it requires to setup connection to a real knative broker
@@ -524,8 +524,8 @@ class KameletBindingLoaderTest extends YamlTestSupport {
context.addComponent("knative", context.getComponent("stub"))
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -558,8 +558,8 @@ class KameletBindingLoaderTest extends YamlTestSupport {
def "kamelet start route"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -590,11 +590,11 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with trait properties"() {
+ def "Pipe with trait properties"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
annotations:
@@ -622,11 +622,11 @@ class KameletBindingLoaderTest extends YamlTestSupport {
context.resolvePropertyPlaceholders("{{MY_ENV}}") == "cheese"
}
- def "kamelet binding no sink"() {
+ def "Pipe no sink"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -658,11 +658,11 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with input/output data types"() {
+ def "Pipe with input/output data types"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec:
@@ -702,11 +702,11 @@ class KameletBindingLoaderTest extends YamlTestSupport {
}
}
- def "kamelet binding with data type transformation"() {
+ def "Pipe with data type transformation"() {
when:
loadBindings('''
- apiVersion: camel.apache.org/v1alpha1
- kind: KameletBinding
+ apiVersion: camel.apache.org/v1
+ kind: Pipe
metadata:
name: timer-event-source
spec: