Make restore lock contention coverage independent of startup timing

This commit is contained in:
2026-11-18 04:02:30 +00:00
parent 5d62f9a88b
commit 69dc5cc8ec
2 changed files with 15 additions and 1 deletions

View File

@@ -56,6 +56,9 @@ the resulting roles.
## 2. P2: Remove the restore test's incidental startup deadline ## 2. P2: Remove the restore test's incidental startup deadline
Status: Complete. Cancellation is synchronized after discovery with the session
lock held. Ten focused race repetitions and the full repository race suite pass.
Stage: 12; the fragile timing assumption predates this migration. Stage: 12; the fragile timing assumption predates this migration.
Location: `internal/app/restore_execution_test.go:383–387`, Location: `internal/app/restore_execution_test.go:383–387`,

View File

@@ -380,8 +380,19 @@ func TestExecuteRestoreLockConflictFailsAndWritesNothing(t *testing.T) {
deps := restoreCommandDependencies(fake) deps := restoreCommandDependencies(fake)
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
discover := deps.discoverRemoteCurrentState
if discover == nil {
discover = discoverRemoteCurrentState
}
deps.discoverRemoteCurrentState = func(ctx context.Context, cfg *config.Config, store storage.ObjectStore) (*RemoteCurrentState, error) {
current, err := discover(ctx, cfg, store)
// Cancel after discovery so configuration and storage startup have no
// incidental deadline. The held lock must prevent installation.
cancel()
return current, err
}
err = restoreWithDependencies(ctx, []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &bytes.Buffer{}, deps) err = restoreWithDependencies(ctx, []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &bytes.Buffer{}, deps)
if err == nil || !strings.Contains(err.Error(), "acquire session lock") { if err == nil || !strings.Contains(err.Error(), "acquire session lock") {
t.Fatalf("Restore() error = %v, want lock failure", err) t.Fatalf("Restore() error = %v, want lock failure", err)