cxm940188 commented on code in PR #23525:
URL: https://github.com/apache/kafka/pull/23525#discussion_r4321932147


##########
metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTest.java:
##########
@@ -1637,6 +1652,54 @@ public void testAppendRecordsAtomically() {
                         appender)).getMessage());
     }
 
+    @ParameterizedTest(name = "numRecords={0}, maxRecordsPerBatch={1}")
+    @CsvSource({
+        "1, 1",
+        "5, 1",
+        "5, 10",
+        "10, 10",
+        "15, 10",

Review Comment:
   Thanks for the suggestion @jsancio. 
   
   For this particular off-by-one, the only trigger is ` records.size() % 
maxRecordsPerBatch == 0`.
   
   - The old loop appended an empty trailing batch solely when the size was an 
exact multiple of the batch size. For `maxRecordsPerBatch=10`, that means 10, 
20, 30, …; 9 and 11 are non-multiples and take the identical code path before 
and after the fix (9 → a single batch of 9; 11 → batches of 10 and 1), so they 
can't exercise the buggy branch. 
   
   - The exact-multiple cases are already covered by "`10, 10`" and "`20, 10`", 
plus every positive size under "`1, 1`" / "`5, 1`" (where every size is a 
multiple). 
   So I'd keep the current matrix rather than add 9/11. 



##########
metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTest.java:
##########
@@ -1637,6 +1652,54 @@ public void testAppendRecordsAtomically() {
                         appender)).getMessage());
     }
 
+    @ParameterizedTest(name = "numRecords={0}, maxRecordsPerBatch={1}")
+    @CsvSource({
+        "1, 1",
+        "5, 1",
+        "5, 10",
+        "10, 10",
+        "15, 10",

Review Comment:
   Thanks for the suggestion @jsancio. 
   
   For this particular off-by-one, the only trigger is ` records.size() % 
maxRecordsPerBatch == 0`.
   
   - The old loop appended an empty trailing batch solely when the size was an 
exact multiple of the batch size. For `maxRecordsPerBatch=10`, that means 10, 
20, 30, …; 9 and 11 are non-multiples and take the identical code path before 
and after the fix (9 → a single batch of 9; 11 → batches of 10 and 1), so they 
can't exercise the buggy branch. 
   
   - The exact-multiple cases are already covered by "`10, 10`" and "`20, 10`", 
plus every positive size under "`1, 1`" / "`5, 1`" (where every size is a 
multiple). 
   
   So I'd keep the current matrix rather than add 9/11. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to