Make tests less flaky (#1189)

This commit is contained in:
Erik Dubbelboer
2022-01-10 12:15:30 +08:00
committed by GitHub
parent d19b8727b0
commit 7eeb00e1cc
3 changed files with 13 additions and 3 deletions
+11 -1
View File
@@ -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)
+1 -1
View File
@@ -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()),
}
}
+1 -1
View File
@@ -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 {