You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "C0urante (via GitHub)" <gi...@apache.org> on 2023/06/06 17:02:18 UTC
[GitHub] [kafka] C0urante commented on a diff in pull request #13816: MINOR: Optimize runtime of MM2 integration tests by batching transactions
C0urante commented on code in PR #13816:
URL: https://github.com/apache/kafka/pull/13816#discussion_r1219842657
##########
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/TestUtils.java:
##########
@@ -34,14 +38,39 @@ static Map<String, String> makeProps(String... keyValues) {
}
return props;
}
-
- /*
- * return records with different but predictable key and value
+
+ /**
+ * Assemble a collection of records arbitrarily distributed across all partitions of the specified topic
+ * @param topicName Destination topic
+ * @param numRecords count of records to produce to the topic in total
+ * @return A batch of records that can be sent to a producer.
*/
- public static Map<String, String> generateRecords(int numRecords) {
- Map<String, String> records = new HashMap<>();
+ public static List<ProducerRecord<byte[], byte[]>> generateRecords(String topicName, int numRecords) {
+ List<ProducerRecord<byte[], byte[]>> records = new ArrayList<>();
for (int i = 0; i < numRecords; i++) {
- records.put("key-" + i, "message-" + i);
+ String key = "key-" + i;
+ String value = "message-" + i;
+ records.add(new ProducerRecord<>(topicName, null, key.getBytes(), value.getBytes()));
+ }
+ return records;
+ }
+
+ /**
+ * Assemble a collection of records evenly distributed across some partitions of the specified topic
Review Comment:
We may want to add a note here that, if `numPartitions` is greater than one, this will cause records with the same key to be written to different partitions.
##########
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/MirrorConnectorsIntegrationBaseTest.java:
##########
@@ -234,6 +245,8 @@ public void startClusters(Map<String, String> additionalMM2Config) throws Except
@AfterEach
public void shutdownClusters() throws Exception {
try {
+ primaryProducer.close();
+ backupProducer.close();
Review Comment:
We probably still want to try to gracefully shut down the cluster even if we encounter an error with stopping our producers:
```suggestion
Utils.closeQuietly(primaryProducer);
Utils.closeQuietly(backupProducer);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org