Skip to content

Commit

Permalink
server: unexport TestTenant
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
knz committed Aug 2, 2023
1 parent 54daaef commit 6f29b21
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 106 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/changefeedccl/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ func makeTenantServerWithOptions(
TestServer: TestServer{
DB: tenantDB,
Server: tenantServer,
TestingKnobs: tenantServer.(*server.TestTenant).Cfg.TestingKnobs,
TestingKnobs: *tenantServer.TestingKnobs(),
Codec: keys.MakeSQLCodec(tenantID),
},
SystemDB: systemDB,
Expand Down
27 changes: 0 additions & 27 deletions pkg/ccl/serverccl/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/server/authserver"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/lexbase"
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
"github.com/cockroachdb/cockroach/pkg/testutils"
Expand Down Expand Up @@ -125,32 +124,6 @@ ALTER TENANT application START SERVICE SHARED`)
}
}

func TestSharedProcessServerInheritsTempStorageLimit(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

const specialSize = 123123123

// Start a server with a custom temp storage limit.
ctx := context.Background()
st := cluster.MakeClusterSettings()
s := serverutils.StartServerOnly(t, base.TestServerArgs{
Settings: st,
TempStorageConfig: base.DefaultTestTempStorageConfigWithSize(st, specialSize),
DefaultTestTenant: base.TestControlsTenantsExplicitly,
})
defer s.Stopper().Stop(ctx)

// Start a shared process tenant server.
ts, _, err := s.StartSharedProcessTenant(ctx, base.TestSharedProcessTenantArgs{
TenantName: "hello",
})
require.NoError(t, err)

tss := ts.(*server.TestTenant)
require.Equal(t, int64(specialSize), tss.SQLCfg.TempStorageConfig.Mon.Limit())
}

func TestServerControllerHTTP(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
Expand Down
7 changes: 3 additions & 4 deletions pkg/ccl/sqlproxyccl/proxy_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/tenantdirsvr"
"github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/throttler"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
Expand Down Expand Up @@ -1933,15 +1932,15 @@ func TestConnectionMigration(t *testing.T) {

// Start first SQL pod.
tenant1, tenantDB1 := serverutils.StartTenant(t, s, tests.CreateTestTenantParams(tenantID))
tenant1.(*server.TestTenant).PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
tenant1.PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
defer tenant1.Stopper().Stop(ctx)
defer tenantDB1.Close()

// Start second SQL pod.
params2 := tests.CreateTestTenantParams(tenantID)
params2.DisableCreateTenant = true
tenant2, tenantDB2 := serverutils.StartTenant(t, s, params2)
tenant2.(*server.TestTenant).PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
tenant2.PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
defer tenant2.Stopper().Stop(ctx)
defer tenantDB2.Close()

Expand Down Expand Up @@ -2989,7 +2988,7 @@ func startTestTenantPodsWithStopper(
params.TestingKnobs = knobs
params.Stopper = stopper
tenant, tenantDB := serverutils.StartTenant(t, ts, params)
tenant.(*server.TestTenant).PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)
tenant.PGPreServer().(*pgwire.PreServeConnHandler).TestingSetTrustClientProvidedRemoteAddr(true)

// Create a test user. We only need to do it once.
if i == 0 {
Expand Down
27 changes: 27 additions & 0 deletions pkg/server/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand Down Expand Up @@ -82,3 +83,29 @@ func TestSQLErrorUponInvalidTenant(t *testing.T) {
err = db.Ping()
require.Regexp(t, `service unavailable for target tenant \(nonexistent\)`, err.Error())
}

func TestSharedProcessServerInheritsTempStorageLimit(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

const specialSize = 123123123

// Start a server with a custom temp storage limit.
ctx := context.Background()
st := cluster.MakeClusterSettings()
s := serverutils.StartServerOnly(t, base.TestServerArgs{
Settings: st,
TempStorageConfig: base.DefaultTestTempStorageConfigWithSize(st, specialSize),
DefaultTestTenant: base.TestControlsTenantsExplicitly,
})
defer s.Stopper().Stop(ctx)

// Start a shared process tenant server.
ts, _, err := s.StartSharedProcessTenant(ctx, base.TestSharedProcessTenantArgs{
TenantName: "hello",
})
require.NoError(t, err)

tss := ts.(*testTenant)
require.Equal(t, int64(specialSize), tss.SQLCfg.TempStorageConfig.Mon.Limit())
}
2 changes: 1 addition & 1 deletion pkg/server/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func newTenantServer(
// Instantiate the migration API server.
tms := newTenantMigrationServer(sqlServer)
serverpb.RegisterMigrationServer(args.grpc.Server, tms)
sqlServer.migrationServer = tms // only for testing via TestTenant
sqlServer.migrationServer = tms // only for testing via testTenant

// Tell the authz server how to connect to SQL.
adminAuthzCheck.SetAuthzAccessorFactory(func(opName string) (sql.AuthorizationAccessor, func()) {
Expand Down
Loading

0 comments on commit 6f29b21

Please sign in to comment.