Skip to content

Fix flaky tests and MockServer test host timeout - #7353

Merged
nkolev92 merged 5 commits into
devfrom
dev-nkolev92-fixFlakyTest
May 5, 2026
Merged

nkolev92 merged 5 commits into
devfrom
dev-nkolev92-fixFlakyTest

Conversation

@nkolev92

@nkolev92 nkolev92 commented May 1, 2026 •

Copy link
Copy Markdown
Member

Engineering

Description

Fix test host crashes caused by MockServer.Stop() hanging indefinitely, and fix a signing test race condition.

  • Refactor MockServer.HandleRequest to use async GetContextAsync with CancellationToken instead of synchronous GetContext, which has no reliable cancellation mechanism and can block indefinitely when Abort() is called
  • Extract signing test from PackageArchiveReaderTests into SigningTestsCollection to prevent parallel test race condition with shared certificate store

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

The ResolvePackageDownloadVersion_UnlistedPackage_BehavesAsExpected test
intermittently hangs on Windows CI, causing the test host to crash after
the 5-minute blame collector timeout. The root cause is using
CancellationToken.None which allows HTTP calls to the mock server to
block indefinitely when there is a transient issue.

Fix: Replace CancellationToken.None with a 60-second CancellationTokenSource
so the test fails fast instead of hanging the entire test host.

Also add using to SourceCacheContext for proper temp file cleanup.

Co-authored-by: Copilot <[email protected]>
@nkolev92
nkolev92 requested a review from a team as a code owner May 1, 2026 17:47
@nkolev92
nkolev92 requested review from Nigusu-Allehu and zivkan May 1, 2026 17:47
@nkolev92 nkolev92 added the Engineering Changes related to the build infrastructure of the repo and that do not change product code label May 1, 2026
Nigusu-Allehu
Nigusu-Allehu previously approved these changes May 1, 2026
@nkolev92
nkolev92 enabled auto-merge (squash) May 4, 2026 16:51
@nkolev92
nkolev92 disabled auto-merge May 4, 2026 17:54
@nkolev92

nkolev92 commented May 4, 2026

Copy link
Copy Markdown
Member Author

The same test crashed again, lol.

Moving to draft.

@nkolev92
nkolev92 marked this pull request as draft May 4, 2026 17:54
nkolev92 and others added 2 commits May 4, 2026 12:52
Replace synchronous HandleRequest (blocking GetContext) with async
HandleRequestAsync using GetContextAsync and CancellationToken. This
prevents MockServer.Stop() from hanging indefinitely when Abort()
doesn't immediately unblock the synchronous listener call, which
caused test host crashes due to 5-minute inactivity timeouts.

Co-authored-by: Copilot <[email protected]>
The MockServer async refactor properly fixes the hang at the root
cause level, making the CancellationTokenSource timeout unnecessary.

Co-authored-by: Copilot <[email protected]>
@nkolev92 nkolev92 changed the title Fix flaky PackageDownloadRunnerTests by adding cancellation timeout Fix flaky tests and MockServer test host timeout May 4, 2026
@nkolev92
nkolev92 marked this pull request as ready for review May 4, 2026 20:05
@nkolev92

nkolev92 commented May 4, 2026

Copy link
Copy Markdown
Member Author

Let's see how this goes :D

@nkolev92
nkolev92 requested a review from Nigusu-Allehu May 4, 2026 21:06
@nkolev92
nkolev92 enabled auto-merge (squash) May 4, 2026 21:11
Comment thread .github/copilot-instructions.md Resolved
@nkolev92
nkolev92 merged commit 3e3affd into dev May 5, 2026
17 of 18 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-fixFlakyTest branch May 5, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Engineering Changes related to the build infrastructure of the repo and that do not change product code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants