Skip to content

test(kafka): fix flaky consumer ignore-topic tests with producer.flush()#2603

Open
dependabot[bot] wants to merge 2 commits intomainfrom
dependabot/github_actions/github-actions-8d02b2c012
Open

test(kafka): fix flaky consumer ignore-topic tests with producer.flush()#2603
dependabot[bot] wants to merge 2 commits intomainfrom
dependabot/github_actions/github-actions-8d02b2c012

Conversation

@dependabot
Copy link
Copy Markdown
Contributor

@dependabot dependabot bot commented on behalf of github Apr 8, 2026

Kafka tests sending to multiple topics were non-deterministic after migrating from bitnami/kafka:3.1 to apache/kafka:4.1.0 (KRaft mode). producer.send() is async — messages to 3 different topics/partitions can arrive at the broker at different times, causing the consumer to poll, receive only foo+bar, then time out before test is committed.

Changes

  • Add producer.flush() after sends in delayed_send for:
    • test_kafka_consumer_ignore_topic
    • test_kafka_consumer_ignore_topic_ongoing_transaction

This ensures all messages are broker-acknowledged before the consumer polls, guaranteeing all 3 are visible within consumer_timeout_ms.

def delayed_send():
    time.sleep(0.2)
    producer.send(topic="foo", key=b"foo", value=b"bar")
    producer.send("bar", key=b"foo", value=b"bar")
    producer.send("test", key=b"foo", value=b"bar")
    producer.flush()  # wait for broker ack before consumer polls

Bumps the github-actions group with 1 update in the / directory: [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish).


Updates `pypa/gh-action-pypi-publish` from 1.13.0 to 1.14.0
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@ed0c539...cef2210)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-version: 1.14.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code labels Apr 8, 2026
@dependabot dependabot bot requested review from a team as code owners April 8, 2026 15:33
@dependabot dependabot bot added dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Copy Markdown
Contributor

@fr4nc1sc0-r4m0n fr4nc1sc0-r4m0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fr4nc1sc0-r4m0n
Copy link
Copy Markdown
Contributor

@copilot fix the testcases

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

@copilot fix the testcases

Fixed in commit 7518ac3c. The failing test test_kafka_consumer_ignore_topic_ongoing_transaction was not receiving the test topic message before consumer_timeout_ms elapsed. With messages sent to 3 different topics (foo, bar, test) asynchronously, they may not all be committed to the broker before the consumer polls — especially with Apache Kafka 4.1.0. Added producer.flush() to delayed_send in both test_kafka_consumer_ignore_topic and test_kafka_consumer_ignore_topic_ongoing_transaction to ensure all messages are acknowledged by the broker before the consumer polls.

Copilot AI changed the title build(deps): bump pypa/gh-action-pypi-publish from 1.13.0 to 1.14.0 in the github-actions group across 1 directory test(kafka): fix flaky consumer ignore-topic tests with producer.flush() Apr 8, 2026
Copilot AI requested a review from fr4nc1sc0-r4m0n April 8, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-python dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants