From 7eeb00e1ccc54b29a6a165c6a27d5dfa96b416ca Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 10 Jan 2022 12:15:30 +0800 Subject: [PATCH] Make tests less flaky (#1189) --- fs_test.go | 12 +++++++++++- header.go | 2 +- server_test.go | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs_test.go b/fs_test.go index 5c39cb1..51a7e2a 100644 --- a/fs_test.go +++ b/fs_test.go @@ -483,6 +483,11 @@ func testParseByteRangeError(t *testing.T, v string, contentLength int) { } func TestFSCompressConcurrent(t *testing.T) { + // Don't run this test on Windows, the Windows Github actions are to slow and timeout too often. + if runtime.GOOS == "windows" { + t.SkipNow() + } + // This test can't run parallel as files in / might be changed by other tests. stop := make(chan struct{}) @@ -513,7 +518,7 @@ func TestFSCompressConcurrent(t *testing.T) { for i := 0; i < concurrency; i++ { select { case <-ch: - case <-time.After(time.Second * 3): + case <-time.After(time.Second * 2): t.Fatalf("timeout") } } @@ -540,6 +545,11 @@ func TestFSCompressSingleThread(t *testing.T) { } func testFSCompress(t *testing.T, h RequestHandler, filePath string) { + // File locking is flaky on Windows. + if runtime.GOOS == "windows" { + t.SkipNow() + } + var ctx RequestCtx ctx.Init(&Request{}, nil, nil) diff --git a/header.go b/header.go index 14cda98..123fe95 100644 --- a/header.go +++ b/header.go @@ -1991,7 +1991,7 @@ func (h *RequestHeader) tryRead(r *bufio.Reader, n int) error { // This is for go 1.6 bug. See https://github.com/golang/go/issues/14121 . if err == bufio.ErrBufferFull { return &ErrSmallBuffer{ - error: fmt.Errorf("error when reading request headers: %w", errSmallBuffer), + error: fmt.Errorf("error when reading request headers: %w (n=%d, r.Buffered()=%d)", errSmallBuffer, n, r.Buffered()), } } diff --git a/server_test.go b/server_test.go index 0a199b8..ec2f656 100644 --- a/server_test.go +++ b/server_test.go @@ -1142,7 +1142,7 @@ func TestServerTLSReadTimeout(t *testing.T) { select { case err = <-r: - case <-time.After(time.Second): + case <-time.After(time.Second * 2): } if err == nil {