Skip to content

Commit

Permalink
fix(apache#3844): Add e2e test for data type converter service discovery
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
christophd authored and squakez committed Jan 10, 2023
1 parent acf7755 commit d1af7f9
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 0 deletions.
41 changes: 41 additions & 0 deletions e2e/yaks/common/kamelet-data-types/event-binding.yaml
Original file line number Diff line number Diff line change
@@ -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}
61 changes: 61 additions & 0 deletions e2e/yaks/common/kamelet-data-types/event-sink.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -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"
62 changes: 62 additions & 0 deletions e2e/yaks/common/kamelet-data-types/event-source.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 15 additions & 0 deletions e2e/yaks/common/kamelet-data-types/kamelet-data-types.feature
Original file line number Diff line number Diff line change
@@ -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!
63 changes: 63 additions & 0 deletions e2e/yaks/common/kamelet-data-types/log-action.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -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/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE2LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgd2lkdGg9IjUxMnB4IiBoZWlnaHQ9IjUxMnB4IiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTEyIDUxMjsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPGc+DQoJPHBhdGggZD0iTTQ0OCwwSDY0QzQ2LjMyOCwwLDMyLDE0LjMxMywzMiwzMnY0NDhjMCwxNy42ODgsMTQuMzI4LDMyLDMyLDMyaDM4NGMxNy42ODgsMCwzMi0xNC4zMTIsMzItMzJWMzINCgkJQzQ4MCwxNC4zMTMsNDY1LjY4OCwwLDQ0OCwweiBNNjQsNDgwVjEyOGg4MHY2NEg5NnYxNmg0OHY0OEg5NnYxNmg0OHY0OEg5NnYxNmg0OHY0OEg5NnYxNmg0OHY4MEg2NHogTTQ0OCw0ODBIMTYwdi04MGgyNTZ2LTE2DQoJCUgxNjB2LTQ4aDI1NnYtMTZIMTYwdi00OGgyNTZ2LTE2SDE2MHYtNDhoMjU2di0xNkgxNjB2LTY0aDI4OFY0ODB6Ii8+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8L3N2Zz4NCg=="
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}}"
42 changes: 42 additions & 0 deletions e2e/yaks/common/kamelet-data-types/yaks-config.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d1af7f9

Please sign in to comment.