Skip to content

chore(asyncpg): fix flaky test_execute_after_patch_unpatch_patch#18199

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
dd/fix/flaky-asyncpg-patch-cycle-test
May 21, 2026
Merged

chore(asyncpg): fix flaky test_execute_after_patch_unpatch_patch#18199
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
dd/fix/flaky-asyncpg-patch-cycle-test

Conversation

@quinna-h
Copy link
Copy Markdown
Contributor

@quinna-h quinna-h commented May 20, 2026

Description

Flaky test ID: DD_U9AQCP

Fixing test_execute_after_patch_unpatch_patch[py3.10]Questions? Ask in #code-gen-flaky-tests

This change stabilizes test_execute_after_patch_unpatch_patch in tests/contrib/asyncpg/test_asyncpg.py.

The flaky failure ('function' object has no attribute '__wrapped__') was categorized as order-dependent and was caused by the test using the patched_conn fixture, which creates the connection before the explicit unpatch()/patch() cycle being validated. That allowed prior test ordering and global asyncpg patch state transitions to influence this test's connection state.

Changes

  • Updated test_execute_after_patch_unpatch_patch to stop using the patched_conn fixture.
  • Created a fresh connection after the unpatch()/patch() cycle inside the test.
  • Added explicit connection cleanup in a try/finally block.

Testing

Risks

Low risk. The change is test-only and narrows scope to per-test local setup/cleanup, improving isolation without changing production behavior.

Additional Notes

None.


PR by Bits - View session in Datadog

Comment @DataDog to request changes

@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 20, 2026

View session in Datadog

Bits Dev status: ✅ Done

Comment @DataDog to request changes

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown
Contributor

I can only run on private repositories.

@quinna-h quinna-h changed the title Fix flaky test_execute_after_patch_unpatch_patch chore(asyncpg): fix flaky test_execute_after_patch_unpatch_patch May 20, 2026
@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 20, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 8 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1]   View in Datadog   GitLab

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. NotImplementedError: This version of CPython is not supported yet

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741491-d2b8243-musllinux_1_2_x86_64, 1]   View in Datadog   GitLab

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Dependency download failed: 404 Not Found for opentelemetry-api==1.42.1.

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. NotImplementedError: This version of CPython is not supported yet during import of ddtrace.

View all 8 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 12c511b | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Codeowners resolved as

tests/contrib/asyncpg/test_asyncpg.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python

@quinna-h quinna-h added changelog/no-changelog A changelog entry is not required for this PR. ai-generated PR created with AI assistance labels May 20, 2026
@quinna-h quinna-h marked this pull request as ready for review May 21, 2026 17:03
@quinna-h quinna-h requested review from a team as code owners May 21, 2026 17:03
@quinna-h quinna-h requested review from brettlangdon and wconti27 May 21, 2026 17:03
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 83e6d7c into main May 21, 2026
316 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the dd/fix/flaky-asyncpg-patch-cycle-test branch May 21, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated PR created with AI assistance Bits AI changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants