Commit 34824d9
test(proxy): allocate unique sub-agent id per test instance to deflake parallel runs
PipeDiscoveryServiceTests and PowerShellToolsTests both used the
constant agent id "default" while reaching into the static
ConsoleSessionManager.Instance for state mutations
(SetActivePipeName / SetLastAiCwd / MarkPipeBusy / ClearDeadPipe /
TryAssignNameToPid). xunit parallelizes test classes by default, so
two classes touching state keyed by the same "default" id can race —
seen in CI on Windows as a transient null AllPipesStatusInfo from
FindReadyPipeAsync_ActivePipeBusy_RecordsStatusInfo, while the same
test was green on the next run with no code change.
Switch to ConsoleSessionManager.Instance.AllocateSubAgentId() in each
class''s constructor (xunit creates a fresh instance per test method,
so each test gets its own id). The session manager already uses this
id everywhere as an opaque dictionary key, and IPipeDiscoveryService /
PowerShellTools accept any non-empty agent id once it''s in the
allocated set, so no production-code change is needed.
For PowerShellToolsTests the TestPipeName format string is also
derived from the new TestAgentId so any code that re-derives the
agent id from a pipe name segment sees a consistent value.
ConsoleSessionManagerTests was already mostly clean (it allocates
per-test ids via the same helper) so no change there. Its one
"default"-using test has a comment acknowledging the leak is benign
because no other test reads that key.
xunit local: net8 162/162, net9 275/275.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 97f4002 commit 34824d9
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
27 | 37 | | |
28 | 38 | | |
29 | 39 | | |
| |||
0 commit comments