Skip to content

Commit

Permalink
Make tests less flaky (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdubbelboer committed Jan 10, 2022
1 parent d19b872 commit 7eeb00e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion fs_test.go
Expand Up @@ -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{})
Expand Down Expand Up @@ -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")
}
}
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion header.go
Expand Up @@ -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()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion server_test.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 7eeb00e

Please sign in to comment.