minimize the race in TestSingleInflight
This commit is contained in:
parent
6f68c4c4bd
commit
996ff55983
|
@ -163,6 +163,10 @@ func TestClientEDNS0Local(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSingleInflight(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)
|
HandleFunc("miek.nl.", HelloServer)
|
||||||
defer HandleRemove("miek.nl.")
|
defer HandleRemove("miek.nl.")
|
||||||
|
|
||||||
|
@ -177,7 +181,7 @@ func TestSingleInflight(t *testing.T) {
|
||||||
|
|
||||||
c := new(Client)
|
c := new(Client)
|
||||||
c.SingleInflight = true
|
c.SingleInflight = true
|
||||||
nr := 10
|
nr := 3
|
||||||
ch := make(chan time.Duration)
|
ch := make(chan time.Duration)
|
||||||
for i := 0; i < nr; i++ {
|
for i := 0; i < nr; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -201,7 +205,7 @@ Loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
if i == 10 {
|
if i == nr {
|
||||||
break Loop
|
break Loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue