mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 19:51:41 +00:00
control/controlhttp: try to avoid flakes in TestDialPlan
Updates tailscale/corp#7446 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Ifcf3b5176f065c2e67cbb8943f6356dea720a9c5
This commit is contained in:
parent
b55761246b
commit
a4e707bcf0
@ -459,12 +459,25 @@ func TestDialPlan(t *testing.T) {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
testProtocolVersion = 1
|
testProtocolVersion = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
getRandomPort := func() string {
|
||||||
|
ln, err := net.Listen("tcp", ":0")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("net.Listen: %v", err)
|
||||||
|
}
|
||||||
|
defer ln.Close()
|
||||||
|
_, port, err := net.SplitHostPort(ln.Addr().String())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return port
|
||||||
|
}
|
||||||
|
|
||||||
// We need consistent ports for each address; these are chosen
|
// We need consistent ports for each address; these are chosen
|
||||||
// randomly and we hope that they won't conflict during this test.
|
// randomly and we hope that they won't conflict during this test.
|
||||||
httpPort = "40080"
|
httpPort := getRandomPort()
|
||||||
httpsPort = "40443"
|
httpsPort := getRandomPort()
|
||||||
)
|
|
||||||
|
|
||||||
makeHandler := func(t *testing.T, name string, host netip.Addr, wrap func(http.Handler) http.Handler) {
|
makeHandler := func(t *testing.T, name string, host netip.Addr, wrap func(http.Handler) http.Handler) {
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user