From 5d1bb8a9cf03422554dd52abf5eba89b8ca11307 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 18 Feb 2025 12:05:50 +0900 Subject: [PATCH] fix flaky test. (#1663) TestIssue1567 fails by max_connections error. This makes our CI unhappy. https://github.com/go-sql-driver/mysql/actions/runs/12904961433/job/35984402310 --- 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)))