From a794f77b540330ff581a66a42448c270c378109c Mon Sep 17 00:00:00 2001 From: William Kennedy Date: Wed, 12 Aug 2015 15:23:41 -0400 Subject: [PATCH] Update go_collector_test.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are running into a timeout with TestHistogramConcurrency on our Jenkins box. I noticed in the stack trace for the timeout this block. goroutine 2348 [chan send]: github.comcast.com/ventris/kober/vnd/github.com/prometheus/client_golang/prometheus.(*goCollector).Collect(0xc20801e8e0, 0xc20800a7e0) /var/lib/jenkins/jobs/Kober/workspace/src/github.comcast.com/ventris/kober/vnd/github.com/prometheus/client_golang/prometheus/go_collector.go:49 +0x6dd github.comcast.com/ventris/kober/vnd/github.com/prometheus/client_golang/prometheus.funcĀ·028() /var/lib/jenkins/jobs/Kober/workspace/src/github.comcast.com/ventris/kober/vnd/github.com/prometheus/client_golang/prometheus/go_collector_test.go:27 +0x11a created by github.comcast.com/ventris/kober/vnd/github.com/prometheus/client_golang/prometheus.TestGoCollector /var/lib/jenkins/jobs/Kober/workspace/src/github.comcast.com/ventris/kober/vnd/github.com/prometheus/client_golang/prometheus/go_collector_test.go:28 +0x35e This suggested that even though the TestGoCollector test was finished, a goroutine was still hanging around. I traced it back to the call to c.Collect always sending twice of the provided channel. This change receives that second value and allows the goroutine to finish with the test. Still can't figure out why TestHistogramConcurrency is timing out after 2 minutes :( --- prometheus/go_collector_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prometheus/go_collector_test.go b/prometheus/go_collector_test.go index b75d28e..d3d52cd 100644 --- a/prometheus/go_collector_test.go +++ b/prometheus/go_collector_test.go @@ -50,6 +50,10 @@ func TestGoCollector(t *testing.T) { t.Errorf("want 1 new goroutine, got %d", diff) } + // GoCollector performs two sends per call. + // On line 27 we need to revceive the second send + // to shutdown cleanly. + <-ch return } case <-time.After(1 * time.Second):