Skip to content

Commit 725f753

Browse files
committed
flowinfra: enable TestDistSQLReadsFillGatewayID for secondary tenants
This required only a minor adjustment to the request filter. Release note: None
1 parent f1f1e7e commit 725f753

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pkg/sql/flowinfra/cluster_test.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ func TestLimitedBufferingDeadlock(t *testing.T) {
506506
// Test that DistSQL reads fill the BatchRequest.Header.GatewayNodeID field with
507507
// the ID of the gateway (as opposed to the ID of the node that created the
508508
// batch). Important to lease follow-the-workload transfers.
509+
//
510+
// Note that in single tenant and shared-process modes, GatewayNodeID field is
511+
// set on the kvclient side (i.e. in the SQL pod) whereas in external-process
512+
// mode it's set on the kvserver side (i.e. in the storage pod).
509513
func TestDistSQLReadsFillGatewayID(t *testing.T) {
510514
defer leaktest.AfterTest(t)()
511515
defer log.Scope(t).Close(t)
@@ -522,19 +526,18 @@ func TestDistSQLReadsFillGatewayID(t *testing.T) {
522526
base.TestClusterArgs{
523527
ReplicationMode: base.ReplicationManual,
524528
ServerArgs: base.TestServerArgs{
525-
UseDatabase: "test",
526-
DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(109392),
529+
UseDatabase: "test",
527530
Knobs: base.TestingKnobs{Store: &kvserver.StoreTestingKnobs{
528531
EvalKnobs: kvserverbase.BatchEvalTestingKnobs{
529532
TestingEvalFilter: func(filterArgs kvserverbase.FilterArgs) *kvpb.Error {
530533
scanReq, ok := filterArgs.Req.(*kvpb.ScanRequest)
531534
if !ok {
532535
return nil
533536
}
534-
if !strings.HasPrefix(
535-
scanReq.Key.String(),
536-
fmt.Sprintf("/Table/%d/1", tableID.Load()),
537-
) {
537+
pkPrefix := fmt.Sprintf("/Table/%d/1", tableID.Load())
538+
tenantPKPrefix := fmt.Sprintf("/Tenant/%d%s", serverutils.TestTenantID().InternalValue, pkPrefix)
539+
if !strings.HasPrefix(scanReq.Key.String(), pkPrefix) &&
540+
!strings.HasPrefix(scanReq.Key.String(), tenantPKPrefix) {
538541
return nil
539542
}
540543

@@ -552,6 +555,13 @@ func TestDistSQLReadsFillGatewayID(t *testing.T) {
552555
})
553556
defer tc.Stopper().Stop(context.Background())
554557

558+
if tc.DefaultTenantDeploymentMode().IsExternal() {
559+
tc.GrantTenantCapabilities(
560+
context.Background(), t, serverutils.TestTenantID(),
561+
map[tenantcapabilitiespb.ID]string{tenantcapabilitiespb.CanAdminRelocateRange: "true"},
562+
)
563+
}
564+
555565
db := tc.ServerConn(0)
556566
sqlutils.CreateTable(t, db, "t",
557567
"num INT PRIMARY KEY",

0 commit comments

Comments
 (0)