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

testutils: add DeploymentMode method to ApplicationLayerInterface #140662

Merged
merged 1 commit into from
Feb 13, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,9 @@ type testTenant struct {
// pgPreServer handles SQL connections prior to routing them to a
// specific tenant.
pgPreServer *pgwire.PreServeConnHandler
// deploymentMode specifies the tenant's deployment mode.
// Allowed values: ExternalProcess or SharedProcess.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allowed value list is a bit off. Doesn't include: SingleTenant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, testTenant and testServer implement ApplicationInterface, with testTenant used for secondary tenants and testServer for a single tenant. That's why I didn't include SingleTenant here.

deploymentMode serverutils.DeploymentMode
}

var _ serverutils.ApplicationLayerInterface = &testTenant{}
Expand Down Expand Up @@ -1258,6 +1261,11 @@ func (t *testTenant) SettingsWatcher() interface{} {
return t.sql.settingsWatcher
}

// DeploymentMode is part of the serverutils.ApplicationLayerInterface.
func (t *testTenant) DeploymentMode() serverutils.DeploymentMode {
return t.deploymentMode
}

// WaitForTenantCapabilities is part of the serverutils.TenantControlInterface.
func (ts *testServer) WaitForTenantCapabilities(
ctx context.Context,
Expand Down Expand Up @@ -1415,6 +1423,7 @@ func (ts *testServer) StartSharedProcessTenant(
pgL: sqlServerWrapper.loopbackPgL,
httpTestServer: hts,
drain: sqlServerWrapper.drainServer,
deploymentMode: serverutils.SharedProcess,
}

sqlDB, err := ts.SQLConnE(serverutils.DBName("cluster:" + string(args.TenantName) + "/" + args.UseDatabase))
Expand Down Expand Up @@ -1791,6 +1800,7 @@ func (ts *testServer) StartTenant(
http: sw.http,
drain: sw.drainServer,
pgL: sw.loopbackPgL,
deploymentMode: serverutils.ExternalProcess,
}, err
}

Expand Down Expand Up @@ -1920,6 +1930,11 @@ func (ts *testServer) MustGetSQLNetworkCounter(name string) int64 {
return mustGetSQLCounterForRegistry(reg, name)
}

// DeploymentMode is part of the serverutils.ApplicationLayerInterface.
func (ts *testServer) DeploymentMode() serverutils.DeploymentMode {
return serverutils.SingleTenant
}

// Locality is part of the serverutils.ApplicationLayerInterface.
func (ts *testServer) Locality() roachpb.Locality {
return ts.cfg.Locality
Expand Down
16 changes: 16 additions & 0 deletions pkg/testutils/serverutils/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ type TestServerController interface {
RunInitialSQL(ctx context.Context, startSingleNode bool, adminUser, adminPassword string) error
}

// DeploymentMode defines the mode of the underlying test server or tenant,
// which can be single-tenant (system-only), shared-process, or
// external-process.
type DeploymentMode uint8

const (
SingleTenant DeploymentMode = iota
SharedProcess
ExternalProcess
)

// ApplicationLayerInterface defines accessors to the application
// layer of a test server. Tests written against this interface are
// effectively agnostic to whether they use a virtual cluster or not.
Expand Down Expand Up @@ -451,6 +462,11 @@ type ApplicationLayerInterface interface {

// DistSQLPlanningNodeID returns the NodeID to use by the DistSQL span resolver.
DistSQLPlanningNodeID() roachpb.NodeID

// DeploymentMode returns the deployment mode of the underlying server or
// tenant, which can be single-tenant (system-only), shared-process, or
// external-process.
DeploymentMode() DeploymentMode
}

// TenantControlInterface defines the API of a test server that can
Expand Down