You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by al...@apache.org on 2026/07/20 03:25:00 UTC

(apisix) branch test/kafka-logger-partition-flaky created (now c8e53b1c2)

This is an automated email from the ASF dual-hosted git repository.

AlinsRan pushed a change to branch test/kafka-logger-partition-flaky
in repository https://gitbox.apache.org/repos/asf/apisix.git


      at c8e53b1c2 test(kafka-logger): fix flaky partition distribution assertion

This branch includes the following new commits:

     new c8e53b1c2 test(kafka-logger): fix flaky partition distribution assertion

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(apisix) 01/01: test(kafka-logger): fix flaky partition distribution assertion

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

AlinsRan pushed a commit to branch test/kafka-logger-partition-flaky
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit c8e53b1c22fd88e1d782d7cd1a52b24e689dc87c
Author: AlinsRan <al...@apache.org>
AuthorDate: Mon Jul 20 11:24:39 2026 +0800

    test(kafka-logger): fix flaky partition distribution assertion
    
    TEST 18 sent exactly three requests to a three-partition topic and required
    all three partition ids to show up. lua-resty-kafka chooses the partition
    with `correlation_id % partition_num`, and the correlation id advances once
    per produce request rather than once per message, so any retry shifts the
    rotation and two messages land on the same partition, leaving an expected
    partition id absent from the error log.
    
    Send six requests instead of three so a transient retry no longer removes a
    partition from the run, and drop the 1s timeout that made those retries
    likely in the first place.
---
 t/plugin/kafka-logger.t | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/t/plugin/kafka-logger.t b/t/plugin/kafka-logger.t
index 6e355ba81..6e04f1ca7 100644
--- a/t/plugin/kafka-logger.t
+++ b/t/plugin/kafka-logger.t
@@ -549,7 +549,6 @@ passed
                                 },
                                 "kafka_topic" : "test3",
                                 "producer_type": "sync",
-                                "timeout" : 1,
                                 "batch_max_size": 1,
                                 "include_req_body": false
                             }
@@ -564,15 +563,17 @@ passed
                 }]]
                 )
 
-            t('/hello',ngx.HTTP_GET)
-            ngx.sleep(0.5)
-            t('/hello',ngx.HTTP_GET)
-            ngx.sleep(0.5)
-            t('/hello',ngx.HTTP_GET)
-            ngx.sleep(0.5)
+            -- lua-resty-kafka picks the partition with `correlation_id % partition_num`,
+            -- and the correlation id advances per produce request rather than per
+            -- message, so a single retry shifts the rotation. Send more requests than
+            -- the partition count so every partition is still covered when that happens.
+            for _ = 1, 6 do
+                t('/hello', ngx.HTTP_GET)
+                ngx.sleep(0.2)
+            end
         }
     }
---- timeout: 5s
+--- timeout: 10s
 --- ignore_response
 --- error_log eval
 [qr/partition_id: 1/,