Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.1 c91fade6b9 fix(tests): the capture-host suite waits for a killed host to exit before reading or deleting its files
Two CaptureHost flakes CI kept producing had one cause: Kill() returned before
the killed host had released its files, so the kill-and-recover case opened a
.partial the dead process still held ('being used by another process'), and
Dispose's ledger delete silently failed and left a consent record for the
refusal case to find. Kill waits for exit (15 s, asserted); DeleteHostLedger
retries. 13_CI_CD's flake tally records it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 20:51:03 +07:00
2 changed files with 30 additions and 5 deletions

No files matched your search

+8
View File
@@ -26,6 +26,14 @@ FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, an
wrong by the end of the same evening; it is corrected rather than quietly deleted, because a frequency
claim made from one observation is exactly the shape this file keeps catching.
**Re-run before investigating**; if it reproduces, read the module list and the scan-set reason, not the test.
- **Two more shapes had one cause, found and fixed 2026-09-16** after four failures in one evening's merge train:
`AKilledHostLeavesAPartialThatRecoverTurnsIntoAnInterruptedSession` ("the process cannot access the file …
`.partial`") and `WithNoConsentRecordTheHostRefusesAndNothingIsEverInjected` (a leftover consent record). The
suite's `Kill` helper returned before the killed host had released its files, so the next line read a `.partial`
the dead process still held, and the ledger delete in `Dispose` silently failed and left the record for the next
case. `Kill` now waits for exit (bounded, asserted) and the delete retries. Not §S19(b) either — a test-harness
race, and the third flake shape of the day (the registry-subtree race between `VkLayerRegistrationTests` and the
GOG reader's test, fixed in #188) was the same kind.
- **A re-run ERASES the evidence, which is why the count above had to be kept by hand.**
`gh run rerun --failed` updates the original run's conclusion, so `gh run list` showed **18 success, 1
cancelled, 0 failed** across the twenty runs that contained all three failures above. Anyone measuring
@@ -89,16 +89,26 @@ public sealed class CaptureHostEndToEndTests : IDisposable
}
/// <summary>The ledger and WAL's two sidecars; a guarded delete of each.</summary>
/// <summary>
/// Deletes the host's ledger, retrying for a few seconds: a host this suite just killed may still hold the file
/// while Windows tears the process down, and a delete that silently failed is how the refusal case found a
/// leftover consent record on CI (2026-09-16, three runs in one evening).
/// </summary>
private static void DeleteHostLedger()
{
foreach (string suffix in new[] { "", "-wal", "-shm" })
{
try
{
File.Delete(HostLedger + suffix);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
string path = HostLedger + suffix;
for (int attempt = 0; attempt < 20 && File.Exists(path); attempt++)
{
try
{
File.Delete(path);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
Thread.Sleep(250);
}
}
}
}
@@ -158,6 +168,12 @@ public sealed class CaptureHostEndToEndTests : IDisposable
return Process.Start(psi)!;
}
/// <summary>
/// Kills the process tree AND waits for it to be gone. `Kill` returns before the process has released its
/// files; the kill-and-recover case then opened the `.partial` the dead host still held ("being used by another
/// process"), and the refusal case's ledger delete failed the same way — the two CaptureHost flakes CI kept
/// producing (13_CI_CD's tally). A wait bounded at 15 s: a process that will not die is a failure to report.
/// </summary>
private static void Kill(Process p)
{
try
@@ -165,6 +181,7 @@ public sealed class CaptureHostEndToEndTests : IDisposable
if (!p.HasExited)
{
p.Kill(entireProcessTree: true);
p.WaitForExit(15_000).Should().BeTrue("a killed process must be gone before its files are read or deleted");
}
}
catch (InvalidOperationException)