Skip to content

chore: stop running postgres-only tests if DB is not set #18784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions coderd/database/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions coderd/database/dbtestutil/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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); {
Expand All @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this because it looks like we only retried 3 times, even though we're supposed to wait 10 seconds. Timestamp information will be helpful if we hit it again.

}

// After the loop dbErr is the last connection error (if any).
Expand Down
Loading