This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d1af7f9b69275c63b7151361037ebda00827f768
Author: Christoph Deppisch <[email protected]>
AuthorDate: Mon Jan 9 15:21:23 2023 +0100

    fix(#3844): Add e2e test for data type converter service discovery
    
    - Kameletes used in the test make use of DataTypeRegistry and classpath 
scan is disabled
    - Data type registry will then perform a lookup of the data types via 
service discovery mechanism
---
 .../common/kamelet-data-types/event-binding.yaml   | 41 ++++++++++++++
 .../kamelet-data-types/event-sink.kamelet.yaml     | 61 +++++++++++++++++++++
 .../kamelet-data-types/event-source.kamelet.yaml   | 62 +++++++++++++++++++++
 .../kamelet-data-types/kamelet-data-types.feature  | 15 ++++++
 .../kamelet-data-types/log-action.kamelet.yaml     | 63 ++++++++++++++++++++++
 .../common/kamelet-data-types/yaks-config.yaml     | 42 +++++++++++++++
 6 files changed, 284 insertions(+)

diff --git a/e2e/yaks/common/kamelet-data-types/event-binding.yaml 
b/e2e/yaks/common/kamelet-data-types/event-binding.yaml
new file mode 100644
index 000000000..42f1d6771
--- /dev/null
+++ b/e2e/yaks/common/kamelet-data-types/event-binding.yaml
@@ -0,0 +1,41 @@
+# ---------------------------------------------------------------------------
+# 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/v1alpha1
+kind: KameletBinding
+metadata:
+  name: event-binding
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: event-source
+    properties:
+      outputFormat: ${outputFormat}
+  steps:
+    - ref:
+        kind: Kamelet
+        apiVersion: camel.apache.org/v1alpha1
+        name: log-action
+  sink:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: event-sink
+    properties:
+      inputFormat: ${inputFormat}
diff --git a/e2e/yaks/common/kamelet-data-types/event-sink.kamelet.yaml 
b/e2e/yaks/common/kamelet-data-types/event-sink.kamelet.yaml
new file mode 100644
index 000000000..94b254ecf
--- /dev/null
+++ b/e2e/yaks/common/kamelet-data-types/event-sink.kamelet.yaml
@@ -0,0 +1,61 @@
+# ---------------------------------------------------------------------------
+# 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/v1alpha1
+kind: Kamelet
+metadata:
+  name: event-sink
+  labels:
+    camel.apache.org/kamelet.type: "sink"
+spec:
+  definition:
+    title: "Event Sink"
+    description: "Handles incoming event with data type auto conversion"
+    required:
+      - inputFormat
+    properties:
+      inputFormat:
+        title: Input Format
+        description: The data type to convert incoming events to
+        type: string
+  dependencies:
+    - github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT
+    - "camel:core"
+    - "camel:kamelet"
+  template:
+    beans:
+      - name: dataTypeRegistry
+        type: 
"#class:org.apache.camel.kamelets.utils.format.DefaultDataTypeRegistry"
+        property:
+          - key: classpathScan
+            value: false
+      - name: inputTypeProcessor
+        type: "#class:org.apache.camel.kamelets.utils.format.DataTypeProcessor"
+        property:
+          - key: scheme
+            value: 'camel'
+          - key: format
+            value: '{{inputFormat}}'
+          - key: registry
+            value: '#bean:{{dataTypeRegistry}}'
+    from:
+      uri: "kamelet:source"
+      steps:
+        - process:
+            ref: "{{inputTypeProcessor}}"
+        - to:
+            uri: "log:info"
diff --git a/e2e/yaks/common/kamelet-data-types/event-source.kamelet.yaml 
b/e2e/yaks/common/kamelet-data-types/event-source.kamelet.yaml
new file mode 100644
index 000000000..10cc5fcb2
--- /dev/null
+++ b/e2e/yaks/common/kamelet-data-types/event-source.kamelet.yaml
@@ -0,0 +1,62 @@
+# ---------------------------------------------------------------------------
+# 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/v1alpha1
+kind: Kamelet
+metadata:
+  name: event-source
+  labels:
+    camel.apache.org/kamelet.type: "source"
+spec:
+  definition:
+    title: "Event Source"
+    description: "Produces events in given data type"
+    required:
+      - outputFormat
+    properties:
+      outputFormat:
+        title: Output Format
+        description: The data type of produced events
+        type: string
+  dependencies:
+    - github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT
+    - "camel:core"
+    - "camel:kamelet"
+  template:
+    beans:
+      - name: dataTypeRegistry
+        type: 
"#class:org.apache.camel.kamelets.utils.format.DefaultDataTypeRegistry"
+        property:
+          - key: classpathScan
+            value: false
+      - name: outputTypeProcessor
+        type: "#class:org.apache.camel.kamelets.utils.format.DataTypeProcessor"
+        property:
+          - key: scheme
+            value: 'camel'
+          - key: format
+            value: '{{outputFormat}}'
+          - key: registry
+            value: '#bean:{{dataTypeRegistry}}'
+    from:
+      uri: timer:tick
+      steps:
+        - set-body:
+            constant: "Hello from Camel K!"
+        - process:
+            ref: "{{outputTypeProcessor}}"
+        - to: "kamelet:sink"
diff --git a/e2e/yaks/common/kamelet-data-types/kamelet-data-types.feature 
b/e2e/yaks/common/kamelet-data-types/kamelet-data-types.feature
new file mode 100644
index 000000000..a30ecc5d5
--- /dev/null
+++ b/e2e/yaks/common/kamelet-data-types/kamelet-data-types.feature
@@ -0,0 +1,15 @@
+Feature: Kamelets with data types
+
+  Background:
+    Given Camel K resource polling configuration
+      | maxAttempts          | 200  |
+      | delayBetweenAttempts | 4000 |
+
+  Scenario: Kamelet event data type conversion
+    Given variables
+    | outputFormat | binary |
+    | inputFormat  | string |
+    Given load KameletBinding event-binding.yaml
+    Given Camel K integration event-binding is running
+    Then Camel K integration event-binding should print BodyType: byte[], 
Body: Hello from Camel K!
+    Then Camel K integration event-binding should print BodyType: String, 
Body: Hello from Camel K!
diff --git a/e2e/yaks/common/kamelet-data-types/log-action.kamelet.yaml 
b/e2e/yaks/common/kamelet-data-types/log-action.kamelet.yaml
new file mode 100644
index 000000000..9461ee6ab
--- /dev/null
+++ b/e2e/yaks/common/kamelet-data-types/log-action.kamelet.yaml
@@ -0,0 +1,63 @@
+# ---------------------------------------------------------------------------
+# 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/v1alpha1
+kind: Kamelet
+metadata:
+  name: log-action
+  annotations:
+    camel.apache.org/kamelet.support.level: "Stable"
+    camel.apache.org/catalog.version: "main-SNAPSHOT"
+    camel.apache.org/kamelet.icon: 
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE2LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodH
 [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "Logging"
+  labels:
+    camel.apache.org/kamelet.type: "action"
+spec:
+  definition:
+    title: "Log Action"
+    description: |-
+      Logs all data that flows between source and sink, useful for debugging 
purposes.
+    type: object
+    properties:
+      loggerName:
+        title: Logger Name
+        description: Name of the logging category to use
+        type: string
+        default: "log-action"
+      level:
+        title: Log Level
+        description: Logging level to use
+        type: string
+        default: "INFO"
+        x-descriptors:
+        - 'urn:alm:descriptor:com.tectonic.ui:select:TRACE'
+        - 'urn:alm:descriptor:com.tectonic.ui:select:DEBUG'
+        - 'urn:alm:descriptor:com.tectonic.ui:select:INFO'
+        - 'urn:alm:descriptor:com.tectonic.ui:select:WARN'
+        - 'urn:alm:descriptor:com.tectonic.ui:select:ERROR'
+        - 'urn:alm:descriptor:com.tectonic.ui:select:OFF'
+  dependencies:
+  - "camel:kamelet"
+  - "camel:log"
+  template:
+    from:
+      uri: "kamelet:source"
+      steps:
+      - to:
+          uri: "log:{{loggerName}}"
+          parameters:
+            level: "{{?level}}"
diff --git a/e2e/yaks/common/kamelet-data-types/yaks-config.yaml 
b/e2e/yaks/common/kamelet-data-types/yaks-config.yaml
new file mode 100644
index 000000000..c53dce8f2
--- /dev/null
+++ b/e2e/yaks/common/kamelet-data-types/yaks-config.yaml
@@ -0,0 +1,42 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+config:
+  namespace:
+    temporary: true
+  runtime:
+    env:
+      - name: CITRUS_TYPE_CONVERTER
+        value: camel
+    settings:
+      loggers:
+        - name: INTEGRATION_STATUS
+          level: INFO
+        - name: INTEGRATION_LOGS
+          level: INFO
+    resources:
+      - event-binding.yaml
+pre:
+- name: installation
+  run: |
+    kubectl apply -f event-source.kamelet.yaml -n $YAKS_NAMESPACE
+    kubectl apply -f event-sink.kamelet.yaml -n $YAKS_NAMESPACE
+    kubectl apply -f log-action.kamelet.yaml -n $YAKS_NAMESPACE
+post:
+  - name: print dump
+    if: env:CI=true && failure()
+    run: yaks dump --includes app=camel-k

Reply via email to