Repository navigation
Retry deleting smoke test work folders on Windows - #2188
waldekmastykarz wants to merge 3 commits into
Conversation
A killed host's descendants (cmd.exe /c more in the stdio tests) can still hold the work folder as their working directory right after Kill returns, which made Stdio_BackToBackJsonRpcMessages_AreMockedIndividually fail intermittently on Windows. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the temporary work-directory cleanup retry change.
No open issues 🎉
What changed in this PR
This PR addresses intermittent Windows failures in Dev Proxy’s process smoke tests by allowing time for terminated processes to release temporary working directories.
Changes:
- Adds
DeleteWorkDir, which retries deletion on I/O or access errors for up to 10 seconds. - Uses the helper at all five work-directory cleanup sites in
ProcessSmokeTests.
| File | Description |
|---|---|
DevProxy.Integration.Tests/ProcessSmokeTests.cs |
Adds bounded deletion retries and applies them consistently to temporary work-directory cleanup. |
Review effort: Balanced
garrytrinder
left a comment
There was a problem hiding this comment.
Functional test results
- PR: dotnet/dev-proxy#2188
- Tested commit:
ea2a3c28409ca2ec24e2b75902f8f2b06409497c - Environment: macOS 27.2.1, .NET SDK 10.0.103. Dedicated worktree and fixture home; both
HOMEandCFFIXED_USER_HOMEisolated; certificate installation and system-proxy registration disabled.
| Scenario or test command | Expected | Actual | Result |
|---|---|---|---|
dotnet restore DevProxy.sln --locked-mode; build DevProxy.Integration.Tests and DevProxy with --no-restore |
Exact-head source builds without errors | Both builds: 0 warnings, 0 errors. Initial no-restore attempt lacked assets; locked restore resolved it. | PASS |
Invoke compiled ProcessSmokeTests.DeleteWorkDir by reflection on a populated directory, then the same absent directory |
Recursive removal; absent directory returns immediately | Removed in 5 ms; absent directory returned in 0 ms. No repository tests rerun locally. | PASS |
| Deny write access on an owned directory's parent, confirm direct deletion fails, restore access after 650 ms, invoke actual compiled helper | Retry succeeds after access is restored | Directory removed after 735 ms. This exercises a real filesystem failure, not a mocked exception. | PASS |
| Keep parent write access denied while invoking actual compiled helper | Retry for approximately 10 seconds, then surface failure rather than silently succeed | IOException surfaced after 10,064 ms; directory remained until fixture permissions were restored. |
PASS |
Start source-built host with --detach --as-system-proxy false --port 0 --api-port 0 --install-cert false --no-first-run; PID-scoped status; authenticated GET /proxy; explicit proxy request to http://api.contoso.local/hello |
Detached process stays alive, API responds, configured mock is served | Owned PID 15381; API http://127.0.0.1:57883 returned 200; proxy port 57882 returned 200 with exact body hello from the mock. State, certificate, token and logs remained under the owned fixture home. |
PASS |
devproxy stop --pid 15381 using matching source build |
Owned process exits gracefully | Exit verified; fixture files removed afterward. | PASS |
| Current-head automated validation, inspected rather than rerun | CI passes for tested SHA | CI run is successful for the tested commit. Windows log: 289 unit tests passed; 299 integration tests passed, 2 skipped. macOS, Ubuntu, build, client smoke and CodeQL checks also report success. | PASS |
| Reproduce Windows descendant-held working-directory lock and prove eventual release during retry | Original Windows cleanup race recovers | No Windows execution host available in this session. macOS permission probes cover retry and timeout behavior but do not reproduce Windows directory-handle semantics; a green Windows CI run does not demonstrate that this intermittent race was exercised. | BLOCKED |
Requested changes
None.
Outcome
Comment only: observed helper behavior and the adjacent runtime smoke scenario pass, with no reproduced functional defect attributable to this PR. Direct validation of the Windows-specific race remains blocked, so this is not an approval or a change request.
Cleanup complete: only owned PIDs were touched; fixture state, certificates, tokens, logs and temporary files were removed; tracked source remained unchanged. An initial harness invocation incorrectly passed --config-file to status and stop; its owned PID 14199 required SIGTERM and its exit was verified. Correcting those harness arguments produced the successful graceful-shutdown result above. The first isolated probe compilation also hit an empty-cache NuGet/TLS error; rerunning the probe compilation with the existing SDK/package cache succeeded. These setup issues were not PR defects.
garrytrinder
left a comment
There was a problem hiding this comment.
Functional test results
- PR: dotnet/dev-proxy#2188
- Tested commit:
1d81c5be96410647618cfe87ef39f6c78a96ce9c - Environment: macOS 27.2.1, .NET SDK 10.0.103; retest on November 27. Latest upstream head checked out in the dedicated clean worktree. Runtime fixtures use isolated
HOMEandCFFIXED_USER_HOME, pre-createdLibrary/Application Support, and their own certificate path. No system-proxy changes or certificate trust installation.
The latest head merges updated main; the net PR diff remains one file, and the cleanup helper is unchanged. The results below are newly executed against the latest head, not carried forward from the earlier review.
| Scenario or test command | Expected | Actual | Result |
|---|---|---|---|
dotnet restore DevProxy.sln --locked-mode; build DevProxy.Integration.Tests and DevProxy with --no-restore |
Latest-head source builds cleanly | Both builds succeeded with 0 warnings and 0 errors. No tracked dependency files changed. | PASS |
Invoke actual compiled ProcessSmokeTests.DeleteWorkDir by reflection on a populated directory, then the now-missing directory |
Recursive removal; absent directory returns immediately | Removal in 9 ms; absent-directory return in 0 ms. | PASS |
| Remove write permission on an owned parent directory; confirm direct deletion fails; restore permission after 650 ms; invoke compiled helper | Retries until access is restored, then removes the directory | Real filesystem failure recovered; directory removed after 844 ms. | PASS |
| Leave parent write permission denied while invoking compiled helper | Approximately 10-second retry deadline; failure surfaces rather than being swallowed | IOException surfaced after 10,042 ms; directory remained until fixture permissions were restored. |
PASS |
Source-built host: --detach --as-system-proxy false --port 0 --api-port 0 --install-cert false --no-first-run --output json --config-file <owned-config>; PID-scoped status and authenticated GET /proxy |
Detached process stays alive and API responds | Owned PID 42217; assigned API http://127.0.0.1:53303 returned HTTP 200 with a JSON object. |
PASS |
Explicit HTTP proxy request through assigned port 53302 to http://api.contoso.local/hello |
Config-loaded mock returns HTTP 200 and exact body | HTTP 200, exact body hello from the mock. Isolated state, token, certificate and logs verified inside the owned fixture home. |
PASS |
Matching source build devproxy stop --pid 42217 |
Graceful shutdown, owned process exits | Stop succeeded and process exit was verified. | PASS |
| Inspect actual Windows CI log for the tested head; do not rerun automated suites locally | Current-head automated suites succeed, skips disclosed | CI run 45968009574 confirms exact tested SHA. Windows job log: 171 abstractions, 227 Kestrel, 358 host and 445 integration tests passed; 2 integration tests skipped (Startup_EnvironmentOverrides... and Status_HonorsInstanceTokenSuppression...). No failed tests. Current-head macOS, Ubuntu, build, client smoke and CodeQL checks also pass. |
PASS |
| Reproduce the Windows descendant-held working-directory lock and observe recovery during retry | Original Windows race demonstrated and fixed | No Windows execution host is available to this session. macOS permission failures exercise retry and timeout behavior, not Windows descendant directory-handle behavior. The successful Windows CI run does not prove that the intermittent race was exercised. | BLOCKED |
Requested changes
None.
Outcome
Comment only. All executed probes and adjacent runtime scenarios pass on the latest head, with no reproduced PR-attributable defect. The essential direct Windows race reproduction remains blocked, so the evidence does not justify approval or a change request.
Cleanup complete: owned PID 42217 exited gracefully; temporary fixtures, certificate, token, state and logs were removed. Original branch checkout restored and tracked/untracked worktree clean. No fixes, commits, pushes or merges. The standalone reflection harness emitted analyzer warnings while compiling; the repository builds themselves were warning-free.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
8e9fd844c707b4cbded9ea7d605b99fa3b6b5655ProcessSmokeTestspass on macOS.↓ The Windows race isn't reproducible locally; only CI over time confirms the flake is gone.
RemoveDirectoryInternal), consistent with a process still using it as its working directory.↓ Which process held it (the
dotnethost or thecmd.exe/morechild) wasn't captured.fix-2139-cert-prompt-json); a rerun passed.Fixes an intermittent Windows failure in
ProcessSmokeTests.Stdio_BackToBackJsonRpcMessages_AreMockedIndividually:The test's assertions pass. The failure happens in
finallywhen deleting the work folder.StopHostkills the whole process tree but can only wait for thedotnethost. On Windows, the killed descendants (cmd.exe /c more), whose working directory is the work folder, can still be shutting down when the delete runs.Changes
DeleteWorkDir, which retries the delete onIOException/UnauthorizedAccessExceptionfor up to 10 seconds, and use it for every work folder cleanup inProcessSmokeTests.