carlos / platform Public

activator tests: skip real unix-socket binds in sandboxes

The two tests that bind a real unix listener (sidecar leak, exec next-due)
now use the same probe-and-skip guard internal/host has — everywhere else
the backend fakes ride TCP, so the rest of the suite still runs sandboxed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Paul Campbell df1989259c4959c6846713eac21e18fd2bc6a764 parent 4a21c80
1 file changed, +21 −0
  • internal/activator/activator_test.go +21 −0
diff --git a/internal/activator/activator_test.go b/internal/activator/activator_test.go
index 35a46dbc5..f462e0df0 100644
--- a/internal/activator/activator_test.go
+++ b/internal/activator/activator_test.go
@@ -20,6 +20,7 @@ import (
"net/http/httputil"
"os"
"path/filepath"
+ "strings"
"sync"
"sync/atomic"
"testing"
@@ -454,6 +455,22 @@ func proxyGet(t *testing.T, base, host string) (string, int) {
return string(b), resp.StatusCode
}
+// requireUnixSockets skips a test when the sandbox forbids unix-socket
+// creation (probe: net.Listen("unix")), matching internal/host's helper. Most
+// tests here fake the backend over TCP; only the ones that bind a real unix
+// listener need this.
+func requireUnixSockets(t *testing.T) {
+ t.Helper()
+ l, err := net.Listen("unix", tmpSock(t))
+ if err != nil {
+ if strings.Contains(err.Error(), "operation not permitted") {
+ t.Skipf("sandbox forbids unix sockets: %v", err)
+ }
+ t.Fatalf("unix socket probe: %v", err)
+ }
+ l.Close()
+}
+
// tmpSock returns a short unix socket path (the sun_path limit is ~104 bytes,
// so t.TempDir() can be too long) and schedules its removal.
func tmpSock(t *testing.T) string {
@@ -912,6 +929,7 @@ func TestActivatorLeaseContention503(t *testing.T) {
// deploy-safety property that lets the bucket env ship fleet-wide before any
// host is flagged.
func TestRouterPerHostHibernateGating(t *testing.T) {
+ requireUnixSockets(t)
a, b, _, reg := testActivator(t, time.Minute)
// Two live backends playing the instances. The flagged host's listener
@@ -1076,6 +1094,7 @@ func TestActivatorRetireDuringWake(t *testing.T) {
// With hibernation on, sibling services (kind "service") are untouched: the
// edge proxies them directly, no wake, no activity tracking.
func TestActivatorServiceRoutesBypass(t *testing.T) {
+ requireUnixSockets(t)
sock := tmpSock(t)
ln, err := net.Listen("unix", sock)
if err != nil {
@@ -1527,6 +1546,7 @@ func TestActivatorSidecarRestartBackoff(t *testing.T) {
// stamps (stamps are per-request), so the marker is not a DoS lever in either
// direction.
func TestActivatorSidecarRequestsInvisibleToActivity(t *testing.T) {
+ requireUnixSockets(t)
a, b, clk, reg := testActivator(t, 10*time.Second)
// A live backend listener stands in for the child a wake would have
@@ -1797,6 +1817,7 @@ func splitEnv(kv string) (k, v string, ok bool) {
// The sleep-time next-due probe: GET /api/next-due over the instance's unix
// socket, authorized with the CARLOS_ADMIN_TOKEN from its env file.
func TestExecBackendNextDue(t *testing.T) {
+ requireUnixSockets(t)
b := testExecBackend(t)
sock := tmpSock(t)
ln, err := net.Listen("unix", sock)