From 2ed08f7893a8768ef350d138d60dd4cfcb16f8ae Mon Sep 17 00:00:00 2001 From: Kyle Nusbaum Date: Wed, 26 Feb 2020 13:05:26 -0600 Subject: [PATCH] profiler: fix race in TestProfilerPassthrough The test previously was trying to read from the p.out channel, which was racing against the send() function and uploadFunc This patch makes the test read from the correct out channel and eliminates an unnecessary loop. --- profiler/profiler_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/profiler/profiler_test.go b/profiler/profiler_test.go index bbc0d9b519..927f50ae2b 100644 --- a/profiler/profiler_test.go +++ b/profiler/profiler_test.go @@ -202,14 +202,10 @@ func TestProfilerPassthrough(t *testing.T) { } p.run() var bat batch -loop: - for { - select { - case bat = <-p.out: - break loop - case <-time.After(500 * time.Millisecond): - t.Fatal("time expired") - } + select { + case bat = <-out: + case <-time.After(500 * time.Millisecond): + t.Fatal("time expired") } assert.Equal(t, 2, len(bat.profiles))