Merge pull request #445 from SandroJijavadze/fix-443-flaky-test

fix flaky test gosched hack
This commit is contained in:
Matthias Rampke 2022-06-28 20:18:13 +02:00 committed by GitHub
commit 3a63a4b86c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)