fix(ci): wait for the kafka broker before creating topics#13709
Open
AlinsRan wants to merge 1 commit into
Open
fix(ci): wait for the kafka broker before creating topics#13709AlinsRan wants to merge 1 commit into
AlinsRan wants to merge 1 commit into
Conversation
Topic creation ran as soon as the containers were up, so when the broker had not registered in ZooKeeper yet the command failed with "Replication factor: 1 larger than available brokers: 0". The error was ignored, and because KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE is on, the topic was then auto-created with the default single partition on first produce. That is what makes t/plugin/kafka-logger.t TEST 18 flaky: it expects test3 to have 3 partitions and asserts partition ids 0, 1 and 2 are all logged, but every message goes to partition 0 when the topic silently degrades to one partition. Retry topic creation until the broker accepts it, and fail the setup instead of starting a test run against a wrong partition layout.
AlinsRan
force-pushed
the
test/kafka-logger-partition-flaky
branch
from
July 20, 2026 05:17
c8e53b1 to
66a43ef
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
t/plugin/kafka-logger.tTEST 18 fails intermittently in CI, e.g. https://github.com/apache/apisix/actions/runs/29567552409/job/88251295446:The cause is in the CI setup, not in the test. Earlier in the same job log:
ci/init-plugin-test-service.shcreates the topics right aftermake ci-env-upreturns. When the broker has not registered itself in ZooKeeper yet, creatingtest2andtest3fails. The failure is ignored, and sinceKAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true,test3is then auto-created with the broker default of one partition on first produce.TEST 18 expects
test3to have 3 partitions and asserts that partition ids 0, 1 and 2 all show up in the error log. With a single-partition topic every message goes to partition 0, sopartition_id: 1andpartition_id: 2never appear — exactly the observed failure. Whether the run is affected depends purely on broker startup timing, which is why it looks flaky.Fix: retry topic creation until the broker accepts it, and fail the setup loudly instead of starting a test run against a wrong partition layout.
ci/init-last-test-service.shhad the same pattern and gets the same treatment.Verified locally by reproducing the race (broker deliberately started 20s late):
and the resulting topic has the expected layout:
Checklist