Skip to content

Commit

Permalink
Fix CI test workflow errors in RecoverySigner unit tests (#5398)
Browse files Browse the repository at this point in the history
* Fix race condition in unit tests

* addressing review comment
  • Loading branch information
urvisavla authored Jul 22, 2024
1 parent a3fae02 commit 2674e20
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion support/db/dbtest/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func checkReadOnly(t testing.TB, DSN string) {
require.NoError(t, err)
defer conn.Close()

tx, err := conn.BeginTx(context.Background(), &sql.TxOptions{Isolation: sql.LevelSerializable})
tx, err := conn.BeginTx(context.Background(), &sql.TxOptions{})
require.NoError(t, err)
defer tx.Rollback()

Expand All @@ -127,6 +127,12 @@ func checkReadOnly(t testing.TB, DSN string) {

if !rows.Next() {
_, err = tx.Exec("CREATE ROLE user_ro WITH LOGIN PASSWORD 'user_ro';")
if err != nil {
// Handle race condition by ignoring the error if it's a duplicate key violation
if pqErr, ok := err.(*pq.Error); ok && pqErr.Code == "23505" {
return
}
}
require.NoError(t, err)
}

Expand Down

0 comments on commit 2674e20

Please sign in to comment.