Skip to content

Commit

Permalink
testserver: do not verify enterprise license
Browse files Browse the repository at this point in the history
Prior to this patch, for test tenant servers to be automatically used
two conditions needed to hold:

- the CCL package(s) needed to be imported.
- an enterprise license needed to be set (usually via `ccl.TestingEnableEnterprise()`)

While we want these conditions to hold to start separate-process SQL
servers in production, they do not need to be verified in unit tests.

NB: as a result of merging this PR, numerous (recently introduced)
calls to `ccl.TestingEnableEnterprise()` in various `main_test.go`
files are now unnecessary. Cleaning them up can be pushed to a later
phase.

Release note: None
  • Loading branch information
knz committed Aug 27, 2023
1 parent 11455fa commit 41a0097
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ go_library(
"//pkg/util/log/logcrash",
"//pkg/util/log/logmetrics",
"//pkg/util/log/logpb",
"//pkg/util/log/severity",
"//pkg/util/metric",
"//pkg/util/mon",
"//pkg/util/netutil",
Expand Down
15 changes: 1 addition & 14 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/admission"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/severity"
"github.com/cockroachdb/cockroach/pkg/util/metric"
"github.com/cockroachdb/cockroach/pkg/util/netutil"
addrutil "github.com/cockroachdb/cockroach/pkg/util/netutil/addr"
Expand Down Expand Up @@ -587,18 +586,6 @@ func (ts *testServer) maybeStartDefaultTestTenant(ctx context.Context) error {
return nil
}

clusterID := ts.sqlServer.execCfg.NodeInfo.LogicalClusterID
if err := base.CheckEnterpriseEnabled(ts.st, clusterID(), "SQL servers"); err != nil {
log.Shoutf(ctx, severity.WARNING, "test tenant requested by configuration, but code organization prevents start!\n%v", err)
// If not enterprise enabled, we won't be able to use SQL Servers so eat
// the error and return without creating/starting a SQL server.
//
// TODO(knz/yahor): Remove this - as we discussed this ought to work
// now even when not enterprise enabled.
ts.params.DefaultTestTenant = base.TODOTestTenantDisabled
return nil // nolint:returnerrcheck
}

tenantSettings := ts.params.Settings
if tenantSettings == nil {
tenantSettings = cluster.MakeTestingClusterSettings()
Expand Down Expand Up @@ -1423,7 +1410,7 @@ func (ts *testServer) StartTenant(

st.ExternalIODir = params.ExternalIODir
sqlCfg := makeTestSQLConfig(st, params.TenantID)
sqlCfg.TenantKVAddrs = []string{ts.AdvRPCAddr()}
sqlCfg.TenantLoopbackAddr = ts.AdvRPCAddr()
sqlCfg.ExternalIODirConfig = params.ExternalIODirConfig
if params.MemoryPoolSize != 0 {
sqlCfg.MemoryPoolSize = params.MemoryPoolSize
Expand Down
7 changes: 4 additions & 3 deletions pkg/testutils/testcluster/testcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ func TestManualReplication(t *testing.T) {
s2.ExecRowsAffected(t, 3, `DELETE FROM test`)

// Split the table to a new range.
kvDB := tc.Servers[0].DB()
tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "t", "test")
ts := tc.Server(0).ApplicationLayer()
kvDB := ts.DB()
tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, ts.Codec(), "t", "test")

tableStartKey := keys.SystemSQLCodec.TablePrefix(uint32(tableDesc.GetID()))
tableStartKey := ts.Codec().TablePrefix(uint32(tableDesc.GetID()))
leftRangeDesc, tableRangeDesc, err := tc.SplitRange(tableStartKey)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 41a0097

Please sign in to comment.