Skip to content

Commit

Permalink
multitenant: remove WaitForTenantEndKeySplit test function
Browse files Browse the repository at this point in the history
This function was added as part of #95100 to block until the tenant's end key
split point was created asynchronously, but is no longer needed because the
tenant end key split point is created synchronously on tenant creation.

Release note: None
  • Loading branch information
ecwall committed Mar 22, 2023
1 parent 50b0d42 commit 03b9480
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 54 deletions.
1 change: 0 additions & 1 deletion pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ go_library(
"//pkg/storage",
"//pkg/storage/enginepb",
"//pkg/storage/fs",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
"//pkg/ts",
Expand Down
33 changes: 0 additions & 33 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/ts"
Expand All @@ -62,7 +61,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/log/severity"
"github.com/cockroachdb/cockroach/pkg/util/metric"
addrutil "github.com/cockroachdb/cockroach/pkg/util/netutil/addr"
"github.com/cockroachdb/cockroach/pkg/util/rangedesc"
"github.com/cockroachdb/cockroach/pkg/util/retry"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
Expand Down Expand Up @@ -820,31 +818,6 @@ func (t *TestTenant) SettingsWatcher() interface{} {
return t.SQLServer.settingsWatcher
}

// WaitForTenantEndKeySplit is part of the TestTenantInterface.
func (t *TestTenant) WaitForTenantEndKeySplit(ctx context.Context) error {
// Wait until the tenant end key split happens.
return testutils.SucceedsWithinError(func() error {
factory := t.RangeDescIteratorFactory().(rangedesc.IteratorFactory)

iterator, err := factory.NewIterator(ctx, t.Codec().TenantSpan())
if err != nil {
return err
}
if !iterator.Valid() {
return errors.New("range iterator has no ranges")
}

for iterator.Valid() {
rangeDesc := iterator.CurRangeDescriptor()
if rangeDesc.EndKey.Compare(roachpb.RKeyMax) == 0 {
return errors.Newf("range ID %d end key not split", rangeDesc.RangeID)
}
iterator.Next()
}
return nil
}, 10*time.Second)
}

// StartSharedProcessTenant is part of TestServerInterface.
func (ts *TestServer) StartSharedProcessTenant(
ctx context.Context, args base.TestSharedProcessTenantArgs,
Expand Down Expand Up @@ -1668,12 +1641,6 @@ func (ts *TestServer) Tracer() *tracing.Tracer {
return ts.node.storeCfg.AmbientCtx.Tracer
}

// WaitForTenantEndKeySplit is part of the TestTenantInterface.
func (ts *TestServer) WaitForTenantEndKeySplit(context.Context) error {
// Does not apply to system tenant.
return nil
}

// ForceTableGC is part of TestServerInterface.
func (ts *TestServer) ForceTableGC(
ctx context.Context, database, table string, timestamp hlc.Timestamp,
Expand Down
3 changes: 0 additions & 3 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1458,9 +1458,6 @@ func (t *logicTest) newCluster(
if err != nil {
t.rootT.Fatalf("%+v", err)
}
if err := tenant.WaitForTenantEndKeySplit(context.Background()); err != nil {
t.rootT.Fatalf("%+v", err)
}
t.tenantAddrs[i] = tenant.SQLAddr()
}

Expand Down
10 changes: 1 addition & 9 deletions pkg/sql/multitenant_admin_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func (tc testCase) runTest(
testServer.Stopper(),
)

var secondaryTenants []serverutils.TestTenantInterface
createSecondaryDB := func(
tenantID roachpb.TenantID,
clusterSettings ...*settings.BoolSetting,
Expand All @@ -270,13 +269,12 @@ func (tc testCase) runTest(
clusterSetting.Override(ctx, &testingClusterSettings.SV, true)
}
}
tenant, db := serverutils.StartTenant(
_, db := serverutils.StartTenant(
t, testServer, base.TestTenantArgs{
Settings: testingClusterSettings,
TenantID: tenantID,
},
)
secondaryTenants = append(secondaryTenants, tenant)
return db
}

Expand Down Expand Up @@ -339,12 +337,6 @@ func (tc testCase) runTest(
fn()
}

// Wait for splits after starting all tenants to make test start up faster.
for _, tenant := range secondaryTenants {
err := tenant.WaitForTenantEndKeySplit(ctx)
require.NoError(t, err)
}

execQueries(testCluster, systemDB, "system", tc.system)
if tc.secondary.isSet() {
execQueries(testCluster, secondaryDB, "secondary", tc.secondary)
Expand Down
8 changes: 0 additions & 8 deletions pkg/testutils/serverutils/test_tenant_shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ type TestTenantInterface interface {
// Tracer returns a reference to the tenant's Tracer.
Tracer() *tracing.Tracer

// WaitForTenantEndKeySplit blocks until the tenant's initial range is split
// at the end key. For example, this will wait until tenant 10 has a split at
// /Tenant/11.
//
// Tests that use crdb_internal.ranges, crdb_internal.ranges_no_leases, or
// SHOW RANGES from a secondary tenant should call this to avoid races.
WaitForTenantEndKeySplit(ctx context.Context) error

// MigrationServer returns the tenant's migration server, which is used in
// upgrade testing.
MigrationServer() interface{}
Expand Down

0 comments on commit 03b9480

Please sign in to comment.