-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Avoid Class cast errors in TimestampRouter
- Avoids String to Long Class cast errors in TimestampRouter utility - Add test for timestamp-router-action Kamelet
- Loading branch information
1 parent
2048783
commit 791443d
Showing
5 changed files
with
135 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/camel-kamelets-itest/src/test/resources/kafka/timestamp-router-pipe.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# --------------------------------------------------------------------------- | ||
# 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/v1 | ||
kind: Pipe | ||
metadata: | ||
name: timestamp-router-pipe | ||
spec: | ||
source: | ||
ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: webhook-source | ||
properties: | ||
subpath: messages | ||
steps: | ||
- ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: timestamp-router-action | ||
properties: | ||
topicFormat: $[topic]_$[timestamp] | ||
timestampFormat: YYYY-MM-dd | ||
- ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: set-body-action | ||
properties: | ||
value: $simple{header[message]} | ||
- ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: log-action | ||
properties: | ||
showHeaders: true | ||
sink: | ||
ref: | ||
kind: Kamelet | ||
apiVersion: camel.apache.org/v1 | ||
name: kafka-sink | ||
properties: | ||
bootstrapServers: ${YAKS_TESTCONTAINERS_REDPANDA_LOCAL_BOOTSTRAP_SERVERS} | ||
user: ${user} | ||
password: ${password} | ||
topic: dummy | ||
securityProtocol: ${securityProtocol} |
55 changes: 55 additions & 0 deletions
55
tests/camel-kamelets-itest/src/test/resources/kafka/timestamp-router.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# --------------------------------------------------------------------------- | ||
# 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. | ||
# --------------------------------------------------------------------------- | ||
|
||
Feature: Kafka Timestamp Router | ||
|
||
Background: | ||
Given variable user is "" | ||
Given variable password is "" | ||
Given variables | ||
| securityProtocol | PLAINTEXT | | ||
| topicName | my-topic | | ||
| timestamp | yaks:unixTimestamp()000 | | ||
| topic | ${topicName}_yaks:currentDate('YYYY-MM-dd') | | ||
| message | Camel K rocks! | | ||
Given Kafka topic: ${topic} | ||
Given Kafka topic partition: 0 | ||
|
||
Scenario: Create infrastructure | ||
Given start Redpanda container | ||
|
||
Scenario: Create Pipe | ||
When load Pipe timestamp-router-pipe.yaml | ||
Then Camel K integration timestamp-router-pipe should be running | ||
Then Camel K integration timestamp-router-pipe should print Routes startup | ||
|
||
Scenario: Receive message on Kafka topic and verify sink output | ||
Given new Kafka connection | ||
| url | ${YAKS_TESTCONTAINERS_REDPANDA_LOCAL_BOOTSTRAP_SERVERS} | | ||
| consumerGroup | consumer-1 | | ||
Given URL: yaks:resolveURL('timestamp-router-pipe',8080) | ||
Given HTTP request query parameter kafka.TOPIC="${topicName}" | ||
Given HTTP request query parameter kafka.TIMESTAMP="${timestamp}" | ||
Given HTTP request query parameter message="yaks:urlEncode(${message})" | ||
Given HTTP request fork mode is enabled | ||
When send GET /messages | ||
Then receive Kafka message with body: ${message} | ||
And receive HTTP 200 OK | ||
|
||
Scenario: Remove resources | ||
Given delete Pipe timestamp-router-pipe | ||
And stop Redpanda container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters