Skip to content

Commit

Permalink
server: use params for temp storage and settings for default test tenant
Browse files Browse the repository at this point in the history
This commit makes it so that we use the settings and temp storage from
the server params (if available) when starting up the default test
tenant. The temp storage fix allows us to adjust one test to work with
the test tenant.

Release note: None
  • Loading branch information
yuzefovich committed Aug 24, 2023
1 parent 7164cad commit a63f83b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,14 @@ func (ts *testServer) maybeStartDefaultTestTenant(ctx context.Context) error {
return nil // nolint:returnerrcheck
}

tempStorageConfig := base.DefaultTestTempStorageConfig(cluster.MakeTestingClusterSettings())
tenantSettings := ts.params.Settings
if tenantSettings == nil {
tenantSettings = cluster.MakeTestingClusterSettings()
}
tempStorageConfig := ts.params.TempStorageConfig
if tempStorageConfig.Settings == nil {
tempStorageConfig = base.DefaultTestTempStorageConfig(tenantSettings)
}
params := base.TestTenantArgs{
// Currently, all the servers leverage the same tenant ID. We may
// want to change this down the road, for more elaborate testing.
Expand All @@ -614,7 +621,7 @@ func (ts *testServer) maybeStartDefaultTestTenant(ctx context.Context) error {
SSLCertsDir: ts.params.SSLCertsDir,
TestingKnobs: ts.params.Knobs,
StartDiagnosticsReporting: ts.params.StartDiagnosticsReporting,
Settings: ts.params.Settings,
Settings: tenantSettings,
}

// Since we're creating a tenant, it doesn't make sense to pass through the
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/colflow/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ go_test(
embed = [":colflow"],
deps = [
"//pkg/base",
"//pkg/ccl",
"//pkg/col/coldata",
"//pkg/col/coldataext",
"//pkg/col/coldatatestutils",
"//pkg/keys",
"//pkg/kv",
"//pkg/multitenant/tenantcapabilities",
"//pkg/roachpb",
"//pkg/security/securityassets",
"//pkg/security/securitytest",
Expand Down
13 changes: 13 additions & 0 deletions pkg/sql/colflow/draining_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/ccl"
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
Expand All @@ -32,6 +35,7 @@ import (
func TestDrainingAfterRemoteError(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
defer ccl.TestingEnableEnterprise()()

ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
Expand Down Expand Up @@ -59,6 +63,15 @@ func TestDrainingAfterRemoteError(t *testing.T) {
tc := testcluster.StartTestCluster(t, 2 /* nodes */, args)
defer tc.Stopper().Stop(ctx)

if tc.StartedDefaultTestTenant() {
systemSqlDB := tc.Server(0).SystemLayer().SQLConn(t, "system")
_, err := systemSqlDB.Exec(`ALTER TENANT [$1] GRANT CAPABILITY can_admin_relocate_range=true`, serverutils.TestTenantID().ToUint64())
require.NoError(t, err)
serverutils.WaitForTenantCapabilities(t, tc.Server(0), serverutils.TestTenantID(), map[tenantcapabilities.ID]string{
tenantcapabilities.CanAdminRelocateRange: "true",
}, "")
}

// Create two tables, one with small values, and another with large rows.
// Relocate the range for the small table to node 2.
conn := tc.ServerConn(0)
Expand Down

0 comments on commit a63f83b

Please sign in to comment.