@@ -9,19 +9,16 @@ import (
99 "context"
1010 "fmt"
1111 "testing"
12- "time"
1312
1413 "github.com/cockroachdb/cockroach/pkg/base"
1514 "github.com/cockroachdb/cockroach/pkg/ccl/multiregionccl/multiregionccltestutils"
1615 _ "github.com/cockroachdb/cockroach/pkg/cloud/impl" // register cloud storage providers
1716 "github.com/cockroachdb/cockroach/pkg/jobs"
1817 "github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
19- "github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
2018 "github.com/cockroachdb/cockroach/pkg/roachpb"
2119 "github.com/cockroachdb/cockroach/pkg/sql"
2220 _ "github.com/cockroachdb/cockroach/pkg/sql/importer"
2321 "github.com/cockroachdb/cockroach/pkg/sql/sqlclustersettings"
24- "github.com/cockroachdb/cockroach/pkg/sql/sqlliveness/slbase"
2522 "github.com/cockroachdb/cockroach/pkg/testutils"
2623 "github.com/cockroachdb/cockroach/pkg/testutils/jobutils"
2724 "github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
@@ -30,80 +27,10 @@ import (
3027 "github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
3128 "github.com/cockroachdb/cockroach/pkg/util/leaktest"
3229 "github.com/cockroachdb/cockroach/pkg/util/log"
33- "github.com/cockroachdb/cockroach/pkg/util/timeutil"
3430 "github.com/cockroachdb/errors"
3531 "github.com/stretchr/testify/require"
3632)
3733
38- func TestBackupSharedProcessTenantNodeDown (t * testing.T ) {
39- defer leaktest .AfterTest (t )()
40- defer log .Scope (t ).Close (t )
41-
42- ctx := context .Background ()
43-
44- skip .UnderRace (t , "multi-node, multi-tenant test too slow under race" )
45- skip .UnderDeadlock (t , "too slow under deadlock detector" )
46- params := base.TestClusterArgs {
47- ServerArgs : base.TestServerArgs {
48- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
49- },
50- }
51- params .ServerArgs .Knobs .JobsTestingKnobs = jobs .NewTestingKnobsWithShortIntervals ()
52- tc , hostDB , _ , cleanup := backupRestoreTestSetupWithParams (t , multiNode , 0 , /* numAccounts */
53- InitManualReplication , params )
54- defer cleanup ()
55-
56- hostDB .Exec (t , "ALTER TENANT ALL SET CLUSTER SETTING server.sqlliveness.ttl='2s'" )
57- hostDB .Exec (t , "ALTER TENANT ALL SET CLUSTER SETTING server.sqlliveness.heartbeat='250ms'" )
58-
59- testTenantID := roachpb .MustMakeTenantID (11 )
60- tenantApp , tenantDB , err := tc .Server (0 ).TenantController ().StartSharedProcessTenant (ctx ,
61- base.TestSharedProcessTenantArgs {
62- TenantID : testTenantID ,
63- TenantName : "test" ,
64- })
65- require .NoError (t , err )
66-
67- hostDB .Exec (t , "ALTER TENANT test GRANT ALL CAPABILITIES" )
68- err = tc .Server (0 ).TenantController ().WaitForTenantCapabilities (ctx , testTenantID , map [tenantcapabilities.ID ]string {
69- tenantcapabilities .CanUseNodelocalStorage : "true" ,
70- }, "" )
71- require .NoError (t , err )
72-
73- tenantSQL := sqlutils .MakeSQLRunner (tenantDB )
74- tenantSQL .Exec (t , "CREATE TABLE foo AS SELECT generate_series(1, 4000)" )
75- tenantSQL .Exec (t , "ALTER TABLE foo SPLIT AT VALUES (500), (1000), (1500), (2000), (2500), (3000)" )
76- tenantSQL .Exec (t , "ALTER TABLE foo SCATTER" )
77-
78- t .Log ("waiting for SQL instances" )
79- waitStart := timeutil .Now ()
80- for i := 1 ; i < multiNode ; i ++ {
81- testutils .SucceedsSoon (t , func () error {
82- t .Logf ("waiting for server %d" , i )
83- db , err := tc .Server (i ).SystemLayer ().SQLConnE (serverutils .DBName ("cluster:test/defaultdb" ))
84- if err != nil {
85- return err
86- }
87- return db .Ping ()
88- })
89- }
90- t .Logf ("all SQL instances (took %s)" , timeutil .Since (waitStart ))
91-
92- // Shut down a node.
93- t .Log ("shutting down server 2 (n3)" )
94- tc .StopServer (2 )
95-
96- // We use succeeds soon here since it still takes some time
97- // for instance-based planning to recognize the downed node.
98- sv := & tenantApp .ClusterSettings ().SV
99- padding := 10 * time .Second
100- timeout := slbase .DefaultTTL .Get (sv ) + slbase .DefaultHeartBeat .Get (sv ) + padding
101- testutils .SucceedsWithin (t , func () error {
102- _ , err := tenantDB .Exec ("BACKUP INTO 'nodelocal://1/worker-failure'" )
103- return err
104- }, timeout )
105- }
106-
10734func TestBackupTenantImportingTable (t * testing.T ) {
10835 defer leaktest .AfterTest (t )()
10936 defer log .Scope (t ).Close (t )
0 commit comments