-
Notifications
You must be signed in to change notification settings - Fork 14.3k
KAFKA-19042: [6/N] Move PlaintextConsumerFetchTest to client-integration-tests module #19520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
); | ||
} | ||
|
||
assertEquals(expected, actual); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please consider comparing the fields one by one to produce accurate error message?
for (var i = 0; i < consumerRecords.size(); i++) {
var producerRecord = producerRecords.get(i);
var consumerRecord = consumerRecords.get(i);
assertEquals(producerRecord.topic(), consumerRecord.topic());
assertEquals(producerRecord.partition(), consumerRecord.partition());
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, addressed it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Leave some minor comments.
try (Producer<byte[], byte[]> producer = cluster.producer()) { | ||
for (var i = 0; i < numRecords; i++) { | ||
sendRecord(producer, tp, startingTimestamp, i, -1); | ||
} | ||
producer.flush(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try (Producer<byte[], byte[]> producer = cluster.producer()) { | |
for (var i = 0; i < numRecords; i++) { | |
sendRecord(producer, tp, startingTimestamp, i, -1); | |
} | |
producer.flush(); | |
} | |
sendRecords(cluster, tp, numRecords, startingTimestamp, -1); |
TopicPartition tp, | ||
int numRecords | ||
) { | ||
sendRecords(cluster, tp, numRecords, System.currentTimeMillis(), -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendRecords(cluster, tp, numRecords, System.currentTimeMillis(), -1); | |
sendRecords(cluster, tp, numRecords, System.currentTimeMillis()); |
assertEquals("value " + keyAndValueIndex, new String(record.value())); | ||
// this is true only because K and V are byte arrays | ||
assertEquals(("key " + keyAndValueIndex).length(), record.serializedKeySize()); | ||
assertEquals(("value " + keyAndValueIndex).length(), record.serializedValueSize()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we define two static variables for "key " and "value "? They are reused many times in this class.
private void testFetchOutOfRangeOffsetResetConfigEarliest(GroupProtocol groupProtocol) throws InterruptedException { | ||
Map<String, Object> config = Map.of( | ||
GROUP_PROTOCOL_CONFIG, groupProtocol.name().toLowerCase(Locale.ROOT), | ||
FETCH_MAX_WAIT_MS_CONFIG, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add comment for this variable?
// ensure no in-flight fetch request so that the offset can be reset immediately
Map<String, Object> config = Map.of( | ||
GROUP_PROTOCOL_CONFIG, groupProtocol.name().toLowerCase(Locale.ROOT), | ||
AUTO_OFFSET_RESET_CONFIG, "latest", | ||
FETCH_MAX_WAIT_MS_CONFIG, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
var produced = producedByPartition.getOrDefault(partition, Collections.emptyList()); | ||
var consumed = consumedByPartition.getOrDefault(partition, Collections.emptyList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var produced = producedByPartition.getOrDefault(partition, Collections.emptyList()); | |
var consumed = consumedByPartition.getOrDefault(partition, Collections.emptyList()); | |
var produced = producedByPartition.getOrDefault(partition, List.of()); | |
var consumed = consumedByPartition.getOrDefault(partition, List.of()); |
cluster.createTopic(topicName, partitionCount, (short) BROKER_COUNT); | ||
} | ||
|
||
List<TopicPartition> partitions = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use HashSet here, so we don't need to use Set.copyOf
?
var records = consumer.poll(Duration.ofMillis(20000)); | ||
assertEquals(1, records.count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reusing consumeRecords
?
var records = consumer.poll(Duration.ofMillis(20000)); | |
assertEquals(1, records.count()); | |
var records = consumeRecords(consumer, 1); | |
assertEquals(1, records.size()); |
var records = consumer.poll(Duration.ofMillis(20000)); | ||
assertEquals(1, records.count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reusing consumerRecords
?
var records = consumer.poll(Duration.ofMillis(20000)); | |
assertEquals(1, records.count()); | |
var records = consumeRecords(consumer, 1); | |
assertEquals(1, records.size()); |
Thanks for @FrankYang0529 comments, addressed all. |
Use Java to rewrite
PlaintextConsumerFetchTest
by new test infra andmove it to client-integration-tests module.