From b1f80555845d5f1a8c5775a01eb98b8354e15216 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Thu, 15 Jun 2023 15:24:03 +0200 Subject: [PATCH] TestConnectWithFallback: increase timeout on Windows connecting on a closed port takes about 2 seconds. You can test with something like this start := time.Now() _, err := d.DialContext(context.Background(), "tcp", "127.0.0.1:1") fmt.Printf("finished, time %s, err: %v\n", time.Since(start), err) This seems by design https://groups.google.com/g/comp.os.ms-windows.programmer.win32/c/jV6kRVY3BqM Generally TestConnectWithFallback takes about 8-9 seconds on Windows. Increase timeout to avoid random failures under load --- pgconn/pgconn_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgconn/pgconn_test.go b/pgconn/pgconn_test.go index 2be99500..09ca52a2 100644 --- a/pgconn/pgconn_test.go +++ b/pgconn/pgconn_test.go @@ -496,7 +496,7 @@ func TestConnectWithRuntimeParams(t *testing.T) { func TestConnectWithFallback(t *testing.T) { t.Parallel() - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))