diff --git a/client_test.go b/client_test.go index 313f0536..7bffa09e 100644 --- a/client_test.go +++ b/client_test.go @@ -163,6 +163,10 @@ func TestClientEDNS0Local(t *testing.T) { } func TestSingleInflight(t *testing.T) { + // Test is inherently racy, because queries might actually be returned before the test + // is over, leading to multiple queries even with SingleInflight. This ofcourse then + // leads to diff. rrts and the test fails. Number of tests is now 3, to lower the chance + // for the race to hit. HandleFunc("miek.nl.", HelloServer) defer HandleRemove("miek.nl.") @@ -177,7 +181,7 @@ func TestSingleInflight(t *testing.T) { c := new(Client) c.SingleInflight = true - nr := 10 + nr := 3 ch := make(chan time.Duration) for i := 0; i < nr; i++ { go func() { @@ -201,7 +205,7 @@ Loop: } } i++ - if i == 10 { + if i == nr { break Loop } }