Fix flaky datagramsession test

This commit is contained in:
MoofMonkey 2022-10-03 12:02:14 +03:00
parent 49438f30f5
commit 301b2baca3
1 changed files with 3 additions and 3 deletions

View File

@ -111,8 +111,8 @@ func TestReadFromDstSessionPreventClosed(t *testing.T) {
} }
func testActiveSessionNotClosed(t *testing.T, readFromDst bool, writeToDst bool) { func testActiveSessionNotClosed(t *testing.T, readFromDst bool, writeToDst bool) {
const closeAfterIdle = time.Millisecond * 100 const closeAfterIdle = time.Millisecond * 300
const activeTime = time.Millisecond * 500 const activeTime = closeAfterIdle * 3
sessionID := uuid.New() sessionID := uuid.New()
cfdConn, originConn := net.Pipe() cfdConn, originConn := net.Pipe()
@ -129,7 +129,7 @@ func testActiveSessionNotClosed(t *testing.T, readFromDst bool, writeToDst bool)
errGroup, ctx := errgroup.WithContext(ctx) errGroup, ctx := errgroup.WithContext(ctx)
errGroup.Go(func() error { errGroup.Go(func() error {
session.Serve(ctx, closeAfterIdle) session.Serve(ctx, closeAfterIdle)
if time.Now().Before(startTime.Add(activeTime)) { if time.Now().Before(activeUntil) {
return fmt.Errorf("session closed while it's still active") return fmt.Errorf("session closed while it's still active")
} }
return nil return nil