net/netcheck: remove arbitrary deadlines from GetReport() tests (#13832)

GetReport() may have side effects when the caller enforces a deadline
that is shorter than ReportTimeout.

Updates #13783
Updates #13394

Signed-off-by: Jordan Whited <jordan@tailscale.com>
pull/13840/head
Jordan Whited 1 month ago committed by GitHub
parent 874db2173b
commit 877fa504b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -38,7 +38,7 @@ func TestBasic(t *testing.T) {
c := newTestClient(t) c := newTestClient(t)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
if err := c.Standalone(ctx, "127.0.0.1:0"); err != nil { if err := c.Standalone(ctx, "127.0.0.1:0"); err != nil {
@ -117,7 +117,7 @@ func TestWorksWhenUDPBlocked(t *testing.T) {
c := newTestClient(t) c := newTestClient(t)
ctx, cancel := context.WithTimeout(context.Background(), 250*time.Millisecond) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
r, err := c.GetReport(ctx, dm, nil) r, err := c.GetReport(ctx, dm, nil)
@ -872,3 +872,30 @@ func TestReportTimeouts(t *testing.T) {
t.Errorf("ReportTimeout (%v) cannot be less than httpsProbeTimeout (%v)", ReportTimeout, httpsProbeTimeout) t.Errorf("ReportTimeout (%v) cannot be less than httpsProbeTimeout (%v)", ReportTimeout, httpsProbeTimeout)
} }
} }
func TestNoUDPNilGetReportOpts(t *testing.T) {
blackhole, err := net.ListenPacket("udp4", "127.0.0.1:0")
if err != nil {
t.Fatalf("failed to open blackhole STUN listener: %v", err)
}
defer blackhole.Close()
dm := stuntest.DERPMapOf(blackhole.LocalAddr().String())
for _, region := range dm.Regions {
for _, n := range region.Nodes {
n.STUNOnly = false // exercise ICMP & HTTPS probing
}
}
c := newTestClient(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
r, err := c.GetReport(ctx, dm, nil)
if err != nil {
t.Fatal(err)
}
if r.UDP {
t.Fatal("unexpected working UDP")
}
}

Loading…
Cancel
Save