forked from mirrors/statsd_exporter
fix flaky test gosched hack
Signed-off-by: Sandro Jijavadze <sandrojijavadze@protonmail.com>
This commit is contained in:
parent
d90c8ff92d
commit
2ab624a917
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