Repository navigation
Stop the Kafka input-binding example test from losing messages - #1236
Merged
Merged
Conversation
The consumer group used the default initialOffset of newest and was still joining when the sidecar reported ready, so messages published right away were skipped. The test also stopped the receiver after a fixed delay. Start the example's consumer group at the oldest offset and wait for all three messages before stopping the receiver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Casper Nielsen <casper@diagrid.io>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1236 +/- ##
=======================================
Coverage 83.89% 83.89%
=======================================
Files 123 123
Lines 10265 10265
=======================================
Hits 8612 8612
Misses 1653 1653 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1 of 3 tasks
sicoyle
approved these changes
Sep 28, 2026
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
tests/examples/test_invoke_binding.pyfailed on Python 3.14 in this run. The receiver printed only message 3, not 1 or 2.Cause. The log shows daprd ready at 19:58:17.88. The test then published messages 1, 2 and 3 one second apart and stopped the receiver about a second after the last one. The Kafka binding's consumer group was still joining at that point: the broker waits 3 s by default (
group.initial.rebalance.delay.ms) before assigning partitions to a new group. The binding uses the defaultinitialOffsetofnewest, so a new group starts at the end of the topic and skips anything published before it joins. Messages 1 and 2 went out before the join, so they were never delivered. The old mechanical-markdown flow in the README got around this withsleep: 5after starting the receiver. The pytest version lost that gap.There was also a second race: the test stopped the receiver on a fixed schedule rather than once the messages had arrived. A slower join could lose all three.
Fix.
examples/invoke-binding/components/kafka-binding.yaml: setinitialOffset: oldest. A new consumer group then starts at the beginning of the topic, so messages published before it joins are still delivered. The topic is created fresh bydocker compose upfor each test run. For someone running the example by hand against containers they keep, this only affects the group's first join, because later runs resume from the committed offset.DaprRunner.wait_for_output()intests/examples/conftest.pypolls the background service's log every second until it contains every expected line. It gives up if the process exits or the timeout passes, the same way_wait_until_readydoes.test_invoke_bindingno longer sleeps between publishes. It waits up to 60 s for all three messages before stopping the receiver, and the existing assertions still give the failure message.No retries were added. The test passes for the same reason the example now works.
Issue reference
No issue. This is a CI flake seen on #1235.
Checklist
wait_for_outputintests/examples/test_dapr_runner.py(13 passed locally)I couldn't run the Kafka example end to end locally (no Docker daemon), so the example validation on this PR is the real check.
🤖 Generated with Claude Code