From 7944155140fbcd2f6f21fd7f4024c2c32d774107 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 23 Jan 2025 19:48:32 +0900 Subject: [PATCH] fix flaky test. --- driver_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/driver_test.go b/driver_test.go index 58b3cb38..00e82865 100644 --- a/driver_test.go +++ b/driver_test.go @@ -3608,6 +3608,12 @@ func runCallCommand(dbt *DBTest, query, name string) { func TestIssue1567(t *testing.T) { // enable TLS. runTests(t, dsn+"&tls=skip-verify", func(dbt *DBTest) { + var max int + err := dbt.db.QueryRow("SELECT @@max_connections").Scan(&max) + if err != nil { + dbt.Fatalf("%s", err.Error()) + } + // disable connection pooling. // data race happens when new connection is created. dbt.db.SetMaxIdleConns(0) @@ -3627,6 +3633,9 @@ func TestIssue1567(t *testing.T) { if testing.Short() { count = 10 } + if count > max { + count = max + } for i := 0; i < count; i++ { timeout := time.Duration(mrand.Int63n(int64(rtt)))