Skip to content

Commit

Permalink
roachtest: add DefaultStartVirtualClusterOpts convenience function
Browse files Browse the repository at this point in the history
Add a convenience function to return `StartOpts` for starting an external
process virtual cluster.

Epic: None
Release Note: None
  • Loading branch information
herkolategan committed Dec 14, 2023
1 parent a1f26dd commit 555437e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 10 additions & 0 deletions pkg/cmd/roachtest/option/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 {
// TODO(radu): we should use a higher-level abstraction instead of
Expand Down
12 changes: 1 addition & 11 deletions pkg/cmd/roachtest/tests/multitenant_distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 555437e

Please sign in to comment.