-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added kafka-testing cases for seekEpoch and seekTimestamp
- Loading branch information
Showing
5 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
core/src/main/java/org/jsmart/zerocode/core/kafka/consume/SeekTimestamp.java
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
11 changes: 11 additions & 0 deletions
11
kafka-testing/src/main/java/org/jsmart/zerocode/zerocodejavaexec/utils/ExampleUtils.java
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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package org.jsmart.zerocode.zerocodejavaexec.utils; | ||
|
||
import org.jsmart.zerocode.core.kafka.consume.SeekTimestamp; | ||
|
||
import java.text.DateFormat; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
|
||
public class ExampleUtils { | ||
|
||
public String seekTimestampToEpoch(SeekTimestamp seekTimestamp) throws ParseException { | ||
DateFormat dateFormat = new SimpleDateFormat(seekTimestamp.getFormat()); | ||
return String.valueOf(dateFormat.parse(seekTimestamp.getTimestamp()).toInstant().toEpochMilli()); | ||
} | ||
|
||
} |
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
105 changes: 105 additions & 0 deletions
105
...testing/src/test/resources/kafka/consume/test_kafka_consume_seek_epoch_and_timestamp.json
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,105 @@ | ||
{ | ||
"scenarioName": "Consume message after timestamp/epoch", | ||
"steps": [ | ||
{ | ||
"name": "load_kafka_before_timestamp", | ||
"url": "kafka-topic:demo-seekTime", | ||
"operation": "PRODUCE", | ||
"request": { | ||
"records": [ | ||
{ | ||
"key": "${RANDOM.NUMBER}", | ||
"value": "Before Timestamp 1" | ||
}, | ||
{ | ||
"key": "${RANDOM.NUMBER}", | ||
"value": "Before Timestamp 2" | ||
} | ||
] | ||
}, | ||
"assertions": { | ||
"status": "Ok" | ||
} | ||
}, | ||
{ | ||
"name": "load_timestamp_and_epoch", | ||
"url": "org.jsmart.zerocode.zerocodejavaexec.utils.ExampleUtils", | ||
"operation": "seekTimestampToEpoch", | ||
"request": { | ||
"timestamp": "${LOCAL.DATETIME.NOW:yyyy-MM-dd'T'HH:mm:ss.SSS}", | ||
"format": "yyyy-MM-dd'T'HH:mm:ss.SSS" | ||
}, | ||
"assertions": {} | ||
}, | ||
{ | ||
"name": "load_kafka_after_timestamp", | ||
"url": "kafka-topic:demo-seekTime", | ||
"operation": "PRODUCE", | ||
"request": { | ||
"records": [ | ||
{ | ||
"key": "${RANDOM.NUMBER}", | ||
"value": "After Timestamp 1" | ||
}, | ||
{ | ||
"key": "${RANDOM.NUMBER}", | ||
"value": "After Timestamp 2" | ||
} | ||
] | ||
}, | ||
"assertions": { | ||
"status": "Ok" | ||
} | ||
}, | ||
{ | ||
"name": "consume_seekEpoch", | ||
"url": "kafka-topic:demo-seekTime", | ||
"operation": "CONSUME", | ||
"request": { | ||
"consumerLocalConfigs": { | ||
"seekEpoch": "${$.load_timestamp_and_epoch.response}", | ||
"commitSync": true, | ||
"recordType": "RAW", | ||
"showRecordsConsumed": true, | ||
"maxNoOfRetryPollsOrTimeouts": 3 | ||
} | ||
}, | ||
"verify": { | ||
"records": [ | ||
{ | ||
"value": "After Timestamp 1" | ||
}, | ||
{ | ||
"value": "After Timestamp 2" | ||
} | ||
] | ||
}}, | ||
{ | ||
"name": "consume_seekTimestamp", | ||
"url": "kafka-topic:demo-seekTime", | ||
"operation": "CONSUME", | ||
"request": { | ||
"consumerLocalConfigs": { | ||
"seekTimestamp": { | ||
"timestamp": "${$.load_timestamp_and_epoch.request.timestamp}", | ||
"format": "${$.load_timestamp_and_epoch.request.format}" | ||
}, | ||
"commitSync": true, | ||
"recordType": "RAW", | ||
"showRecordsConsumed": true, | ||
"maxNoOfRetryPollsOrTimeouts": 3 | ||
} | ||
}, | ||
"verify": { | ||
"records": [ | ||
{ | ||
"value": "After Timestamp 1" | ||
}, | ||
{ | ||
"value": "After Timestamp 2" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |