Skip to content

Commit

Permalink
profiler: fix race in TestProfilerPassthrough (DataDog#601)
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 authored and mingrammer committed Dec 22, 2020
1 parent 6d4eecd commit 1daeaa6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions profiler/profiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,12 @@ 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:
// TODO (knusbaum) this timeout is long because we were seeing timeouts at 500ms.
// it would be nice to have a time-independent way to test this
case <-time.After(1000 * time.Millisecond):
t.Fatal("time expired")
}

assert.Equal(t, 2, len(bat.profiles))
Expand Down

0 comments on commit 1daeaa6

Please sign in to comment.