Make restore lock contention coverage independent of startup timing
This commit is contained in:
@@ -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`,
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user