Skip to content

Commit

Permalink
profiler: fix race in TestProfilerPassthrough
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
knusbaum committed Feb 26, 2020
1 parent b058d3b commit 2ed08f7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions profiler/profiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 2ed08f7

Please sign in to comment.