From 18e7e3c0b5e2b73bbb64893e7a5d06ce9f80c446 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Tue, 8 Jul 2025 15:43:46 +0400 Subject: [PATCH] chore: stop running postgres-only tests if DB is not set --- coderd/database/db_test.go | 4 ++++ coderd/database/dbtestutil/postgres.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/coderd/database/db_test.go b/coderd/database/db_test.go index 68b60a788fd3d..f9442942e53e1 100644 --- a/coderd/database/db_test.go +++ b/coderd/database/db_test.go @@ -85,6 +85,10 @@ func TestNestedInTx(t *testing.T) { func testSQLDB(t testing.TB) *sql.DB { t.Helper() + if !dbtestutil.WillUsePostgres() { + t.Skip("this test requires postgres") + } + connection, err := dbtestutil.Open(t) require.NoError(t, err) diff --git a/coderd/database/dbtestutil/postgres.go b/coderd/database/dbtestutil/postgres.go index c1cfa383577de..e5aa4b14de83b 100644 --- a/coderd/database/dbtestutil/postgres.go +++ b/coderd/database/dbtestutil/postgres.go @@ -81,7 +81,7 @@ func initDefaultConnection(t TBSubset) error { } var dbErr error - // Retry up to 3 seconds for temporary errors. + // Retry up to 10 seconds for temporary errors. ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() for r := retry.New(10*time.Millisecond, 500*time.Millisecond); r.Wait(ctx); { @@ -93,7 +93,7 @@ func initDefaultConnection(t TBSubset) error { if !containsAnySubstring(errString, retryableErrSubstrings) { break } - t.Logf("failed to connect to postgres, retrying: %s", errString) + t.Logf("%s failed to connect to postgres, retrying: %s", time.Now().Format(time.StampMilli), errString) } // After the loop dbErr is the last connection error (if any).