Skip to content

Commit bf0271f

Browse files
authored
chore: stop running postgres-only tests if DB is not set (#18784)
Fixes coder/internal#695 PostgreSQL tests are getting run in a non-postgres CI job because the tests don't get skipped if the `DB=` env is unset. This PR adds a skip for them. They are flaking in the `test-go-race` CI job. They run fine in the `test-go-race-pg` job, which pre-creates the postgres server, so the flakiness is almost certainly related to spinning up the database server.
1 parent 211393a commit bf0271f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

coderd/database/db_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func TestNestedInTx(t *testing.T) {
8585
func testSQLDB(t testing.TB) *sql.DB {
8686
t.Helper()
8787

88+
if !dbtestutil.WillUsePostgres() {
89+
t.Skip("this test requires postgres")
90+
}
91+
8892
connection, err := dbtestutil.Open(t)
8993
require.NoError(t, err)
9094

coderd/database/dbtestutil/postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func initDefaultConnection(t TBSubset) error {
8181
}
8282

8383
var dbErr error
84-
// Retry up to 3 seconds for temporary errors.
84+
// Retry up to 10 seconds for temporary errors.
8585
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
8686
defer cancel()
8787
for r := retry.New(10*time.Millisecond, 500*time.Millisecond); r.Wait(ctx); {
@@ -93,7 +93,7 @@ func initDefaultConnection(t TBSubset) error {
9393
if !containsAnySubstring(errString, retryableErrSubstrings) {
9494
break
9595
}
96-
t.Logf("failed to connect to postgres, retrying: %s", errString)
96+
t.Logf("%s failed to connect to postgres, retrying: %s", time.Now().Format(time.StampMilli), errString)
9797
}
9898

9999
// After the loop dbErr is the last connection error (if any).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy