Skip to content

Fix/aiokafka tests fixes#4384

Merged
xrmx merged 7 commits intoopen-telemetry:mainfrom
dorlib:fix/aiokafka-tests-fixes
Apr 3, 2026
Merged

Fix/aiokafka tests fixes#4384
xrmx merged 7 commits intoopen-telemetry:mainfrom
dorlib:fix/aiokafka-tests-fixes

Conversation

@dorlib
Copy link
Copy Markdown
Contributor

@dorlib dorlib commented Apr 1, 2026

Description

Fix two pre-existing test warnings in the aiokafka instrumentation test suite:

  1. Unclosed AIOKafkaProducer in test_send_and_wait, the test creates a producer via producer_factory() but never closes it. Fixed by wrapping the test body in try/finally and calling await producer.stop().

  2. RuntimeWarning: coroutine was never awaited in test_wrap_getmany, the _create_consumer_span mock was declared as mock.MagicMock but the real function is async. The return value's method calls produced unawaited coroutines. Fixed by changing the type hint to mock.AsyncMock.

Fixes #4383

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • tox -e py3-test-instrumentation-aiokafka all 17 tests pass
  • Verified Unclosed AIOKafkaProducer warning no longer appears
  • Verified RuntimeWarning: coroutine was never awaited no longer appears during test execution
  • Ran with -W error::RuntimeWarning all 17 tests still pass

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

Thanks again @dorlib ! Runs like this one are quieter.

Please could you do a tox -e precommit for some formatting fixes.

@tammy-baylis-swi tammy-baylis-swi moved this to Reviewed PRs that need fixes in Python PR digest Apr 2, 2026
@xrmx xrmx moved this from Reviewed PRs that need fixes to Approved PRs in Python PR digest Apr 2, 2026
@xrmx xrmx merged commit 4d266a0 into open-telemetry:main Apr 3, 2026
860 checks passed
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Python PR digest Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-aiokafka: test warnings — Unclosed AIOKafkaProducer and unawaited coroutine

4 participants