forked from kroxylicious/kroxylicious
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[System Tests] Added Consumer Record support for consumers (kroxylici…
…ous#1290) * Added Consumer Record support for consumers Signed-off-by: Francisco Vila <[email protected]> * formatted Signed-off-by: Francisco Vila <[email protected]> * added kafka clients dependency Signed-off-by: Francisco Vila <[email protected]> * removed methods from KafkaClient API Signed-off-by: Francisco Vila <[email protected]> * refactor to deserialize only once per message Signed-off-by: Francisco Vila <[email protected]> * created consumer records for each kafka client Signed-off-by: Francisco Vila <[email protected]> * created consumer records for each kafka client Signed-off-by: Francisco Vila <[email protected]> * fix format Signed-off-by: Francisco Vila <[email protected]> * fixed Entry for ClientConsumerRecord Signed-off-by: Francisco Vila <[email protected]> * improve logging in error Signed-off-by: Francisco Vila <[email protected]> * Update kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/clients/records/KafConsumerRecord.java Co-authored-by: Keith Wall <[email protected]> Signed-off-by: Francisco Vila <[email protected]> * refactored kafka clients Signed-off-by: Francisco Vila <[email protected]> * format Signed-off-by: Francisco Vila <[email protected]> * Update kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/clients/KafClient.java Co-authored-by: Keith Wall <[email protected]> Signed-off-by: Francisco Vila <[email protected]> * refactored getNumberOfJsonMessages Signed-off-by: Francisco Vila <[email protected]> * Refactor BaseConsumerRecord and kafka clients consumerRecords Signed-off-by: Francisco Vila <[email protected]> * format Signed-off-by: Francisco Vila <[email protected]> * added dependency in pom file Signed-off-by: Francisco Vila <[email protected]> * fix null pointer exception Signed-off-by: Francisco Vila <[email protected]> * align parameters each in one line Signed-off-by: Francisco Vila <[email protected]> * Setting String type for key Signed-off-by: Francisco Vila <[email protected]> * inline objectMapper Signed-off-by: Francisco Vila <[email protected]> * added JsonIgnoreProperties and refactored BaseConsumerRecord to ConsumerRecord Signed-off-by: Francisco Vila <[email protected]> * fixes Signed-off-by: Francisco Vila <[email protected]> * remove getTimestamType method Signed-off-by: Francisco Vila <[email protected]> * fix format Signed-off-by: Francisco Vila <[email protected]> * removed kafka clients from pom file Signed-off-by: Francisco Vila <[email protected]> * rename payload to value Signed-off-by: Francisco Vila <[email protected]> * add more Keith's suggestions Signed-off-by: Francisco Vila <[email protected]> * format Signed-off-by: Francisco Vila <[email protected]> * fix issue Signed-off-by: Francisco Vila <[email protected]> --------- Signed-off-by: Francisco Vila <[email protected]> Signed-off-by: Francisco Vila <[email protected]> Co-authored-by: Keith Wall <[email protected]>
- Loading branch information
Showing
21 changed files
with
562 additions
and
145 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
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
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
82 changes: 82 additions & 0 deletions
82
...systemtests/src/main/java/io/kroxylicious/systemtests/clients/records/ConsumerRecord.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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright Kroxylicious Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package io.kroxylicious.systemtests.clients.records; | ||
|
||
import java.io.UncheckedIOException; | ||
import java.util.Map; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class ConsumerRecord { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerRecord.class); | ||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); | ||
|
||
protected String topic; | ||
protected String key; | ||
protected String value; | ||
protected int partition; | ||
protected long offset; | ||
protected Map<String, String> recordHeaders; | ||
|
||
public String getTopic() { | ||
return topic; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public int getPartition() { | ||
return partition; | ||
} | ||
|
||
public long getOffset() { | ||
return offset; | ||
} | ||
|
||
public Map<String, String> getRecordHeaders() { | ||
return recordHeaders; | ||
} | ||
|
||
/** | ||
* Parse from json string t. | ||
* | ||
* @param <T> the type parameter | ||
* @param valueTypeRef the value type ref | ||
* @param response the response | ||
* @return the t | ||
*/ | ||
public static <T> T parseFromJsonString(TypeReference<T> valueTypeRef, String response) { | ||
try { | ||
return OBJECT_MAPPER.readValue(response, valueTypeRef); | ||
} | ||
catch (JsonProcessingException e) { | ||
LOGGER.atError().setMessage("Something bad happened").setCause(e).log(); | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ConsumerRecord(topic: " + this.topic + | ||
", key: " + this.key + | ||
", value: " + this.value + | ||
", partition: " + this.partition + | ||
", offset: " + this.offset + | ||
", headers: " + this.recordHeaders + | ||
")"; | ||
} | ||
} |
Oops, something went wrong.