test: fix make test-all-db TempDir cleanup race#677
Merged
Conversation
…routines make test-all-db flaked on macOS: TestLogout (and any integration test) could fail during teardown with 'TempDir RemoveAll: directory not empty'. The SQLite test DB lives in the temp dir and uses WAL; the fire-and-forget LogEvent/AddSession goroutines from Login/SignUp/Logout can create a -wal/-shm sidecar file exactly as t.TempDir() force-removes the dir, failing an already-passed test. Manage the dir ourselves and remove it best-effort (retry, ignore errors) so cleanup-race noise can't fail the suite. Test-only; green in CI (Linux) already, this fixes the local full-suite run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
make test-all-dbfails locally (macOS) with:The test's assertions pass — only the temp-dir cleanup fails, and only under the full suite (TestLogout passes 5/5 in isolation and is green in CI on Linux).
Root cause
The integration harness puts the SQLite test DB in
t.TempDir(), and SQLite runs in WAL mode. The fire-and-forget goroutines fromLogEvent/AddSession(started by Login/SignUp/Logout — already documented in the storage-close cleanup comment) can create a-wal/-shmsidecar file exactly ast.TempDir()'s strictRemoveAlltears the dir down → "directory not empty" → Go fails the already-passed test. Pre-existing fragility, not from any recent feature merge.Fix
Manage the DB's temp dir ourselves instead of
t.TempDir(), and remove it best-effort (a few retries, ignore the error) so a benign teardown race can't fail the suite. Registered so removal still runs after the storageClose()cleanup (t.Cleanup is LIFO). Test-only change.Verification
Full module across all 7 DBs (
TEST_DBS=couchbase,postgres,sqlite,mongodb,arangodb,scylladb,dynamodb go test -p 1 ./...) → exit 0, no failures. Storage provider tests across all NoSQL backends also pass (187s), confirming the new org_domains/webauthn_credentials tables round-trip everywhere.