From c6a8fd7f9c1a52355022f3f05db2682ea36fe724 Mon Sep 17 00:00:00 2001 From: Herko Lategan Date: Tue, 12 Dec 2023 14:33:55 +0000 Subject: [PATCH] roachtest: add `DefaultStartVirtualClusterOpts` convenience function Add a convenience function to return `StartOpts` for starting an external process virtual cluster. Epic: None Release Note: None --- pkg/cmd/roachtest/option/options.go | 10 ++++++++++ pkg/cmd/roachtest/tests/multitenant_distsql.go | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/roachtest/option/options.go b/pkg/cmd/roachtest/option/options.go index 37e0f262af1a..6cc69bc2e540 100644 --- a/pkg/cmd/roachtest/option/options.go +++ b/pkg/cmd/roachtest/option/options.go @@ -46,6 +46,16 @@ func DefaultStartSingleNodeOpts() StartOpts { return startOpts } +// DefaultStartVirtualClusterOpts returns StartOpts for starting an external +// process virtual cluster with the given tenant name and SQL instance. +func DefaultStartVirtualClusterOpts(tenantName string, sqlInstance int) StartOpts { + startOpts := StartOpts{RoachprodOpts: roachprod.DefaultStartOpts()} + startOpts.RoachprodOpts.Target = install.StartServiceForVirtualCluster + startOpts.RoachprodOpts.VirtualClusterName = tenantName + startOpts.RoachprodOpts.SQLInstance = sqlInstance + return startOpts +} + // StopOpts is a type that combines the stop options needed by roachprod and roachtest. type StopOpts struct { RoachprodOpts roachprod.StopOpts diff --git a/pkg/cmd/roachtest/tests/multitenant_distsql.go b/pkg/cmd/roachtest/tests/multitenant_distsql.go index bd0e0320d08d..0cf83d22cf77 100644 --- a/pkg/cmd/roachtest/tests/multitenant_distsql.go +++ b/pkg/cmd/roachtest/tests/multitenant_distsql.go @@ -73,17 +73,7 @@ func runMultiTenantDistSQL( for i := 0; i < numInstances; i++ { node := (i % c.Spec().NodeCount) + 1 sqlInstance := i / c.Spec().NodeCount - instStartOps := option.DefaultStartOpts() - instStartOps.RoachprodOpts.Target = install.StartServiceForVirtualCluster - instStartOps.RoachprodOpts.VirtualClusterName = tenantName - instStartOps.RoachprodOpts.SQLInstance = sqlInstance - // We set the ports to 0 so that ports are assigned dynamically. This is a - // temporary workaround until we use dynamic port assignment as the default. - // See: https://github.com/cockroachdb/cockroach/issues/111052 - // TODO(herko): remove this once dynamic port assignment is the default. - instStartOps.RoachprodOpts.SQLPort = 0 - instStartOps.RoachprodOpts.AdminUIPort = 0 - + instStartOps := option.DefaultStartVirtualClusterOpts(tenantName, sqlInstance) t.L().Printf("Starting instance %d on node %d", i, node) c.StartServiceForVirtualCluster(ctx, t.L(), c.Node(node), instStartOps, settings, storageNodes) nodes.Add(i + 1)