forked from mirror/client_golang
Unflake TestGoCollectorGoroutines
This is not a great solution, but it's also hard to test for this moving target. Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
3ddc3cfbe5
commit
6fa429cf42
|
@ -44,9 +44,14 @@ func TestGoCollectorGoroutines(t *testing.T) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
c.Collect(metricCh)
|
c.Collect(metricCh)
|
||||||
go func(c <-chan struct{}) {
|
for i := 1; i <= 10; i++ {
|
||||||
<-c
|
// Start 10 goroutines to be sure we'll detect an
|
||||||
}(endGoroutineCh)
|
// increase even if unrelated goroutines happen to
|
||||||
|
// terminate during this test.
|
||||||
|
go func(c <-chan struct{}) {
|
||||||
|
<-c
|
||||||
|
}(endGoroutineCh)
|
||||||
|
}
|
||||||
<-waitCh
|
<-waitCh
|
||||||
c.Collect(metricCh)
|
c.Collect(metricCh)
|
||||||
close(endCollectionCh)
|
close(endCollectionCh)
|
||||||
|
@ -73,9 +78,8 @@ func TestGoCollectorGoroutines(t *testing.T) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff := int(pb.GetGauge().GetValue()) - old; diff != 1 {
|
if diff := old - int(pb.GetGauge().GetValue()); diff > -1 {
|
||||||
// TODO: This is flaky in highly concurrent situations.
|
t.Errorf("want at least one new goroutine, got %d fewer", diff)
|
||||||
t.Errorf("want 1 new goroutine, got %d", diff)
|
|
||||||
}
|
}
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
t.Fatalf("expected collect timed out")
|
t.Fatalf("expected collect timed out")
|
||||||
|
|
Loading…
Reference in New Issue