@@ -10,10 +10,8 @@ package auditloggingccl
1010
1111import (
1212 "context"
13- gosql "database/sql"
1413 "fmt"
1514 "math"
16- "net/url"
1715 "regexp"
1816 "strings"
1917 "testing"
@@ -121,13 +119,7 @@ func TestSingleRoleAuditLogging(t *testing.T) {
121119 rootRunner := sqlutils .MakeSQLRunner (sqlDB )
122120 defer s .Stopper ().Stop (context .Background ())
123121
124- testUserURL , cleanupFn := sqlutils .PGUrl (t ,
125- s .ApplicationLayer ().AdvSQLAddr (), t .Name (), url .User (username .TestUser ))
126- defer cleanupFn ()
127-
128- testUserDb , err := gosql .Open ("postgres" , testUserURL .String ())
129- require .NoError (t , err )
130- defer testUserDb .Close ()
122+ testUserDb := s .ApplicationLayer ().SQLConnForUser (t , username .TestUser , "" )
131123 testRunner := sqlutils .MakeSQLRunner (testUserDb )
132124
133125 // Dummy table/user used by tests.
@@ -250,16 +242,10 @@ func TestMultiRoleAuditLogging(t *testing.T) {
250242 defer cleanup ()
251243
252244 s , sqlDB , _ := serverutils .StartServer (t , base.TestServerArgs {})
253- rootRunner := sqlutils .MakeSQLRunner (sqlDB )
254245 defer s .Stopper ().Stop (context .Background ())
246+ rootRunner := sqlutils .MakeSQLRunner (sqlDB )
255247
256- testUserURL , cleanupFn := sqlutils .PGUrl (t ,
257- s .ApplicationLayer ().AdvSQLAddr (), t .Name (), url .User (username .TestUser ))
258- defer cleanupFn ()
259-
260- testUserDb , err := gosql .Open ("postgres" , testUserURL .String ())
261- require .NoError (t , err )
262- defer testUserDb .Close ()
248+ testUserDb := s .ApplicationLayer ().SQLConnForUser (t , username .TestUser , "" )
263249 testRunner := sqlutils .MakeSQLRunner (testUserDb )
264250
265251 // Dummy table/user used by tests.
@@ -374,13 +360,7 @@ func TestReducedAuditConfig(t *testing.T) {
374360 return nil
375361 })
376362
377- testUserURL , cleanupFn := sqlutils .PGUrl (t ,
378- s .ApplicationLayer ().AdvSQLAddr (), t .Name (), url .User (username .TestUser ))
379- defer cleanupFn ()
380-
381- testUserDb , err := gosql .Open ("postgres" , testUserURL .String ())
382- require .NoError (t , err )
383- defer testUserDb .Close ()
363+ testUserDb := s .ApplicationLayer ().SQLConnForUser (t , username .TestUser , "" )
384364 testRunner := sqlutils .MakeSQLRunner (testUserDb )
385365
386366 // Set a cluster configuration.
@@ -436,9 +416,7 @@ func TestReducedAuditConfig(t *testing.T) {
436416 }
437417
438418 // Open 2nd connection for the test user.
439- testUserDb2 , err := gosql .Open ("postgres" , testUserURL .String ())
440- require .NoError (t , err )
441- defer testUserDb2 .Close ()
419+ testUserDb2 := s .ApplicationLayer ().SQLConnForUser (t , username .TestUser , "" )
442420 testRunner2 := sqlutils .MakeSQLRunner (testUserDb2 )
443421
444422 // Run a query on the new connection. The new connection will cause the reduced audit config to be re-computed.
0 commit comments