Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/backup/schedule_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestBackupSucceededUpdatesMetrics(t *testing.T) {

t.Run("updates RPO tenant metric", func(t *testing.T) {
schedule := createSchedule(t, true)
tenantIDs := mustMakeTenantIDs(t, 1, 2)
tenantIDs := mustMakeTenantIDs(t, 1, 3)
endTime := hlc.Timestamp{WallTime: hlc.UnixNano()}
details := jobspb.BackupDetails{
EndTime: endTime,
Expand All @@ -52,7 +52,7 @@ func TestBackupSucceededUpdatesMetrics(t *testing.T) {
err := executor.backupSucceeded(ctx, nil, schedule, details, nil)
require.NoError(t, err)

expectedTenantIDs := []string{"system", "2"}
expectedTenantIDs := []string{"system", "3"}
verifyRPOTenantMetricLabels(t, executor.metrics.RpoTenantMetric, expectedTenantIDs)
verifyRPOTenantMetricGaugeValue(t, executor.metrics.RpoTenantMetric, details.EndTime)
})
Expand Down
14 changes: 7 additions & 7 deletions pkg/backup/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,23 +541,23 @@ func TestShowBackupTenantView(t *testing.T) {

_ = securitytest.EmbeddedTenantIDs()

_, conn2 := serverutils.StartTenant(t, srv, base.TestTenantArgs{TenantID: roachpb.MustMakeTenantID(2)})
defer conn2.Close()
_, conn3 := serverutils.StartTenant(t, srv, base.TestTenantArgs{TenantID: roachpb.MustMakeTenantID(3)})
defer conn3.Close()

tenant2 := sqlutils.MakeSQLRunner(conn2)
tenant3 := sqlutils.MakeSQLRunner(conn3)
dataQuery := `CREATE DATABASE foo; CREATE TABLE foo.bar(i int primary key); INSERT INTO foo.bar VALUES (110), (210)`
backupQuery := `BACKUP TABLE foo.bar INTO $1`
showBackupQuery := "SELECT object_name, object_type, rows FROM [SHOW BACKUP FROM LATEST IN $1]"
tenant2.Exec(t, dataQuery)
tenant3.Exec(t, dataQuery)

// First, assert that SHOW BACKUPS on a tenant backup returns the same results if
// either the system tenant or tenant2 calls it.
// either the system tenant or tenant3 calls it.
tenantAddr, httpServerCleanup := makeInsecureHTTPServer(t)
defer httpServerCleanup()

tenant2.Exec(t, backupQuery, tenantAddr)
tenant3.Exec(t, backupQuery, tenantAddr)
systemTenantShowRes := systemDB.QueryStr(t, showBackupQuery, tenantAddr)
require.Equal(t, systemTenantShowRes, tenant2.QueryStr(t, showBackupQuery, tenantAddr))
require.Equal(t, systemTenantShowRes, tenant3.QueryStr(t, showBackupQuery, tenantAddr))

// If the system tenant created the same data, and conducted the same backup,
// the row counts should look the same.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ func TestSQLWatcherReactsToUpdates(t *testing.T) {
},
{
stmts: []string{
"SELECT crdb_internal.create_tenant(2);",
"BACKUP TENANT 2 INTO 'nodelocal://1/foo'",
"SELECT crdb_internal.create_tenant(3);",
"BACKUP TENANT 3 INTO 'nodelocal://1/foo'",
},
expectedPTSUpdates: []spanconfig.ProtectedTimestampUpdate{{ClusterTarget: false,
TenantTarget: roachpb.MustMakeTenantID(2)}},
TenantTarget: roachpb.MustMakeTenantID(3)}},
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/crosscluster/producer/stream_event_batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestBatchSpanConfigs(t *testing.T) {
t.Logf("Replication helper seed %d", seed)

seb := makeStreamEventBatcher(true)
codec := keys.MakeSQLCodec(roachpb.MustMakeTenantID(2))
codec := keys.MakeSQLCodec(roachpb.MustMakeTenantID(3))
bufferedEvents := make([]streampb.StreamedSpanConfigEntry, 0)

tableSpan := func(tableID uint32) roachpb.Span {
Expand Down
2 changes: 1 addition & 1 deletion pkg/crosscluster/replicationtestutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var DefaultTenantStreamingClustersArgs = TenantStreamingClustersArgs{
SrcNumNodes: 1,
SrcClusterSettings: DefaultClusterSettings,
DestTenantName: roachpb.TenantName("destination"),
DestTenantID: roachpb.MustMakeTenantID(2),
DestTenantID: roachpb.MustMakeTenantID(3),
DestNumNodes: 1,
DestClusterSettings: DefaultClusterSettings,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/keys/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func TestEnsureSafeSplitKey(t *testing.T) {
func TestDecodeTenantPrefix(t *testing.T) {
tIDs := []roachpb.TenantID{
roachpb.SystemTenantID,
roachpb.MustMakeTenantID(2),
roachpb.MustMakeTenantID(3),
roachpb.MustMakeTenantID(999),
roachpb.MustMakeTenantID(math.MaxUint64),
}
Expand Down
36 changes: 18 additions & 18 deletions pkg/kv/kvclient/kvtenant/tenant_range_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@ func TestRangeLookupPrefetchFiltering(t *testing.T) {
})
defer tc.Stopper().Stop(ctx)

ten2ID := roachpb.MustMakeTenantID(2)
tenant2, err := tc.Server(0).TenantController().StartTenant(ctx, base.TestTenantArgs{
TenantID: ten2ID,
ten3ID := roachpb.MustMakeTenantID(3)
tenant3, err := tc.Server(0).TenantController().StartTenant(ctx, base.TestTenantArgs{
TenantID: ten3ID,
})
require.NoError(t, err)

// Split some ranges within tenant2 that we'll want to see in prefetch.
ten2Codec := keys.MakeSQLCodec(ten2ID)
ten2Split1 := append(ten2Codec.TenantPrefix(), 'a')
ten2Split2 := append(ten2Codec.TenantPrefix(), 'b')
// Split some ranges within tenant3 that we'll want to see in prefetch.
ten3Codec := keys.MakeSQLCodec(ten3ID)
ten3Split1 := append(ten3Codec.TenantPrefix(), 'a')
ten3Split2 := append(ten3Codec.TenantPrefix(), 'b')
{
tc.SplitRangeOrFatal(t, ten2Split1)
tc.SplitRangeOrFatal(t, ten2Split2)
tc.SplitRangeOrFatal(t, ten3Split1)
tc.SplitRangeOrFatal(t, ten3Split2)
}

// Split some ranges for the tenant which comes after tenant2.
// Split some ranges for the tenant which comes after tenant3.
{
ten3Codec := keys.MakeSQLCodec(roachpb.MustMakeTenantID(3))
tc.SplitRangeOrFatal(t, ten3Codec.TenantPrefix())
tc.SplitRangeOrFatal(t, append(ten3Codec.TenantPrefix(), 'b'))
tc.SplitRangeOrFatal(t, append(ten3Codec.TenantPrefix(), 'c'))
ten4Codec := keys.MakeSQLCodec(roachpb.MustMakeTenantID(4))
tc.SplitRangeOrFatal(t, ten4Codec.TenantPrefix())
tc.SplitRangeOrFatal(t, append(ten4Codec.TenantPrefix(), 'b'))
tc.SplitRangeOrFatal(t, append(ten4Codec.TenantPrefix(), 'c'))
}

// Do the fetch and make sure we prefetch all the ranges we should see,
// and none of the ranges we should not.
db := tenant2.DistSenderI().(*kvcoord.DistSender).RangeDescriptorCache().DB()
prefixRKey := keys.MustAddr(ten2Codec.TenantPrefix())
db := tenant3.DistSenderI().(*kvcoord.DistSender).RangeDescriptorCache().DB()
prefixRKey := keys.MustAddr(ten3Codec.TenantPrefix())
res, prefetch, err := db.RangeLookup(
ctx, prefixRKey,
rangecache.ReadFromLeaseholder, false, /* useReverseScan */
Expand All @@ -72,6 +72,6 @@ func TestRangeLookupPrefetchFiltering(t *testing.T) {
require.Len(t, res, 1)
require.Equal(t, prefixRKey, res[0].StartKey)
require.Len(t, prefetch, 2)
require.Equal(t, keys.MustAddr(ten2Split1), prefetch[0].StartKey)
require.Equal(t, keys.MustAddr(ten2Split2), prefetch[1].StartKey)
require.Equal(t, keys.MustAddr(ten3Split1), prefetch[0].StartKey)
require.Equal(t, keys.MustAddr(ten3Split2), prefetch[1].StartKey)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func setup(
},
})

ten2ID := roachpb.MustMakeTenantID(2)
tenant2, err := tc.Server(0).TenantController().StartTenant(ctx, base.TestTenantArgs{
TenantID: ten2ID,
ten3ID := roachpb.MustMakeTenantID(3)
tenant3, err := tc.Server(0).TenantController().StartTenant(ctx, base.TestTenantArgs{
TenantID: ten3ID,
})
require.NoError(t, err)
return tc, tenant2, tenant2.RangeDescIteratorFactory().(rangedesc.IteratorFactory)
return tc, tenant3, tenant3.RangeDescIteratorFactory().(rangedesc.IteratorFactory)
}

// TestScanRangeDescriptors is an integration test to ensure that tenants can
Expand Down
20 changes: 10 additions & 10 deletions pkg/kv/kvserver/client_replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5117,8 +5117,8 @@ func TestTenantID(t *testing.T) {
})
defer tc.Stopper().Stop(ctx)

tenant2 := roachpb.MustMakeTenantID(2)
tenant2Prefix := keys.MakeTenantPrefix(tenant2)
tenant3 := roachpb.MustMakeTenantID(3)
tenant3Prefix := keys.MakeTenantPrefix(tenant3)
t.Run("(1) initial set", func(t *testing.T) {
// Ensure that a normal range has the system tenant.
{
Expand All @@ -5128,16 +5128,16 @@ func TestTenantID(t *testing.T) {
require.Equal(t, roachpb.SystemTenantID, tenantId, "%v", repl)
}
// Ensure that a range with a tenant prefix has the proper tenant ID.
tc.SplitRangeOrFatal(t, tenant2Prefix)
tc.SplitRangeOrFatal(t, tenant3Prefix)
{
_, repl := getFirstStoreReplica(t, tc.Server(0), tenant2Prefix)
_, repl := getFirstStoreReplica(t, tc.Server(0), tenant3Prefix)
tenantId, valid := repl.TenantID()
require.True(t, valid)
require.Equal(t, tenant2, tenantId, "%v", repl)
require.Equal(t, tenant3, tenantId, "%v", repl)
}
})
t.Run("(2) not set before snapshot", func(t *testing.T) {
_, repl := getFirstStoreReplica(t, tc.Server(0), tenant2Prefix)
_, repl := getFirstStoreReplica(t, tc.Server(0), tenant3Prefix)
sawSnapshot := make(chan struct{}, 1)
blockSnapshot := make(chan struct{})
tc.AddAndStartServer(t, base.TestServerArgs{
Expand Down Expand Up @@ -5166,7 +5166,7 @@ func TestTenantID(t *testing.T) {
// networking handshake timeouts.
addReplicaErr := make(chan error)
addReplica := func() {
_, err := tc.AddVoters(tenant2Prefix, tc.Target(1))
_, err := tc.AddVoters(tenant3Prefix, tc.Target(1))
addReplicaErr <- err
}
go addReplica()
Expand All @@ -5190,14 +5190,14 @@ func TestTenantID(t *testing.T) {
require.NoError(t, <-addReplicaErr)
tenantID, valid := uninitializedRepl.TenantID() // now initialized
require.True(t, valid)
require.Equal(t, tenant2, tenantID)
require.Equal(t, tenant3, tenantID)
})
t.Run("(3) upon restart", func(t *testing.T) {
tc.StopServer(0)
tc.AddAndStartServer(t, stickySpecTestServerArgs)
_, repl := getFirstStoreReplica(t, tc.Server(2), tenant2Prefix)
_, repl := getFirstStoreReplica(t, tc.Server(2), tenant3Prefix)
tenantID, _ := repl.TenantID() // now initialized
require.Equal(t, tenant2, tenantID, "%v", repl)
require.Equal(t, tenant3, tenantID, "%v", repl)
})

}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,7 @@ func TestStore_HottestReplicasByTenant(t *testing.T) {
}

td := []testData{{1, 2}, {1, 3}, {1, 4}, {1, 5},
{2, 1}, {2, 2}, {2, 3}, {2, 4}}
{3, 1}, {3, 2}, {3, 3}, {3, 4}}

acc := NewTenantReplicaAccumulator(aload.Queries)

Expand All @@ -2689,7 +2689,7 @@ func TestStore_HottestReplicasByTenant(t *testing.T) {
for i := 0; i < iterationsNum; i++ {
go func() {
require.NotNil(t, store.HottestReplicasByTenant(roachpb.MustMakeTenantID(1)))
require.NotNil(t, store.HottestReplicasByTenant(roachpb.MustMakeTenantID(2)))
require.NotNil(t, store.HottestReplicasByTenant(roachpb.MustMakeTenantID(3)))
wg.Done()
}()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/tenantrate/limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCloser(t *testing.T) {
factory := tenantrate.NewLimiterFactory(&st.SV, &tenantrate.TestingKnobs{
QuotaPoolOptions: []quotapool.Option{quotapool.WithTimeSource(timeSource)},
}, fakeAuthorizer{})
tenant := roachpb.MustMakeTenantID(2)
tenant := roachpb.MustMakeTenantID(3)
closer := make(chan struct{})
limiter := factory.GetTenant(ctx, tenant, closer)
// First Wait call will not block.
Expand Down
2 changes: 1 addition & 1 deletion pkg/roachpb/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var TenantOne = MustMakeTenantID(1)

// MinTenantID is the minimum ID of a (non-system) tenant in a multi-tenant
// cluster.
var MinTenantID = MustMakeTenantID(2)
var MinTenantID = MustMakeTenantID(3)

// MaxTenantID is the maximum ID of a (non-system) tenant in a multi-tenant
// cluster.
Expand Down
2 changes: 1 addition & 1 deletion pkg/roachpb/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestTenantIDString(t *testing.T) {
for tID, expStr := range map[TenantID]string{
{}: "invalid",
SystemTenantID: "system",
MustMakeTenantID(2): "2",
MustMakeTenantID(3): "3",
MustMakeTenantID(999): "999",
MustMakeTenantID(math.MaxUint64): "18446744073709551615",
} {
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpc/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func TestTenantAuthRequest(t *testing.T) {
}
}

tenantTwo := roachpb.MustMakeTenantID(2)
tenantThree := roachpb.MustMakeTenantID(3)
makeTimeseriesQueryReq := func(tenantID *roachpb.TenantID) *tspb.TimeSeriesQueryRequest {
req := &tspb.TimeSeriesQueryRequest{
Queries: []tspb.Query{{}},
Expand Down Expand Up @@ -998,7 +998,7 @@ func TestTenantAuthRequest(t *testing.T) {
expErr: noError,
},
{
req: makeTimeseriesQueryReq(&tenantTwo),
req: makeTimeseriesQueryReq(&tenantThree),
expErr: `tsdb query with invalid tenant not permitted`,
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func TestTenantVersionCheck(t *testing.T) {
})
// Ensure that the same ping succeeds with a secondary tenant context.
t.Run("old, secondary tenant", func(t *testing.T) {
tenantCtx := roachpb.ContextWithClientTenant(context.Background(), roachpb.MustMakeTenantID(2))
tenantCtx := roachpb.ContextWithClientTenant(context.Background(), roachpb.MustMakeTenantID(3))
_, err := heartbeat.Ping(tenantCtx, request)
require.NoError(t, err)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func TestServerSQLConn(t *testing.T) {

// Start some secondary tenant servers.
secondaryTenantExtNoName, err := s.TenantController().StartTenant(ctx, base.TestTenantArgs{
TenantID: roachpb.MustMakeTenantID(2),
TenantID: roachpb.MustMakeTenantID(3),
})
require.NoError(t, err)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestSettingWatcherOnTenant(t *testing.T) {
// value (which would cause a panic in test builds).
systemOnlySetting: {2 << 20, 4 << 20},
}
fakeTenant := roachpb.MustMakeTenantID(2)
fakeTenant := roachpb.MustMakeTenantID(3)
systemTable := keys.SystemSQLCodec.TablePrefix(keys.SettingsTableID)
fakeCodec := keys.MakeSQLCodec(fakeTenant)
fakeTenantSpan := keys.MakeTenantSpan(fakeTenant)
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ func TestHotRangesPayloadMultitenant(t *testing.T) {
})
defer s.Stopper().Stop(ctx)

tenantID := roachpb.MustMakeTenantID(2)
tenantID := roachpb.MustMakeTenantID(3)
tt, err := s.TenantController().StartTenant(ctx, base.TestTenantArgs{
TenantID: tenantID,
})
Expand Down
Loading
Loading