fix flaky test gosched hack

Signed-off-by: Sandro Jijavadze <sandrojijavadze@protonmail.com>
This commit is contained in:
Sandro Jijavadze 2022-06-21 19:36:20 +04:00
parent d90c8ff92d
commit 2ab624a917

View file

@ -15,6 +15,7 @@ package relay
import (
"fmt"
"runtime"
"testing"
"time"
@ -68,6 +69,14 @@ func TestRelay_RelayLine(t *testing.T) {
for _, line := range tt.args.lines {
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.
clock.ClockInstance.Instant = time.Unix(1, 10)
clock.ClockInstance.TickerCh <- time.Unix(0, 0)