Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testserver: add ShareMostTestingKnobsWithTenant option #88557

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/base/test_server_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ type TestServerArgs struct {
// or if some of the functionality being tested is not accessible from
// within tenants.
DisableDefaultTestTenant bool

// ShareMostTestingKnobsWithTenant should be set by tests that want their
// testing knobs shared with the any DefaultTestTenant that the server starts.
// See (*testserver).TestingKnobsForTenant for details on which knobs aren't
// shared.
ShareMostTestingKnobsWithTenant bool
}

// TestClusterArgs contains the parameters one can set when creating a test
Expand Down
19 changes: 17 additions & 2 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ func (ts *TestServer) TestingKnobs() *base.TestingKnobs {
return nil
}

// TestingKnobsForTenant returns a TestingKnobs that is used when starting Test
// Tenants. These knobs are a copy of the Server's TestingKnobs with any knobs
// that have been found to be problematic to share by default removed.
func (ts *TestServer) TestingKnobsForTenant() base.TestingKnobs {
knobs := *ts.TestingKnobs()
// TODO(ssd): We don't share the Server knobs the testcluster setup code
// installed an RPC listener that is inappropriate for the tenant.
knobs.Server = nil
return knobs
}

// TenantStatusServer returns the TenantStatusServer used by the TestServer.
func (ts *TestServer) TenantStatusServer() interface{} {
return ts.status
Expand Down Expand Up @@ -546,10 +557,14 @@ func (ts *TestServer) maybeStartDefaultTestTenant(ctx context.Context) error {
UseDatabase: ts.params.UseDatabase,
SSLCertsDir: ts.params.SSLCertsDir,
AllowSettingClusterSettings: true,
}
if ts.params.ShareMostTestingKnobsWithTenant {
params.TestingKnobs = ts.TestingKnobsForTenant()
} else {
// These settings are inherited from the SQL server creation in
// logicTest.newCluster, and are required to run the logic test suite
// successfully.
TestingKnobs: base.TestingKnobs{
params.TestingKnobs = base.TestingKnobs{
SQLExecutor: &sql.ExecutorTestingKnobs{
DeterministicExplain: true,
UseTransactionalDescIDGenerator: useTransactionalDescIDGenerator,
Expand All @@ -558,7 +573,7 @@ func (ts *TestServer) maybeStartDefaultTestTenant(ctx context.Context) error {
AOSTClause: "AS OF SYSTEM TIME '-1us'",
},
RangeFeed: ts.TestingKnobs().RangeFeed,
},
}
}

tenant, err := ts.StartTenant(ctx, params)
Expand Down