minimize the race in TestSingleInflight

This commit is contained in:
Miek Gieben 2015-08-22 13:42:02 +01:00
parent 6f68c4c4bd
commit 996ff55983
1 changed files with 6 additions and 2 deletions

View File

@ -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
}
}