wgengine: search randomly for unused port instead of in contiguous range (#18974)

In TestUserspaceEnginePortReconfig, when selecting a port, use a random offset rather than searching in a continguous range in case there is a range that is blocked

Updates tailscale/tailscale#2855

Signed-off-by: kari-ts <kari@tailscale.com>
This commit is contained in:
kari-ts
2026-03-11 12:21:50 -07:00
committed by GitHub
parent 607d01cdae
commit dd1da0b389

View File

@@ -5,6 +5,7 @@
import (
"fmt"
"math/rand"
"net/netip"
"os"
"reflect"
@@ -175,8 +176,8 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
var ue *userspaceEngine
ht := health.NewTracker(bus)
reg := new(usermetric.Registry)
for i := range 100 {
attempt := uint16(defaultPort + i)
for range 100 {
attempt := uint16(defaultPort + rand.Intn(1000))
e, err := NewFakeUserspaceEngine(t.Logf, attempt, &knobs, ht, reg, bus)
if err != nil {
t.Fatal(err)