@@ -56,7 +56,6 @@ import (
5656 "github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
5757 "github.com/cockroachdb/cockroach/pkg/testutils/jobutils"
5858 "github.com/cockroachdb/cockroach/pkg/testutils/kvclientutils"
59- "github.com/cockroachdb/cockroach/pkg/testutils/pgurlutils"
6059 "github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
6160 "github.com/cockroachdb/cockroach/pkg/testutils/skip"
6261 "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
@@ -1296,19 +1295,14 @@ func TestFailedImport(t *testing.T) {
12961295 ctx := context .Background ()
12971296 baseDir := datapathutils .TestDataPath (t , "csv" )
12981297 tc := serverutils .StartCluster (t , nodes , base.TestClusterArgs {ServerArgs : base.TestServerArgs {
1299- // Test fails within a test tenant. This may be because we're trying
1300- // to access files in nodelocal://1, which is off node. More
1301- // investigation is required. Tracked with #76378.
1302- DefaultTestTenant : base .TODOTestTenantDisabled ,
1303- SQLMemoryPoolSize : 256 << 20 ,
1304- ExternalIODir : baseDir ,
1298+ ExternalIODir : baseDir ,
13051299 }})
13061300 defer tc .Stopper ().Stop (ctx )
13071301 conn := tc .ServerConn (0 )
13081302
13091303 var forceFailure bool
13101304 for i := 0 ; i < tc .NumServers (); i ++ {
1311- tc .Server (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
1305+ tc .ApplicationLayer (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
13121306 jobspb .TypeImport ,
13131307 func (raw jobs.Resumer ) jobs.Resumer {
13141308 r := raw .(* importResumer )
@@ -1371,15 +1365,14 @@ func TestImportIntoCSVCancel(t *testing.T) {
13711365 },
13721366 JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
13731367 },
1374- DefaultTestTenant : base .TODOTestTenantDisabled ,
1375- ExternalIODir : baseDir ,
1368+ ExternalIODir : baseDir ,
13761369 }})
13771370 defer tc .Stopper ().Stop (ctx )
13781371 conn := tc .ServerConn (0 )
13791372
13801373 setupDoneCh := make (chan struct {})
13811374 for i := 0 ; i < tc .NumServers (); i ++ {
1382- tc .Server (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
1375+ tc .ApplicationLayer (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
13831376 jobspb .TypeImport ,
13841377 func (raw jobs.Resumer ) jobs.Resumer {
13851378 r := raw .(* importResumer )
@@ -1422,17 +1415,13 @@ func TestImportCSVStmt(t *testing.T) {
14221415 ctx := context .Background ()
14231416 baseDir := datapathutils .TestDataPath (t , "csv" )
14241417 tc := serverutils .StartCluster (t , nodes , base.TestClusterArgs {ServerArgs : base.TestServerArgs {
1425- // Test fails when run within a test tenant. More
1426- // investigation is required. Tracked with #76378.
1427- DefaultTestTenant : base .TODOTestTenantDisabled ,
1428- SQLMemoryPoolSize : 256 << 20 ,
1429- ExternalIODir : baseDir ,
1418+ ExternalIODir : baseDir ,
14301419 }})
14311420 defer tc .Stopper ().Stop (ctx )
14321421 conn := tc .ServerConn (0 )
14331422
14341423 for i := 0 ; i < tc .NumServers (); i ++ {
1435- tc .Server (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
1424+ tc .ApplicationLayer (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
14361425 jobspb .TypeImport ,
14371426 func (raw jobs.Resumer ) jobs.Resumer {
14381427 r := raw .(* importResumer )
@@ -1752,10 +1741,7 @@ func TestImportCSVStmt(t *testing.T) {
17521741 t .Run ("RBAC-SuperUser" , func (t * testing.T ) {
17531742 sqlDB .Exec (t , `CREATE USER testuser` )
17541743 sqlDB .Exec (t , `GRANT admin TO testuser` )
1755- pgURL , cleanupFunc := pgurlutils .PGUrl (
1756- t , tc .ApplicationLayer (0 ).AdvSQLAddr (), "TestImportPrivileges-testuser" ,
1757- url .User ("testuser" ),
1758- )
1744+ pgURL , cleanupFunc := tc .ApplicationLayer (0 ).PGUrl (t , serverutils .User (username .TestUser ))
17591745 defer cleanupFunc ()
17601746 testuser , err := gosql .Open ("postgres" , pgURL .String ())
17611747 if err != nil {
@@ -1868,7 +1854,7 @@ func TestImportCSVStmt(t *testing.T) {
18681854 // Test userfile import CSV.
18691855 t .Run ("userfile-simple" , func (t * testing.T ) {
18701856 userfileURI := "userfile://defaultdb.public.root/test.csv"
1871- userfileStorage , err := tc .Server (0 ).ExecutorConfig ().(sql.ExecutorConfig ).DistSQLSrv .
1857+ userfileStorage , err := tc .ApplicationLayer (0 ).ExecutorConfig ().(sql.ExecutorConfig ).DistSQLSrv .
18721858 ExternalStorageFromURI (ctx , userfileURI , username .RootUserName ())
18731859 require .NoError (t , err )
18741860
@@ -1884,7 +1870,7 @@ func TestImportCSVStmt(t *testing.T) {
18841870
18851871 t .Run ("userfile-relative-file-path" , func (t * testing.T ) {
18861872 userfileURI := "userfile:///import-test/employees.csv"
1887- userfileStorage , err := tc .Server (0 ).ExecutorConfig ().(sql.ExecutorConfig ).DistSQLSrv .
1873+ userfileStorage , err := tc .ApplicationLayer (0 ).ExecutorConfig ().(sql.ExecutorConfig ).DistSQLSrv .
18881874 ExternalStorageFromURI (ctx , userfileURI , username .RootUserName ())
18891875 require .NoError (t , err )
18901876
@@ -1980,21 +1966,13 @@ func TestImportObjectLevelRBAC(t *testing.T) {
19801966 const nodes = 3
19811967
19821968 ctx := context .Background ()
1983- tc := serverutils .StartCluster (t , nodes , base.TestClusterArgs {ServerArgs : base.TestServerArgs {
1984- // Test fails when run within a test tenant. More investigation
1985- // is required. Tracked with #76378.
1986- DefaultTestTenant : base .TODOTestTenantDisabled ,
1987- SQLMemoryPoolSize : 256 << 20 ,
1988- }})
1969+ tc := serverutils .StartCluster (t , nodes , base.TestClusterArgs {})
19891970 defer tc .Stopper ().Stop (ctx )
19901971 conn := tc .ServerConn (0 )
19911972 rootDB := sqlutils .MakeSQLRunner (conn )
19921973
19931974 rootDB .Exec (t , `CREATE USER testuser` )
1994- pgURL , cleanupFunc := pgurlutils .PGUrl (
1995- t , tc .ApplicationLayer (0 ).AdvSQLAddr (), "TestImportPrivileges-testuser" ,
1996- url .User ("testuser" ),
1997- )
1975+ pgURL , cleanupFunc := tc .ApplicationLayer (0 ).PGUrl (t , serverutils .User (username .TestUser ))
19981976 defer cleanupFunc ()
19991977
20001978 startTestUser := func (t * testing.T ) * gosql.DB {
@@ -2009,7 +1987,7 @@ func TestImportObjectLevelRBAC(t *testing.T) {
20091987
20101988 writeToUserfile := func (t * testing.T , filename , data string ) {
20111989 // Write to userfile storage now that testuser has CREATE privileges.
2012- ief := tc .Server (0 ).InternalDB ().(isql.DB )
1990+ ief := tc .ApplicationLayer (0 ).InternalDB ().(isql.DB )
20131991 fileTableSystem1 , err := cloud .ExternalStorageFromURI (
20141992 ctx , dest , base.ExternalIODirConfig {},
20151993 cluster .NoSettings , blobs .TestEmptyBlobClientFactory ,
@@ -2139,10 +2117,8 @@ func TestImportIntoCSV(t *testing.T) {
21392117 Knobs : base.TestingKnobs {
21402118 JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
21412119 },
2142- // Test fails when run within a test tenant. More investigation
2143- // is required. Tracked with #76378.
2144- DefaultTestTenant : base .TODOTestTenantDisabled ,
2145- ExternalIODir : baseDir }})
2120+ ExternalIODir : baseDir ,
2121+ }})
21462122 defer tc .Stopper ().Stop (ctx )
21472123 conn := tc .ServerConn (0 )
21482124
@@ -2154,7 +2130,7 @@ func TestImportIntoCSV(t *testing.T) {
21542130 var delayImportFinish chan struct {}
21552131
21562132 for i := 0 ; i < tc .NumServers (); i ++ {
2157- tc .Server (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
2133+ tc .ApplicationLayer (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
21582134 jobspb .TypeImport ,
21592135 func (raw jobs.Resumer ) jobs.Resumer {
21602136 r := raw .(* importResumer )
@@ -2186,6 +2162,13 @@ func TestImportIntoCSV(t *testing.T) {
21862162 sqlDB := sqlutils .MakeSQLRunner (conn )
21872163
21882164 sqlDB .Exec (t , `SET CLUSTER SETTING kv.bulk_ingest.batch_size = '10KB'` )
2165+ // 'import-into-no-glob-wildcard' hits an error that the file doesn't exist
2166+ // in external storage. When run with test tenants, that error also happens
2167+ // to be annotated with 'rpc error' marker, which we treat as a retryable
2168+ // one (see joberror.IsPermanentBulkJobError which calls
2169+ // sqlerrors.IsDistSQLRetryableError). In order to speed up the test, we'll
2170+ // reduce the retry duration from 2 minutes to 2 seconds.
2171+ sqlDB .Exec (t , `SET CLUSTER SETTING bulkio.import.retry_duration = '2s'` )
21892172
21902173 testFiles := makeCSVData (t , numFiles , rowsPerFile , nodes , rowsPerRaceFile )
21912174 if util .RaceEnabled {
@@ -2902,7 +2885,7 @@ func TestImportIntoCSV(t *testing.T) {
29022885 )
29032886
29042887 sqlDB .ExpectErr (
2905- t , `ingested key collides with an existing one: /Table/\d+/1/0/0` ,
2888+ t , `ingested key collides with an existing one: (\/Tenant\/10)? /Table/\d+/1/0/0` ,
29062889 fmt .Sprintf (`IMPORT INTO t (a, b) CSV DATA (%s)` , testFiles .files [0 ]),
29072890 )
29082891 })
@@ -2944,7 +2927,7 @@ func TestImportIntoCSV(t *testing.T) {
29442927
29452928 preCollisionData := sqlDB .QueryStr (t , `SELECT * FROM t` )
29462929 sqlDB .ExpectErr (
2947- t , `ingested key collides with an existing one: /Table/\d+/1/0/0` ,
2930+ t , `ingested key collides with an existing one: (\/Tenant\/10)? /Table/\d+/1/0/0` ,
29482931 fmt .Sprintf (`IMPORT INTO t (a, b) CSV DATA (%s)` , testFiles .fileWithShadowKeys [0 ]),
29492932 )
29502933 sqlDB .CheckQueryResults (t , `SELECT * FROM t` , preCollisionData )
@@ -2980,7 +2963,7 @@ func TestImportIntoCSV(t *testing.T) {
29802963 // Test userfile IMPORT INTO CSV.
29812964 t .Run ("import-into-userfile-simple" , func (t * testing.T ) {
29822965 userfileURI := "userfile://defaultdb.public.root/test.csv"
2983- userfileStorage , err := tc .Server (0 ).ExecutorConfig ().(sql.ExecutorConfig ).DistSQLSrv .
2966+ userfileStorage , err := tc .ApplicationLayer (0 ).ExecutorConfig ().(sql.ExecutorConfig ).DistSQLSrv .
29842967 ExternalStorageFromURI (ctx , userfileURI , username .RootUserName ())
29852968 require .NoError (t , err )
29862969
@@ -3840,11 +3823,8 @@ func TestImportDefaultWithResume(t *testing.T) {
38403823
38413824 ctx := context .Background ()
38423825 filterFunc , verifyFunc := kvclientutils .PrefixTransactionRetryFilter (t , importProgressDebugName , 1 )
3843- s , db , _ := serverutils .StartServer (t ,
3826+ srv , db , _ := serverutils .StartServer (t ,
38443827 base.TestServerArgs {
3845- // Test hangs when run within a test tenant. More investigation
3846- // is required. Tracked with #76378.
3847- DefaultTestTenant : base .TODOTestTenantDisabled ,
38483828 Knobs : base.TestingKnobs {
38493829 JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
38503830 DistSQL : & execinfra.TestingKnobs {
@@ -3856,8 +3836,9 @@ func TestImportDefaultWithResume(t *testing.T) {
38563836 },
38573837 SQLMemoryPoolSize : 1 << 30 , // 1 GiB
38583838 })
3839+ defer srv .Stopper ().Stop (ctx )
3840+ s := srv .ApplicationLayer ()
38593841 registry := s .JobRegistry ().(* jobs.Registry )
3860- defer s .Stopper ().Stop (ctx )
38613842
38623843 sqlDB := sqlutils .MakeSQLRunner (db )
38633844 testCases := []struct {
@@ -4369,13 +4350,7 @@ func TestImportControlJobRBAC(t *testing.T) {
43694350 defer jobs .ResetConstructors ()()
43704351
43714352 ctx := context .Background ()
4372- tc := serverutils .StartCluster (t , 1 , base.TestClusterArgs {
4373- ServerArgs : base.TestServerArgs {
4374- // Test fails when run within a test tenant. More investigation
4375- // is required. Tracked with #76378.
4376- DefaultTestTenant : base .TODOTestTenantDisabled ,
4377- },
4378- })
4353+ tc := serverutils .StartCluster (t , 1 , base.TestClusterArgs {})
43794354 defer tc .Stopper ().Stop (ctx )
43804355 rootDB := sqlutils .MakeSQLRunner (tc .ServerConn (0 ))
43814356
@@ -4384,10 +4359,7 @@ func TestImportControlJobRBAC(t *testing.T) {
43844359 // Create non-root user.
43854360 rootDB .Exec (t , `CREATE USER testuser` )
43864361 rootDB .Exec (t , `ALTER ROLE testuser CONTROLJOB` )
4387- pgURL , cleanupFunc := pgurlutils .PGUrl (
4388- t , tc .ApplicationLayer (0 ).AdvSQLAddr (), "TestImportPrivileges-testuser" ,
4389- url .User ("testuser" ),
4390- )
4362+ pgURL , cleanupFunc := tc .ApplicationLayer (0 ).PGUrl (t , serverutils .User (username .TestUser ))
43914363 defer cleanupFunc ()
43924364 testuser , err := gosql .Open ("postgres" , pgURL .String ())
43934365 if err != nil {
@@ -4413,7 +4385,7 @@ func TestImportControlJobRBAC(t *testing.T) {
44134385
44144386 startLeasedJob := func (t * testing.T , record jobs.Record ) * jobs.StartableJob {
44154387 job , err := jobs .TestingCreateAndStartJob (
4416- ctx , registry , tc .Server (0 ).InternalDB ().(isql.DB ), record ,
4388+ ctx , registry , tc .ApplicationLayer (0 ).InternalDB ().(isql.DB ), record ,
44174389 )
44184390 require .NoError (t , err )
44194391 return job
@@ -4795,9 +4767,8 @@ func TestCreateStatsAfterImport(t *testing.T) {
47954767 st := cluster .MakeClusterSettings ()
47964768 stats .AutomaticStatisticsOnSystemTables .Override (context .Background (), & st .SV , false )
47974769 args := base.TestServerArgs {
4798- Settings : st ,
4799- DefaultTestTenant : base .TODOTestTenantDisabled ,
4800- ExternalIODir : baseDir ,
4770+ Settings : st ,
4771+ ExternalIODir : baseDir ,
48014772 }
48024773 tc := serverutils .StartCluster (t , nodes , base.TestClusterArgs {ServerArgs : args })
48034774 defer tc .Stopper ().Stop (ctx )
@@ -5155,7 +5126,7 @@ func waitForJobResult(
51555126 t * testing.T , tc serverutils.TestClusterInterface , id jobspb.JobID , expected jobs.State ,
51565127) {
51575128 // Force newly created job to be adopted and verify its result.
5158- tc .Server (0 ).JobRegistry ().(* jobs.Registry ).TestingNudgeAdoptionQueue ()
5129+ tc .ApplicationLayer (0 ).JobRegistry ().(* jobs.Registry ).TestingNudgeAdoptionQueue ()
51595130 testutils .SucceedsSoon (t , func () error {
51605131 var unused int64
51615132 return tc .ServerConn (0 ).QueryRow (
@@ -5276,17 +5247,14 @@ func TestImportJobEventLogging(t *testing.T) {
52765247 ctx := context .Background ()
52775248 baseDir := datapathutils .TestDataPath (t , "avro" )
52785249 args := base.TestServerArgs {ExternalIODir : baseDir }
5279- // Test fails within a test tenant. More investigation is required.
5280- // Tracked with #76378.
5281- args .DefaultTestTenant = base .TODOTestTenantDisabled
52825250 args .Knobs = base.TestingKnobs {JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals ()}
52835251 params := base.TestClusterArgs {ServerArgs : args }
52845252 tc := serverutils .StartCluster (t , nodes , params )
52855253 defer tc .Stopper ().Stop (ctx )
52865254
52875255 var forceFailure bool
52885256 for i := 0 ; i < tc .NumServers (); i ++ {
5289- tc .Server (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
5257+ tc .ApplicationLayer (i ).JobRegistry ().(* jobs.Registry ).TestingWrapResumerConstructor (
52905258 jobspb .TypeImport ,
52915259 func (raw jobs.Resumer ) jobs.Resumer {
52925260 r := raw .(* importResumer )
0 commit comments