Skip to content

Limit testcontainersTest xdist concurrency and avoid overlap with postCommitPyIT - #41777

Merged
damccorm merged 2 commits into
masterfrom
fix/python-testcontainers-concurrency-46360492005
Dec 3, 2026
Merged

damccorm merged 2 commits into
masterfrom
fix/python-testcontainers-concurrency-46360492005

Conversation

@damccorm

@damccorm damccorm commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:

  • The PR is an appropriate fix for the issue (e.g. we're not changing a test to avoid a bug)
  • The PR is a simple fix to the issue (e.g. we're not adding infra when we could just modify a test)
  • The PR is not covering for other problems (e.g. if we're bumping timeouts, it is not because we're covering for a performance problem)

Full details of the methodology of generation and review can be found here - https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing

If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)

Summary

Fixes repeated DinD /run tmpfs exhaustion (io.containerd.runc.v2: write /run/docker/containerd/daemon/...: no space left on device) in PostCommit Python (py313), which occurred 6 times in 7 days across 7 distinct highmem22 pods (runs https://github.com/apache/beam/actions/runs/45665899847, https://github.com/apache/beam/actions/runs/45868651102, https://github.com/apache/beam/actions/runs/45946466565, https://github.com/apache/beam/actions/runs/46112600361, https://github.com/apache/beam/actions/runs/46171031694, https://github.com/apache/beam/actions/runs/46202099310, and https://github.com/apache/beam/actions/runs/46360492005).

Root Cause

Since #41648 unskipped the 35 Redis uses_testcontainer tests, :sdks:python:test-suites:direct:py313:testcontainersTest ran with basicTestOpts's --numprocesses=8 concurrently with :sdks:python:test-suites:portable:py313:postCommitPy313IT (CrossLanguageDebeziumIOTest, launching localstack, debezium/example-postgres, and apache/beam_java21_sdk). The combined container burst transiently exhausts the docker:24.0.7-dind-alpine3.18 sidecar's /run tmpfs.

Changes

  • sdks/python/test-suites/direct/common.gradle: Factor shared pytest options into commonTestOpts, define a dedicated testcontainersTestOpts (--numprocesses=2) alongside basicTestOpts (--numprocesses=8), use testcontainersTestOpts in testcontainersTest, and add mustRunAfter ":sdks:python:test-suites:portable:py${pythonVersionSuffix}:postCommitPy${pythonVersionSuffix}IT".

Verification

  • Triggered beam_PostCommit_Python.yml workflow run on branch: 47130183867 (prior passing run before refactor: 46452371330)

@damccorm damccorm added the test-failure-cleanup Automated test health and flake cleanup PRs label Nov 30, 2026
@damccorm

Copy link
Copy Markdown
Contributor Author

/gemini review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR mitigates DinD /run tmpfs exhaustion during Python PostCommit runs by serializing :sdks:python:test-suites:direct:py*:testcontainersTest after :sdks:python:test-suites:portable:py*:postCommitPy*IT and lowering pytest-xdist concurrency from 8 to 2 workers for testcontainersTest. The changes in sdks/python/test-suites/direct/common.gradle are clean, targeted, and directly address the container burst root cause.

🔍 General Feedback

  • Using mustRunAfter with the interpolated pythonVersionSuffix properly orders the direct and portable suites when both are part of the task graph (such as in python313PostCommit) without introducing an unnecessary hard dependency when running testcontainersTest standalone.
  • Capping --numprocesses to 2 for testcontainersTest significantly reduces concurrent container creation overhead on the shared DinD sidecar.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions github-actions Bot added python size/xs XS: <10 lines changed labels Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.19%. Comparing base (3c2b7a7) to head (ac24051).
⚠️ Report is 110 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #41777      +/-   ##
============================================
+ Coverage     58.12%   58.19%   +0.07%     
  Complexity     2843     2843              
============================================
  Files          1211     1211              
  Lines        173473   173799     +326     
  Branches       2329     2329              
============================================
+ Hits         100824   101149     +325     
- Misses        69940    69941       +1     
  Partials       2709     2709              
Flag Coverage Δ
python 80.83% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@damccorm damccorm added the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Nov 30, 2026
@damccorm

damccorm commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@damccorm
damccorm marked this pull request as ready for review December 3, 2026 14:45
@damccorm damccorm removed the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Dec 3, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR mitigates DinD /run tmpfs exhaustion during PostCommit Python runs by reducing pytest-xdist concurrency (--numprocesses=2) for testcontainersTest and ordering it after postCommitPy${pythonVersionSuffix}IT. The refactoring of shared pytest options into commonTestOpts alongside dedicated basicTestOpts and testcontainersTestOpts in sdks/python/test-suites/direct/common.gradle is clean, idiomatic, and well-scoped.

🔍 General Feedback

  • Factoring out commonTestOpts avoids brittle list transformations while keeping test option sets explicit.
  • Using mustRunAfter appropriately prevents overlapping container bursts when both tasks are in the execution graph without introducing an unnecessary hard dependency when running testcontainersTest standalone.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @shunping for label python.
Backup reviewer: tvalentyn (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@shunping shunping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@damccorm
damccorm merged commit 485342f into master Dec 3, 2026
94 of 96 checks passed
@damccorm
damccorm deleted the fix/python-testcontainers-concurrency-46360492005 branch December 3, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Next Action: Reviewers python size/xs XS: <10 lines changed test-failure-cleanup Automated test health and flake cleanup PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants