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>
main
kari-ts 1 month ago committed by GitHub
parent 607d01cdae
commit dd1da0b389
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      wgengine/userspace_test.go

@ -5,6 +5,7 @@ package wgengine
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)

Loading…
Cancel
Save