Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachtest: create simple tpce workload driver #99810

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

msbutler
Copy link
Collaborator

Currently, the tpce workload is used in 2 roachtests in tpce.go. This patch makes it easier for other roachtests to init and run a tpce workload by creating a tpce driver that abstracts away the actual cmds required to init and run a tpce workload. This will make it easier to address #99787, for example.

Informs #99787

Release note: none

@msbutler msbutler added the T-testeng TestEng Team label Mar 28, 2023
@msbutler msbutler requested a review from a team as a code owner March 28, 2023 15:25
@msbutler msbutler self-assigned this Mar 28, 2023
@msbutler msbutler requested review from smg260 and renatolabs and removed request for a team March 28, 2023 15:25
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@renatolabs renatolabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @msbutler and @smg260)


pkg/cmd/roachtest/tests/tpce.go line 30 at r1 (raw file):

type tpceSpec struct {
	loadNode         option.NodeListOption

Nit: make this an int if you have any intentions of really having just one "load node", or rename it to loadNodes if having multiple workload nodes is officially supported (as suggested by the current type).


pkg/cmd/roachtest/tests/tpce.go line 56 at r1 (raw file):

		builder.WriteString(fmt.Sprintf(" --threads=%d", to.threads))
	}
	return builder.String()

May I suggest the use of commandbuilder here?


pkg/cmd/roachtest/tests/tpce.go line 61 at r1 (raw file):

func initTPCESpec(
	ctx context.Context, t test.Test, c cluster.Cluster, loadNode,
	roachNodes option.NodeListOption,

TIL this is crlfmt compliant.


pkg/cmd/roachtest/tests/tpce.go line 63 at r1 (raw file):

	roachNodes option.NodeListOption,
) (*tpceSpec, error) {
	t.Status("installing docker")

Suggestion: can we take a logger instance as argument and use that here instead of t.Status / t.L(). You can keep existing behavior in the your caller by passing t.L() and would make this struct friendlier to implementations that desire more fine grained control of test logging.

Copy link
Collaborator Author

@msbutler msbutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @renatolabs and @smg260)


pkg/cmd/roachtest/tests/tpce.go line 30 at r1 (raw file):

Previously, renatolabs (Renato Costa) wrote…

Nit: make this an int if you have any intentions of really having just one "load node", or rename it to loadNodes if having multiple workload nodes is officially supported (as suggested by the current type).

Done.


pkg/cmd/roachtest/tests/tpce.go line 56 at r1 (raw file):

Previously, renatolabs (Renato Costa) wrote…

May I suggest the use of commandbuilder here?

dang this is slick!!! Sadly I had to sprintf the hosts as they're passed as duplicate flags: e.g "hosts=ip1 hosts=ip2".


pkg/cmd/roachtest/tests/tpce.go line 61 at r1 (raw file):

Previously, renatolabs (Renato Costa) wrote…

TIL this is crlfmt compliant.

🤷

crlfmt
diff -u old/pkg/cmd/roachtest/tests/tpce.go new/pkg/cmd/roachtest/tests/tpce.go
--- old/pkg/cmd/roachtest/tests/tpce.go	2023-03-30 09:16:29
+++ new/pkg/cmd/roachtest/tests/tpce.go	2023-03-30 09:16:29
@@ -13,17 +13,17 @@
 import (
 	"context"
 	"fmt"
-	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
-	"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
 	"strings"
 	"time"

 	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
 	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
 	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
+	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
 	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
 	"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
 	"github.com/cockroachdb/cockroach/pkg/roachprod/install"
+	"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
 	"github.com/cockroachdb/errors"
 	"github.com/stretchr/testify/require"
 )
@@ -49,7 +49,10 @@
 }

 func initTPCESpec(
-	ctx context.Context, l *logger.Logger, c cluster.Cluster, loadNode int,
+	ctx context.Context,
+	l *logger.Logger,
+	c cluster.Cluster,
+	loadNode int,
 	roachNodes option.NodeListOption,
 ) (*tpceSpec, error) {
 	l.Printf("Installing docker")

pkg/cmd/roachtest/tests/tpce.go line 63 at r1 (raw file):

Previously, renatolabs (Renato Costa) wrote…

Suggestion: can we take a logger instance as argument and use that here instead of t.Status / t.L(). You can keep existing behavior in the your caller by passing t.L() and would make this struct friendlier to implementations that desire more fine grained control of test logging.

Done.

Copy link
Contributor

@renatolabs renatolabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Sorry, forgot about this PR. Just one small nit!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @msbutler and @smg260)


pkg/cmd/roachtest/tests/tpce.go line 56 at r1 (raw file):

Previously, msbutler (Michael Butler) wrote…

dang this is slick!!! Sadly I had to sprintf the hosts as they're passed as duplicate flags: e.g "hosts=ip1 hosts=ip2".

Yeah, when I saw this code I thought of how we could have some APIs in that package to support use cases like this one. I'll eventually get to it.


pkg/cmd/roachtest/tests/tpce.go line 86 at r2 (raw file):

// import of the data and schema creation.
func (ts *tpceSpec) init(ctx context.Context, t test.Test, c cluster.Cluster, o tpceCmdOptions) {
	cmd := ts.newCmd(o).Flag("init", "")

Nit: while the command will run fine with this (the formatting will include extra spaces due to the empty string), the API for flags/options that don't take a corresponding value is Option("init").

Currently, the tpce workload is used in 2 roachtests in tpce.go. This patch
makes it easier for other roachtests to init and run a tpce workload by
creating a tpce driver that abstracts away the actual cmds required to init and
run a tpce workload. This will make it easier to address cockroachdb#99787, for example.

Informs cockroachdb#99787

Release note: none
@msbutler msbutler force-pushed the butler-portable-tpce branch from 57d3650 to 36a1187 Compare April 6, 2023 11:44
Copy link
Collaborator Author

@msbutler msbutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @renatolabs and @smg260)


pkg/cmd/roachtest/tests/tpce.go line 86 at r2 (raw file):

Previously, renatolabs (Renato Costa) wrote…

Nit: while the command will run fine with this (the formatting will include extra spaces due to the empty string), the API for flags/options that don't take a corresponding value is Option("init").

Done

@msbutler
Copy link
Collaborator Author

msbutler commented Apr 6, 2023

TFTR!

bors=renatolabs

@msbutler
Copy link
Collaborator Author

msbutler commented Apr 6, 2023

bors r=renatolabs

@craig
Copy link
Contributor

craig bot commented Apr 6, 2023

Build succeeded:

@craig craig bot merged commit 01f3b26 into cockroachdb:master Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-testeng TestEng Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants