Repository navigation
TEST: Bound concurrent scenario resume with operation watchdogs - #4849
Open
Richard Lundeen (richlundeen) wants to merge 1 commit into
Open
Richard Lundeen (richlundeen) wants to merge 1 commit into
Richard Lundeen (richlundeen) wants to merge 1 commit into
Conversation
The 60 s pytest-timeout on test_concurrent_partial_failures_resume_without_duplicate_results measured the whole test, including sqlite fixture setup and initialize_async, so stalled macOS runners hit it outside any deadlock. Bound the operations that can deadlock instead: the three-attack rendezvous via wait_for_event_async and each scenario run via wait_for_completion_async (TEST_WATCHDOG_SECONDS, no cancellation of the run). Release gates and join owned runs in a finally block. The marker becomes an outer backstop for synchronous hangs at 4 * TEST_WATCHDOG_SECONDS. Assertions and mocks are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Repeated cancellation can let the test’s finally block exit before scenario-run tasks finish asynchronous cleanup because the waiter does not reliably drain them.
1 open issue
What changed in this PR
Updates PyRIT’s concurrent scenario-resume test to tolerate slow CI runners while retaining deadlock detection. Product code and existing assertions remain unchanged.
Changes:
- Adds repository-standard watchdogs for rendezvous and scenario runs.
- Adds gate release, task cancellation, and cleanup waits.
- Raises the outer pytest timeout to accommodate per-operation watchdogs.
| File | Description |
|---|---|
tests/unit/scenario/core/test_scenario_partial_results.py |
Updates watchdog bounds and task cleanup for the concurrent partial-failure resume test. |
Review effort: Balanced
Comment on lines
+1175
to
+1177
| await wait_for_completion_async( | ||
| future=asyncio.gather(*get_defined_tasks(first_run, resume_run), return_exceptions=True) | ||
| ) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
test_concurrent_partial_failures_resume_without_duplicate_resultsused a 60 s whole-testpytest.mark.timeoutas its deadlock guard, and saturated macOS runners slowed the run itself past it: run 47008045719, job 143918339549 recorded about 60.7 s of call time, timing out inside the firstscenario.run_async(). Passing macOS calls take up to about 118 s, against about 1.5 s locally. This PR replaces the 60 s whole-test alarm with the repository-standard 300 sTEST_WATCHDOG_SECONDShang watchdog on the rendezvous and on each run. That watchdog also excludes fixture setup and names the stuck phase.wait_for_event_async, and eachscenario.run_async()withwait_for_completion_async. Both come fromtests/unit/async_utils.pyand use the defaultTEST_WATCHDOG_SECONDS(300 s per phase).TimeoutErrornames the stuck step: either the rendezvous never signaled readiness, or a run never completed. Neither helper cancels the run, so slow database reads are not interrupted, which keeps the reason TEST: avoid cancelling scenario resume for slow database reads #3138 removedasyncio.wait_for.finallyblock releases the test's gates, cancels only runs that are still pending, and joins the owned tasks.@pytest.mark.timeout(60)becomes@pytest.mark.timeout(4 * TEST_WATCHDOG_SECONDS). It is now an outer backstop for hangs that block the event loop, sized above the test's four sequential watchdog waits, as other unit tests already do.This follows the Correctness Test Timeouts guidance in
test.instructions.md, which says hang-only bounds should useTEST_WATCHDOG_SECONDS. #4842 uses 120 s for a different set of tests. If maintainers would rather align this test with that, the change is a single constant.