activator: tests held serial only by the umask now run in parallel
#337 (4a1e4b2) stopped edge.SecureUnixListen changing the process umask on Linux, so a test that binds a control, log or cmd-stream listener no longer corrupts a parallel neighbour's directory modes. 26 tests held sequential for that reason alone now call t.Parallel(); the rule above TestMain no longer cites the umask. TestStopKeepsListenersOpenUntil- TerminationIsProven stays sequential: in parallel its log socket still accepted a dial after Stop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 files changed,
+31
−10
internal/activator/activator_test.go+7 −10internal/activator/claimrecord_linux_test.go+3 −0internal/activator/cmdunit_test.go+1 −0internal/activator/exec_gate_test.go+1 −0internal/activator/generations_backend_test.go+1 −0internal/activator/gensocket_rev19_test.go+2 −0internal/activator/identity_test.go+3 −0internal/activator/loglistener_test.go+1 −0internal/activator/plan14_generation_backend_test.go+1 −0internal/activator/swap_executed_test.go+2 −0internal/activator/unitproc_gen_test.go+1 −0internal/activator/unitproc_test.go+5 −0internal/activator/wakecheck_claim_linux_test.go+1 −0internal/activator/wakeplan_test.go+1 −0internal/activator/wakerecord_refused_test.go+1 −0
diff --git a/internal/activator/activator_test.go b/internal/activator/activator_test.go| index 84c04e9df..b8c04587f 100644 |
| --- a/internal/activator/activator_test.go |
| +++ b/internal/activator/activator_test.go |
| @@ -6110,16 +6110,11 @@ func TestMain(m *testing.M) { |
| // write package state (a shrunk timeout, a hook, the generations switch, |
| // the log's output), set the environment or the working directory, depend |
| // on time it measures itself (time.Since), or use the /proc child waits in |
| -// childwait_test.go, which count every child of this binary. Nor may it |
| -// bind a socket through edge.SecureUnixListen (a control, log or cmd-stream |
| -// listener: every ExecBackend spawn and nested start binds one), which sets |
| -// the process's umask to 0177 around the bind, so a directory a parallel |
| -// test made in that window comes out 0600 and unusable. A test that does |
| -// any of these stays sequential. The tests marked parallel were checked |
| -// for all of it, through every test helper they call, and run once each |
| -// to see that none reaches SecureUnixListen; a test that later starts |
| -// shrinking a package var or spawning through the backend must drop its |
| -// t.Parallel(). |
| +// childwait_test.go, which count every child of this binary. A test that |
| +// does any of these stays sequential. The tests marked parallel were |
| +// checked for all of it, through every test helper they call; a test that |
| +// later starts shrinking a package var or setting the environment must |
| +// drop its t.Parallel(). |
| // fakeAppMain is the app half: bind the --socket, tighten it to 0600 — the |
| // exact titogo habit that stranded the sibling router in issue #103 — and |
| @@ -6236,6 +6231,7 @@ func TestExecBackendFailedWakeDoesNotNormalizeSocketMode(t *testing.T) { |
| // socket. The squatter here holds its 200 until the child has verifiably |
| // exited, making the race the guard closes deterministic. |
| func TestExecBackendDoesNotNormalizeSquatterSocket(t *testing.T) { |
| + t.Parallel() |
| requireUnixSockets(t) |
| b := testExecBackend(t) |
| host := "squatted.example.com" |
| @@ -6313,6 +6309,7 @@ func TestExecBackendDoesNotNormalizeSquatterSocket(t *testing.T) { |
| // "child exited". It also pins the other half — that the listener is still |
| // closed, on this path, once the child is gone. |
| func TestChildProcStopKeepsTheControlSocketUpUntilTheChildExits(t *testing.T) { |
| + t.Parallel() |
| requireUnixSockets(t) |
| dir := t.TempDir() |
| ready := filepath.Join(dir, "ready") // the child's SIGTERM trap is installed |
diff --git a/internal/activator/claimrecord_linux_test.go b/internal/activator/claimrecord_linux_test.go| index 7c56af25a..97d9be459 100644 |
| --- a/internal/activator/claimrecord_linux_test.go |
| +++ b/internal/activator/claimrecord_linux_test.go |
| @@ -130,6 +130,7 @@ func (c *claimedRecord) start(t *testing.T, e *actEntry, maxStarts int) error { |
| // claim actor's bucket, before each exec. A start that failed for any other |
| // reason is retried, and the retry is a new exec: it records again. |
| func TestAClaimedStartRecordsBeforeEachExec(t *testing.T) { |
| + t.Parallel() |
| c := newClaimedRecord(t, nil) |
| launches := 0 |
| granted := launchedChild(t) |
| @@ -279,6 +280,7 @@ func TestAClaimedProbeRecords(t *testing.T) { |
| // claim's Holder.Location (internal/host buildStates.locate, ruling |
| // R-CLAIMPREFIX-2), which is the claimed lease's. |
| func TestAClaimedSidecarRestartRecordsTheBuildItsPrimaryRan(t *testing.T) { |
| + t.Parallel() |
| claimedSidecarRestart(t, false) |
| } |
| @@ -288,6 +290,7 @@ func TestAClaimedSidecarRestartRecordsTheBuildItsPrimaryRan(t *testing.T) { |
| // pin's demand. Prepare's start was checked against the pin (s.Version is |
| // Pin.Build), and s.Staged is what actually ran. |
| func TestAPinnedClaimedSidecarRestartRunsTheClaimedFile(t *testing.T) { |
| + t.Parallel() |
| claimedSidecarRestart(t, true) |
| } |
diff --git a/internal/activator/cmdunit_test.go b/internal/activator/cmdunit_test.go| index 2f87e3a18..862ff37d9 100644 |
| --- a/internal/activator/cmdunit_test.go |
| +++ b/internal/activator/cmdunit_test.go |
| @@ -151,6 +151,7 @@ func TestStartCmdRefusesAnUnsafeRunID(t *testing.T) { |
| } |
| func TestStopAndSettleDrainsBothStreams(t *testing.T) { |
| + t.Parallel() |
| b, rt, ctl, unit, u, out, errs := startTestCmd(t) |
| unit.set("active", "inv1", true, true) |
| write := func(path, s string) { |
diff --git a/internal/activator/exec_gate_test.go b/internal/activator/exec_gate_test.go| index 153667835..30a5f99ee 100644 |
| --- a/internal/activator/exec_gate_test.go |
| +++ b/internal/activator/exec_gate_test.go |
| @@ -688,6 +688,7 @@ func flatLiveFixture(t *testing.T) (b *ExecBackend, rt registry.Route, v1, v2, o |
| // exec cannot start a build the gate never saw. A refusal starts nothing. |
| // With the gate nil the spawn execs the live link exactly as before. |
| func TestALiveExecGateGatesTheFlatLiveLinkSpawn(t *testing.T) { |
| + t.Parallel() |
| t.Run("gated build is the exec'd build", func(t *testing.T) { |
| b, rt, v1, v2, out := flatLiveFixture(t) |
| g := &liveGate{refuse: map[string]bool{"v2": true}} |
diff --git a/internal/activator/generations_backend_test.go b/internal/activator/generations_backend_test.go| index 3cfb77e1f..d8c57d8ff 100644 |
| --- a/internal/activator/generations_backend_test.go |
| +++ b/internal/activator/generations_backend_test.go |
| @@ -160,6 +160,7 @@ func TestStartGenFlatBindsItsOwnGenerationSocket(t *testing.T) { |
| // control env follows it, and prepare removes only that generation's stale |
| // file. |
| func TestStartGenNestedUsesItsOwnDirectory(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
diff --git a/internal/activator/gensocket_rev19_test.go b/internal/activator/gensocket_rev19_test.go| index 65793d674..42a64b2c1 100644 |
| --- a/internal/activator/gensocket_rev19_test.go |
| +++ b/internal/activator/gensocket_rev19_test.go |
| @@ -94,6 +94,7 @@ func sameLaunch(t *testing.T, offArgv, genArgv []string, offEnv, genEnv map[stri |
| // Rule 2, flat: a generation's exec has the flag-off argv and agent-owned |
| // environment apart from the socket's directory and the control path. |
| func TestFlatGenerationLaunchMatchesTheFlagOffLaunch(t *testing.T) { |
| + t.Parallel() |
| requireUnixSockets(t) |
| b := testExecBackend(t) |
| b.RunDirOverride = shortRunDir(t) |
| @@ -143,6 +144,7 @@ func TestFlatGenerationLaunchMatchesTheFlagOffLaunch(t *testing.T) { |
| // agent-owned environment apart from the socket's directory and the control |
| // path, and prepare made the generation's own directory before the start. |
| func TestNestedGenerationLaunchMatchesTheFlagOffLaunch(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
diff --git a/internal/activator/identity_test.go b/internal/activator/identity_test.go| index 836d79b2e..23ea4b384 100644 |
| --- a/internal/activator/identity_test.go |
| +++ b/internal/activator/identity_test.go |
| @@ -348,6 +348,7 @@ func noPlainVerbs(t *testing.T, ctl *fakeControl) { |
| // that is the original run unit (generation 0); with them on, generation n. |
| // Never a plain Start or StartGen. |
| func TestNestedStartExeNamesTheRecordedFile(t *testing.T) { |
| + t.Parallel() |
| for _, tc := range []struct { |
| name string |
| gens bool |
| @@ -471,6 +472,7 @@ func declinedPinFixture(t *testing.T, ctl *fakeControl, unit *fakeUnit) (*ExecBa |
| // the gate answered still runs v1. Never a plain Start or StartGen, which |
| // would bind whatever the link names when root lays the unit out. |
| func TestADeclinedNestedLiveLinkStartRunsThePinnedFile(t *testing.T) { |
| + t.Parallel() |
| for _, tc := range []struct { |
| name string |
| gens bool |
| @@ -532,6 +534,7 @@ func TestADeclinedNestedLiveLinkStartRunsThePinnedFile(t *testing.T) { |
| // The same for the legacy sidecar's nested live-link start: root is asked |
| // to bind the pinned v1 (StartSidecarExe), never a plain sidecar start. |
| func TestADeclinedNestedSidecarStartRunsThePinnedFile(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt, x, v2 := declinedPinFixture(t, ctl, unit) |
diff --git a/internal/activator/loglistener_test.go b/internal/activator/loglistener_test.go| index 9d5e41578..b890f692c 100644 |
| --- a/internal/activator/loglistener_test.go |
| +++ b/internal/activator/loglistener_test.go |
| @@ -68,6 +68,7 @@ func TestLogListenerTeesOneConnectionAndRefusesASecond(t *testing.T) { |
| // written after Close returns must not reach the sink, and the tee |
| // goroutine must not outlive the listener. |
| func TestLogListenerCloseShutsTheConnectionAndWaitsForTheTee(t *testing.T) { |
| + t.Parallel() |
| dir, err := os.MkdirTemp("", "ll") |
| if err != nil { |
| t.Fatal(err) |
diff --git a/internal/activator/plan14_generation_backend_test.go b/internal/activator/plan14_generation_backend_test.go| index f609bf736..5eb679af9 100644 |
| --- a/internal/activator/plan14_generation_backend_test.go |
| +++ b/internal/activator/plan14_generation_backend_test.go |
| @@ -99,6 +99,7 @@ func TestPlan14GenerationBackendControlBoundary(t *testing.T) { |
| } |
| func TestPlan14GenerationBackendAuxiliaryBoundary(t *testing.T) { |
| + t.Parallel() |
| for _, claimed := range []bool{false, true} { |
| for _, role := range []string{"seed", "sidecar"} { |
| for _, pinned := range []bool{false, true} { |
diff --git a/internal/activator/swap_executed_test.go b/internal/activator/swap_executed_test.go| index 1e800a15e..83a67fccb 100644 |
| --- a/internal/activator/swap_executed_test.go |
| +++ b/internal/activator/swap_executed_test.go |
| @@ -169,6 +169,7 @@ func TestReplaceWorkerReportsWhetherTheAttemptsBuildExecuted(t *testing.T) { |
| // kill the same way, so an abandoned forced attempt regained an allowance |
| // it may have spent. |
| func TestASwapWhoseNestedStartIsUncertainReportsExecution(t *testing.T) { |
| + t.Parallel() |
| unitFailed := errors.New("the unit failed to start") |
| for _, tc := range []struct { |
| name string |
| @@ -219,6 +220,7 @@ func TestASwapWhoseNestedStartIsUncertainReportsExecution(t *testing.T) { |
| // abandonment, with nothing executed. Before the fix the kill-proven cases |
| // were abandoned with Executed true. |
| func TestAHoldWhoseNestedStartIsUncertainIsDown(t *testing.T) { |
| + t.Parallel() |
| unitFailed := errors.New("the unit failed to start") |
| exitedUnobserved := func(instancectl.StagedExe) (string, error) { return "", nil } |
| rootFailed := func(instancectl.StagedExe) (string, error) { return "", unitFailed } |
diff --git a/internal/activator/unitproc_gen_test.go b/internal/activator/unitproc_gen_test.go| index 028878c1e..1d8394c42 100644 |
| --- a/internal/activator/unitproc_gen_test.go |
| +++ b/internal/activator/unitproc_gen_test.go |
| @@ -174,6 +174,7 @@ func TestUnitGen(t *testing.T) { |
| // Flag off: a nested wake starts the original template, with the original |
| // launch file, log socket and unit name. |
| func TestStartUnitWithContainmentOffKeepsTheOriginalTemplate(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
diff --git a/internal/activator/unitproc_test.go b/internal/activator/unitproc_test.go| index d65dca226..f002c37d6 100644 |
| --- a/internal/activator/unitproc_test.go |
| +++ b/internal/activator/unitproc_test.go |
| @@ -145,6 +145,7 @@ func nestedBackend(t *testing.T, ctl *fakeControl, unit *fakeUnit) (*ExecBackend |
| } |
| func TestStartUnitWritesTheLaunchFileAndReturnsAUnitProc(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
| @@ -210,6 +211,7 @@ func TestStartUnitWritesTheLaunchFileAndReturnsAUnitProc(t *testing.T) { |
| } |
| func TestUnitProcDoesNotExitOnTerminalStateWhileTheCgroupIsPopulated(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
| @@ -240,6 +242,7 @@ func TestUnitProcDoesNotExitOnTerminalStateWhileTheCgroupIsPopulated(t *testing. |
| } |
| func TestUnitProcStopsAForeignInvocation(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
| @@ -346,6 +349,7 @@ func (e *eventCapture) last() (capturedEvent, bool) { |
| // member-safe event, and the record must be consumed (removed) exactly |
| // once. |
| func TestUnitProcExitLineBoundsAForgedExitRecord(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
| @@ -471,6 +475,7 @@ func TestStopKeepsListenersOpenUntilTerminationIsProven(t *testing.T) { |
| // Stop a second time once it returns ErrStillRunning. The listeners must |
| // still close once termination is proven, with nobody asking again. |
| func TestStopClosesListenersAfterDoneWithNoSecondStopCall(t *testing.T) { |
| + t.Parallel() |
| ctl := &fakeControl{inv: "inv1"} |
| unit := &fakeUnit{} |
| b, rt := nestedBackend(t, ctl, unit) |
diff --git a/internal/activator/wakecheck_claim_linux_test.go b/internal/activator/wakecheck_claim_linux_test.go| index 46340e9e9..bf69a1100 100644 |
| --- a/internal/activator/wakecheck_claim_linux_test.go |
| +++ b/internal/activator/wakecheck_claim_linux_test.go |
| @@ -94,6 +94,7 @@ func newHeldClaimed(t *testing.T, live, hashed string) *heldClaimed { |
| // waits for the install; the launch then snapshots the target and runs it, |
| // recorded first. |
| func TestAClaimedHeldWakeWaitsForRootsInstall(t *testing.T) { |
| + t.Parallel() |
| c := newHeldClaimed(t, "v3", "v1") |
| c.a.HeldTarget = heldOn("v1") |
| r := &asks{then: func(string, string) { c.b.fakeBackend.setLive("v1") }} |
diff --git a/internal/activator/wakeplan_test.go b/internal/activator/wakeplan_test.go| index b188a6a45..675eb3498 100644 |
| --- a/internal/activator/wakeplan_test.go |
| +++ b/internal/activator/wakeplan_test.go |
| @@ -1372,6 +1372,7 @@ func TestAFirstWakeWithTimeForAVerdictStillExecsB(t *testing.T) { |
| // exactly one terminal event. Before the fix both hold cases sent |
| // GenCancelled and the proven overlap crash served nothing. |
| func TestAPlannedWakeWhoseNestedStartIsUncertain(t *testing.T) { |
| + t.Parallel() |
| unitFailed := errors.New("the unit failed to start") |
| // B (v2) is answered as the case says; the good build (v1) starts. |
| bAnswers := func(inv string, err error) func(instancectl.StagedExe) (string, error) { |
diff --git a/internal/activator/wakerecord_refused_test.go b/internal/activator/wakerecord_refused_test.go| index 224175449..2c46a9fad 100644 |
| --- a/internal/activator/wakerecord_refused_test.go |
| +++ b/internal/activator/wakerecord_refused_test.go |
| @@ -67,6 +67,7 @@ func refusedWake(t *testing.T, eb *ExecBackend, rt registry.Route) (error, []str |
| } |
| func TestARefusedLaunchLeavesNoBuildStateRecord(t *testing.T) { |
| + t.Parallel() |
| const host = "shop.example.com" |
| route := func(eb *ExecBackend) registry.Route { |
| return registry.Route{Host: host, Kind: "instance", Hibernate: true, App: "app", |