From 6c58c4a99450257854d6364e4ee3361edf6e9bb1 Mon Sep 17 00:00:00 2001 From: Matthew Mattox Date: Tue, 10 Nov 2026 16:39:17 -0600 Subject: [PATCH 1/3] test: give each integration node its own API port Every test node started the API on the default 127.0.0.1:8080. Only one mount at a time could bind it, and on .68 an unrelated service holds it, so a -short run logged about 150 "Failed to start API server" lines. Each node now gets a free loopback port next to its broadcast ports. Co-Authored-By: Claude Opus 5.5 --- tests/integration/api_test.go | 12 ----- tests/integration/helpers.go | 67 ++++++++++++++++---------- tests/integration/multinode_helpers.go | 2 +- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/tests/integration/api_test.go b/tests/integration/api_test.go index 390e8847..d4cd3086 100644 --- a/tests/integration/api_test.go +++ b/tests/integration/api_test.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "io" - "net" "net/http" "os" "os/exec" @@ -15,17 +14,6 @@ import ( "time" ) -func freeLoopbackAddr(t *testing.T) string { - t.Helper() - ln, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("Failed to find a free port: %v", err) - } - addr := ln.Addr().String() - ln.Close() - return addr -} - func TestAPIServesHealthOnLoopback(t *testing.T) { mfs := NewMountedFS(t, 20) addr := freeLoopbackAddr(t) diff --git a/tests/integration/helpers.go b/tests/integration/helpers.go index daca684f..2b328e08 100644 --- a/tests/integration/helpers.go +++ b/tests/integration/helpers.go @@ -30,8 +30,8 @@ type MountedFS struct { ctx context.Context cancel context.CancelFunc - // broadcastArgs give the node its own broadcast ports; ExtraArgs come after and win. - broadcastArgs []string + // portArgs give the node its own broadcast and API ports; ExtraArgs come after and win. + portArgs []string } // freeUDPPorts returns n distinct UDP ports that were free on all interfaces. @@ -49,11 +49,26 @@ func freeUDPPorts(t *testing.T, n int) []int { return ports } -// broadcastArgs sets the broadcast ports. Nodes of one cluster share the -// multicast port, every node needs its own unicast port, and a mount fails -// when it cannot bind them. -func broadcastArgs(mcastPort, unicastPort int) []string { - return []string{"-mcast-port", strconv.Itoa(mcastPort), "-unicast-port", strconv.Itoa(unicastPort)} +func freeLoopbackAddr(t *testing.T) string { + t.Helper() + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatalf("Failed to find a free port: %v", err) + } + addr := ln.Addr().String() + ln.Close() + return addr +} + +// portArgs sets the node's ports. Nodes of one cluster share the multicast +// port, every node needs its own unicast port, and a mount fails when it +// cannot bind them. The API gets a free port instead of the default 8080. +func portArgs(t *testing.T, mcastPort, unicastPort int) []string { + return []string{ + "-mcast-port", strconv.Itoa(mcastPort), + "-unicast-port", strconv.Itoa(unicastPort), + "-api-addr", freeLoopbackAddr(t), + } } // findBinary locates the goclusterfs-mount binary. @@ -123,13 +138,13 @@ func NewMountedFS(t *testing.T, sizeMB int) *MountedFS { ports := freeUDPPorts(t, 2) mfs := &MountedFS{ - ImagePath: imagePath, - MountPoint: mountPoint, - BinaryPath: binaryPath, - t: t, - ctx: ctx, - cancel: cancel, - broadcastArgs: broadcastArgs(ports[0], ports[1]), + ImagePath: imagePath, + MountPoint: mountPoint, + BinaryPath: binaryPath, + t: t, + ctx: ctx, + cancel: cancel, + portArgs: portArgs(t, ports[0], ports[1]), } // Register cleanup @@ -160,7 +175,7 @@ func (m *MountedFS) Format() error { "-mount", m.MountPoint, "-format", } - args = append(args, m.broadcastArgs...) + args = append(args, m.portArgs...) cmd := exec.Command(m.BinaryPath, args...) @@ -232,7 +247,7 @@ func (m *MountedFS) Mount(debug bool) error { if debug { args = append(args, "-debug") } - args = append(args, m.broadcastArgs...) + args = append(args, m.portArgs...) args = append(args, m.ExtraArgs...) // Create a fresh context for this mount operation @@ -267,7 +282,7 @@ func (m *MountedFS) FormatAndMount(debug bool) error { if debug { args = append(args, "-debug") } - args = append(args, m.broadcastArgs...) + args = append(args, m.portArgs...) args = append(args, m.ExtraArgs...) m.MountCmd = exec.CommandContext(m.ctx, m.BinaryPath, args...) @@ -469,13 +484,13 @@ func NewMountedFSWithImage(t *testing.T, imagePath string) *MountedFS { ports := freeUDPPorts(t, 2) mfs := &MountedFS{ - ImagePath: imagePath, - MountPoint: mountPoint, - BinaryPath: binaryPath, - t: t, - ctx: ctx, - cancel: cancel, - broadcastArgs: broadcastArgs(ports[0], ports[1]), + ImagePath: imagePath, + MountPoint: mountPoint, + BinaryPath: binaryPath, + t: t, + ctx: ctx, + cancel: cancel, + portArgs: portArgs(t, ports[0], ports[1]), } // Register cleanup - only removes mount point, NOT the shared image @@ -532,7 +547,7 @@ func (m *MountedFS) FormatAndMountWithSFB(debug bool) error { if debug { args = append(args, "-debug") } - args = append(args, m.broadcastArgs...) + args = append(args, m.portArgs...) m.MountCmd = exec.CommandContext(m.ctx, m.BinaryPath, args...) m.MountCmd.Stdout = m.output() @@ -562,7 +577,7 @@ func (m *MountedFS) MountWithSFB(debug bool) error { if debug { args = append(args, "-debug") } - args = append(args, m.broadcastArgs...) + args = append(args, m.portArgs...) // Create a fresh context for this mount operation m.ctx, m.cancel = context.WithCancel(context.Background()) diff --git a/tests/integration/multinode_helpers.go b/tests/integration/multinode_helpers.go index 161b8961..8bb604de 100644 --- a/tests/integration/multinode_helpers.go +++ b/tests/integration/multinode_helpers.go @@ -60,7 +60,7 @@ func NewMultiNodeCluster(t *testing.T, nodeCount, sizeMB int) *MultiNodeCluster ports := freeUDPPorts(t, nodeCount+1) for i := 0; i < nodeCount; i++ { cluster.Nodes[i] = NewMountedFSWithImage(t, imagePath) - cluster.Nodes[i].broadcastArgs = broadcastArgs(ports[0], ports[i+1]) + cluster.Nodes[i].portArgs = portArgs(t, ports[0], ports[i+1]) } // Register cleanup From bc41e2e50553e14a0660272ad6bf0928112953ed Mon Sep 17 00:00:00 2001 From: Matthew Mattox Date: Thu, 12 Nov 2026 00:52:33 -0600 Subject: [PATCH 2/3] test: keep the net import that #57's gfsctl test needs Co-Authored-By: Claude Opus 5.5 --- tests/integration/api_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/api_test.go b/tests/integration/api_test.go index d4cd3086..4d7fc881 100644 --- a/tests/integration/api_test.go +++ b/tests/integration/api_test.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "io" + "net" "net/http" "os" "os/exec" From be8c61959b077fc2d22abefbf387dddd40af6fa5 Mon Sep 17 00:00:00 2001 From: Matthew Mattox Date: Thu, 12 Nov 2026 01:19:35 -0600 Subject: [PATCH 3/3] ci: run checks on main Co-Authored-By: Claude Opus 5.5