Isolate API test configuration and shorten control socket fixtures
2 files changed,
+23
−9
apimode_test.go+1 −0internal/activator/activator_test.go+22 −9
CI failed — run details
diff --git a/apimode_test.go b/apimode_test.go| index 681094f26..df68f7251 100644 |
| --- a/apimode_test.go |
| +++ b/apimode_test.go |
| @@ -51,6 +51,7 @@ func clearDeploymentEnv(t *testing.T) { |
| t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "") |
| t.Setenv("CARLOS_DEPLOYMENT_DIR", "") |
| t.Setenv("CARLOS_CONSOLE", "") |
| + t.Setenv("CARLOS_CONFIG", filepath.Join(t.TempDir(), "config")) |
| } |
| func TestResolveModeDirectWins(t *testing.T) { |
diff --git a/internal/activator/activator_test.go b/internal/activator/activator_test.go| index c27ccd6ca..a16d90892 100644 |
| --- a/internal/activator/activator_test.go |
| +++ b/internal/activator/activator_test.go |
| @@ -863,6 +863,19 @@ func tmpSock(t *testing.T) string { |
| return s |
| } |
| +// shortTempDir is a direct child of the configured temp root. t.TempDir |
| +// includes the test's full name, which can push a derived .control socket |
| +// past sockaddr_un.sun_path's limit when TMPDIR is a disk-backed gate path. |
| +func shortTempDir(t *testing.T) string { |
| + t.Helper() |
| + dir, err := os.MkdirTemp(os.TempDir(), "ca-") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { os.RemoveAll(dir) }) |
| + return dir |
| +} |
| + |
| // --- tests --------------------------------------------------------------------- |
| // Many concurrent requests during a wake coalesce into exactly one wake: one |
| @@ -4832,7 +4845,7 @@ func TestExecBackendStartPassesControlSocketInEnvAndStartsPurgeListener(t *testi |
| rt := registry.Route{ |
| Host: "control-socket.example.com", |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| wantControlSocket := rt.Socket + ".control" |
| @@ -4898,7 +4911,7 @@ func TestExecBackendStartWithNilCacheStillBindsControlSocket(t *testing.T) { |
| rt := registry.Route{ |
| Host: host, |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| wantControlSocket := rt.Socket + ".control" |
| @@ -4981,7 +4994,7 @@ func (f *fakeTimerStore) CountTimers(host, kind string) (int, error) { retu |
| func startAndReachControlSocket(t *testing.T, b *ExecBackend, host string) (controlSocket, token string, stop func()) { |
| t.Helper() |
| stageRecordingLiveFullEnv(t, b, host, "v1") |
| - rt := registry.Route{Host: host, Kind: "instance", Socket: filepath.Join(t.TempDir(), "instance.sock")} |
| + rt := registry.Route{Host: host, Kind: "instance", Socket: filepath.Join(shortTempDir(t), "instance.sock")} |
| controlSocket = rt.Socket + ".control" |
| ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| @@ -5116,7 +5129,7 @@ func TestExecBackendStartMergesConfigEnvUnderOwnEnv(t *testing.T) { |
| rt := registry.Route{ |
| Host: host, |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| @@ -5163,7 +5176,7 @@ func TestExecBackendStartAdvertisesHeaderPurgeChannel(t *testing.T) { |
| rt := registry.Route{ |
| Host: host, |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| @@ -5202,7 +5215,7 @@ func TestExecBackendStartWithNilCacheSetsNoPurgeVar(t *testing.T) { |
| rt := registry.Route{ |
| Host: host, |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| @@ -5247,7 +5260,7 @@ func TestExecBackendStartTenantCannotClaimAbsentPurgeChannel(t *testing.T) { |
| rt := registry.Route{ |
| Host: host, |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| @@ -5295,7 +5308,7 @@ func TestExecBackendStartOverridesTenantSuppliedPurgeVars(t *testing.T) { |
| rt := registry.Route{ |
| Host: host, |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| @@ -5344,7 +5357,7 @@ func TestExecBackendStartPurgesHostCacheOnSpawn(t *testing.T) { |
| rt := registry.Route{ |
| Host: "deploy.example.com", |
| Kind: "instance", |
| - Socket: filepath.Join(t.TempDir(), "instance.sock"), |
| + Socket: filepath.Join(shortTempDir(t), "instance.sock"), |
| } |
| proc, _, _ := b.Start(ctx, rt) // health-wait failure is expected; the spawn still happened |
| if proc != nil { |