Skip to content

feat(flaky-detection): Add pytest-xdist support to flaky detection system#383

Closed
remyduthu wants to merge 1 commit intodevs/remyduthu/remyduthu/mrgfy-6296-add-support-for-pytest-xdist-to-our-flaky-detection-system/I1527a32fbff3f69d53e69d6e31dc1892bb6109c1from
devs/remyduthu/remyduthu/mrgfy-6296-add-support-for-pytest-xdist-to-our-flaky-detection-system/I31dc94df9451d8b4bf166166e03453dda6168c18
Closed

feat(flaky-detection): Add pytest-xdist support to flaky detection system#383
remyduthu wants to merge 1 commit intodevs/remyduthu/remyduthu/mrgfy-6296-add-support-for-pytest-xdist-to-our-flaky-detection-system/I1527a32fbff3f69d53e69d6e31dc1892bb6109c1from
devs/remyduthu/remyduthu/mrgfy-6296-add-support-for-pytest-xdist-to-our-flaky-detection-system/I31dc94df9451d8b4bf166166e03453dda6168c18

Conversation

@remyduthu
Copy link
Contributor

Add full flaky detection support under pytest-xdist using controller-
orchestrated pre-computed deadlines and xdist's built-in IPC.

Architecture:

  • Controller fetches flaky detection context from API once, distributes
    it to workers via workerinput
  • Each worker constructs a FlakyDetector from the serialized context,
    computes the same global budget, runs tests with reruns
  • Workers send metrics back via workeroutput
  • Controller aggregates metrics and generates the terminal report

Changes:

  • Add FlakyDetector.from_context() classmethod for worker-side construction
  • Add to_serializable_metrics() for xdist IPC (plain builtins only)
  • Add make_report_from_aggregated() for controller-side reporting
  • Add static deadline mode (_is_xdist flag) preserving dynamic for non-xdist
  • Add MergifyCIInsights.load_flaky_detector_from_context()
  • Add controller hooks (pytest_configure_node, pytest_testnodedown)
  • Add worker hooks (workerinput loading, workeroutput export)
  • Disable flaky detection under 'each' scheduling mode
  • Add pytest-xdist dev dependency and integration tests

Fixes: MRGFY-6296

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Depends-On: #382

…stem

Add full flaky detection support under pytest-xdist using controller-
orchestrated pre-computed deadlines and xdist's built-in IPC.

Architecture:
- Controller fetches flaky detection context from API once, distributes
  it to workers via workerinput
- Each worker constructs a FlakyDetector from the serialized context,
  computes the same global budget, runs tests with reruns
- Workers send metrics back via workeroutput
- Controller aggregates metrics and generates the terminal report

Changes:
- Add FlakyDetector.from_context() classmethod for worker-side construction
- Add to_serializable_metrics() for xdist IPC (plain builtins only)
- Add make_report_from_aggregated() for controller-side reporting
- Add static deadline mode (_is_xdist flag) preserving dynamic for non-xdist
- Add MergifyCIInsights.load_flaky_detector_from_context()
- Add controller hooks (pytest_configure_node, pytest_testnodedown)
- Add worker hooks (workerinput loading, workeroutput export)
- Disable flaky detection under 'each' scheduling mode
- Add pytest-xdist dev dependency and integration tests

Fixes: MRGFY-6296

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change-Id: I31dc94df9451d8b4bf166166e03453dda6168c18
@remyduthu
Copy link
Contributor Author

This pull request is part of a stack:

  1. docs: Add design spec for pytest-xdist flaky detection support (#380)
  2. docs: Address spec review feedback for xdist flaky detection (#381)
  3. docs: Add implementation plan for xdist flaky detection support (#382)
  4. feat(flaky-detection): Add pytest-xdist support to flaky detection system (#383) 👈

@mergify
Copy link

mergify bot commented Mar 19, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 Approval

This rule is failing.
  • #approved-reviews-by >= 2

🔴 🔎 Reviews

This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success = codespell
    • check-success = test (3.10)
    • check-success = test (3.11)
    • check-success = test (3.12)
    • check-success = test (3.13)
    • check-success = test (3.14)
    • check-success = test (3.8)
    • check-success = test (3.9)

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@mergify mergify bot requested a review from a team March 19, 2026 13:07
@remyduthu remyduthu closed this Mar 19, 2026
@remyduthu remyduthu deleted the branch devs/remyduthu/remyduthu/mrgfy-6296-add-support-for-pytest-xdist-to-our-flaky-detection-system/I1527a32fbff3f69d53e69d6e31dc1892bb6109c1 March 19, 2026 13:08
@remyduthu remyduthu deleted the devs/remyduthu/remyduthu/mrgfy-6296-add-support-for-pytest-xdist-to-our-flaky-detection-system/I31dc94df9451d8b4bf166166e03453dda6168c18 branch March 19, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant