fix(tests): clear the SQLite pool before deleting the secrets path-guard temp dir — Windows sharing violation
This commit is contained in:
@@ -557,12 +557,12 @@ real-clock deadlines into failures.
|
|||||||
### Two more findings from the 2026-08-15 windev gate
|
### Two more findings from the 2026-08-15 windev gate
|
||||||
|
|
||||||
- `SecretsStorePathGuardTests.CreateBuilder_AcceptsSecretsStoreOutsideContentRoot_AndCreatesIt`
|
- `SecretsStorePathGuardTests.CreateBuilder_AcceptsSecretsStoreOutsideContentRoot_AndCreatesIt`
|
||||||
fails **deterministically on Windows, on `main` as well as on any branch**, so it is not a
|
used to fail deterministically on Windows: creating the builder opens `secrets.db`,
|
||||||
signal about the change under test. Creating the builder opens `secrets.db`, and
|
`Microsoft.Data.Sqlite`'s connection pool kept the file handle alive past the test body, and
|
||||||
`Microsoft.Data.Sqlite`'s connection pool keeps the file handle alive past the test body,
|
the cleanup's recursive directory delete hit a sharing violation Windows enforces and Unix
|
||||||
so the recursive directory delete in the cleanup hits a still-open file — a sharing
|
does not. The cleanup now clears the SQLite connection pool before deleting the temp
|
||||||
violation Windows enforces and Unix does not. Pre-existing and tracked separately; do not
|
directory (the same pattern as `TempDatabaseDirectory` and `PreHostSecretExpansionTests`),
|
||||||
chase it as a regression. Subtract it from the expected pass count on Windows.
|
so the test passes on Windows and macOS alike — count it as a pass on both.
|
||||||
- The `StaWaitHelper` timing tests (`WaitForSignalOrMessages_*`) flake on a loaded box with a
|
- The `StaWaitHelper` timing tests (`WaitForSignalOrMessages_*`) flake on a loaded box with a
|
||||||
signature that reads like a broken wait but is not: the helper wakes on *input being
|
signature that reads like a broken wait but is not: the helper wakes on *input being
|
||||||
present*, so a message posted to the test thread ends the wait early. That is the helper
|
present*, so a message posted to the test thread ends the wait early. That is the helper
|
||||||
|
|||||||
@@ -100,8 +100,25 @@ public sealed class SecretsStorePathGuardTests
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Environment.SetEnvironmentVariable(SqlitePathVariable, original);
|
Environment.SetEnvironmentVariable(SqlitePathVariable, original);
|
||||||
|
|
||||||
|
// The store runs in WAL mode with connection pooling, so a pooled handle can outlive the
|
||||||
|
// migration and keep secrets.db (plus its -wal/-shm sidecars) open. Windows refuses to
|
||||||
|
// delete a directory holding open files where Unix does not, so clear the pool first;
|
||||||
|
// the catch is belt-and-braces for a sidecar whose handle outlasts even that.
|
||||||
|
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
|
||||||
|
try
|
||||||
|
{
|
||||||
Directory.Delete(directory, recursive: true);
|
Directory.Delete(directory, recursive: true);
|
||||||
}
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
// Best-effort cleanup of the temp store; a locked file must not fail the test.
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
// Best-effort cleanup of the temp store; a locked file must not fail the test.
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The content root CreateBuilder will use, taken from a builder created with the suite's normal
|
// The content root CreateBuilder will use, taken from a builder created with the suite's normal
|
||||||
|
|||||||
Reference in New Issue
Block a user