Skip to content

Commit

Permalink
sql: make TestScatterResponse compatible with secondary tenants
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
knz committed Aug 15, 2023
1 parent 371c1c5 commit 3b49761
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/sql/scatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils"
"github.com/cockroachdb/cockroach/pkg/sql/randgen"
"github.com/cockroachdb/cockroach/pkg/testutils"
Expand Down Expand Up @@ -115,16 +115,21 @@ func TestScatterResponse(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop(context.Background())
ts, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{})
defer ts.Stopper().Stop(context.Background())

s := ts.ApplicationLayer()

sql.SecondaryTenantSplitAtEnabled.Override(ctx, &s.ClusterSettings().SV, true)
sql.SecondaryTenantScatterEnabled.Override(ctx, &s.ClusterSettings().SV, true)

sqlutils.CreateTable(
t, sqlDB, "t",
"k INT PRIMARY KEY, v INT",
1000,
sqlutils.ToRowFn(sqlutils.RowIdxFn, sqlutils.RowModuloFn(10)),
)
tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "test", "t")
tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, s.Codec(), "test", "t")

r := sqlutils.MakeSQLRunner(sqlDB)

Expand Down Expand Up @@ -153,10 +158,10 @@ func TestScatterResponse(t *testing.T) {
}
var expectedKey roachpb.Key
if i == 0 {
expectedKey = keys.SystemSQLCodec.TablePrefix(uint32(tableDesc.GetID()))
expectedKey = s.Codec().TablePrefix(uint32(tableDesc.GetID()))
} else {
var err error
expectedKey, err = randgen.TestingMakePrimaryIndexKey(tableDesc, i*10)
expectedKey, err = randgen.TestingMakePrimaryIndexKeyForTenant(tableDesc, s.Codec(), i*10)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 3b49761

Please sign in to comment.