From ff4bc9a0d7bf5ec5f2fca2fc7955cd0e9ac7f3a6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 5 Dec 2026 14:51:37 -0800 Subject: [PATCH 1/2] test(block): claim the mini test's ports host-wide The pid-derived --port-shift put mini's 13 ports inside the handoff and weed pair ranges the other process-level harnesses claim, unclaimed, so a parallel CI shard could bind one of them. Pick a shift whose every port is claimed and free, as handoffAddress does. Co-Authored-By: Claude Opus 5.5 --- .../mini_nonroot_integration_test.go | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go b/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go index d46d84870e..e708452ba8 100644 --- a/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go +++ b/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go @@ -5,6 +5,8 @@ package main_test import ( "context" "fmt" + "math/rand" + "net" "os" "path/filepath" "strings" @@ -41,7 +43,7 @@ func TestMiniStartsWithoutRootAndNamesItsBinaries(t *testing.T) { t.Fatal(err) } cli := filepath.Join(bins, "sw-block") - shift := 3000 + (os.Getpid()*13)%6000 + shift := miniPortShift(t) dir := filepath.Join(t.TempDir(), "mini") ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute) defer cancel() @@ -131,6 +133,35 @@ func miniGoBuild(t *testing.T, out, pkg string) { } +// miniPortShift picks a --port-shift whose every mini port (defaultMiniPorts +// in cmd/sw-block) is claimed host-wide and free now, as the other harnesses' +// ports are, so a parallel process-level shard never binds one of them. +func miniPortShift(t *testing.T) int { + t.Helper() + defaults := []int{9180, 9201, 9202, 9203, 4420, 9333, 19333, 9340, 19340, 8888, 18888, 12535, 22535} + for i := 0; i < 200; i++ { + shift := 3000 + rand.Intn(6000) + free := true + for _, p := range defaults { + if !claimHostPort(p + shift) { + free = false + break + } + ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", p+shift)) + if err != nil { + free = false + break + } + ln.Close() + } + if free { + return shift + } + } + t.Fatal("no --port-shift with every mini port claimed and free") + return 0 +} + func exists(p string) bool { _, err := os.Stat(p) return err == nil From 20c36760b9de630644f6c7e552e66731f44c6594 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 5 Dec 2026 14:57:29 -0800 Subject: [PATCH 2/2] test(block): claim the failed-start mini launch's ports too The second launch ran at shift+1, whose ports were neither claimed nor checked, so a parallel shard could take one and fail the launch before it reached the deliberate blockvolume refusal. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go b/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go index e708452ba8..93e7dcc347 100644 --- a/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go +++ b/seaweed-block/cmd/blockvolume/mini_nonroot_integration_test.go @@ -105,7 +105,7 @@ func TestMiniStartsWithoutRootAndNamesItsBinaries(t *testing.T) { dir2 := filepath.Join(t.TempDir(), "mini") ctx2, cancel2 := context.WithTimeout(context.Background(), 3*time.Minute) defer cancel2() - p2 := startOwnedMini(t, ctx2, cli, "mini", "--dir", dir2, "--bin", broken, "--weed", weed, "--port-shift", fmt.Sprint(shift+1)) + p2 := startOwnedMini(t, ctx2, cli, "mini", "--dir", dir2, "--bin", broken, "--weed", weed, "--port-shift", fmt.Sprint(miniPortShift(t))) err = p2.join(t, 3*time.Minute+miniShutdownGrace+10*time.Second) b2 := p2.output.String() t.Logf("failed start:\n%s", b2)