mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-26 01:01:01 +00:00
Merge pull request #445 from SandroJijavadze/fix-443-flaky-test
fix flaky test gosched hack
This commit is contained in:
commit
3a63a4b86c
1 changed files with 9 additions and 0 deletions
|
@ -15,6 +15,7 @@ package relay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -68,6 +69,14 @@ func TestRelay_RelayLine(t *testing.T) {
|
||||||
for _, line := range tt.args.lines {
|
for _, line := range tt.args.lines {
|
||||||
r.RelayLine(line)
|
r.RelayLine(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for goSchedTimes := 0; goSchedTimes < 1000; goSchedTimes++ {
|
||||||
|
if len(r.bufferChannel) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
runtime.Gosched()
|
||||||
|
}
|
||||||
|
|
||||||
// Tick time forward to trigger a packet send.
|
// Tick time forward to trigger a packet send.
|
||||||
clock.ClockInstance.Instant = time.Unix(1, 10)
|
clock.ClockInstance.Instant = time.Unix(1, 10)
|
||||||
clock.ClockInstance.TickerCh <- time.Unix(0, 0)
|
clock.ClockInstance.TickerCh <- time.Unix(0, 0)
|
||||||
|
|
Loading…
Reference in a new issue