Skip to content

Commit

Permalink
Merge #33645
Browse files Browse the repository at this point in the history
33645: roachtest: use `fixtures import` for tpccbench on AWS r=ajwerner a=ajwerner

#33625 made this change for regular tpcc roachtests but failed to update the
tpccbench test. This PR factors the logic out and uses it for tpccbench too.

Release note: None

Co-authored-by: Andrew Werner <[email protected]>
  • Loading branch information
craig[bot] and ajwerner committed Jan 10, 2019
2 parents f921c46 + 6cdfa25 commit f5e3c29
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/cmd/roachtest/tpcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ type tpccOptions struct {
ZFS bool
}

// tpccFixturesCmd generates the command string to load tpcc data for the
// specified warehouse count into a cluster using either `fixtures import`
// or `fixtures load` depending on the cloud.
func tpccFixturesCmd(cloud string, warehouses int, checks bool) string {
action := "load"
if cloud == "aws" {
action = "import"
}
return fmt.Sprintf("./workload fixtures %s tpcc --checks=%v --warehouses=%d {pgurl:1}",
action, checks, warehouses)
}

func runTPCC(ctx context.Context, t *test, c *cluster, opts tpccOptions) {
crdbNodes := c.Range(1, c.nodes-1)
workloadNode := c.Node(c.nodes)
Expand Down Expand Up @@ -72,14 +84,6 @@ func runTPCC(ctx context.Context, t *test, c *cluster, opts tpccOptions) {
}

func() {
var fixturesCmd string
if cloud == "aws" {
fixturesCmd = fmt.Sprintf(
"./workload fixtures import tpcc --warehouses=%d {pgurl:1}", fixtureWarehouses)
} else {
fixturesCmd = fmt.Sprintf(
"./workload fixtures load tpcc --warehouses=%d {pgurl:1}", fixtureWarehouses)
}
db := c.Conn(ctx, 1)
defer db.Close()
if opts.ZFS {
Expand All @@ -92,7 +96,7 @@ func runTPCC(ctx context.Context, t *test, c *cluster, opts tpccOptions) {
t.Status("loading dataset")
c.Start(ctx, t, crdbNodes)

c.Run(ctx, workloadNode, fixturesCmd)
c.Run(ctx, workloadNode, tpccFixturesCmd(cloud, fixtureWarehouses, true /* checks */))
c.Stop(ctx, crdbNodes)

c.Run(ctx, crdbNodes, "test -e /sbin/zfs && sudo zfs snapshot data1@pristine")
Expand All @@ -102,7 +106,7 @@ func runTPCC(ctx context.Context, t *test, c *cluster, opts tpccOptions) {
c.Start(ctx, t, crdbNodes)
} else {
c.Start(ctx, t, crdbNodes)
c.Run(ctx, workloadNode, fixturesCmd)
c.Run(ctx, workloadNode, tpccFixturesCmd(cloud, fixtureWarehouses, true /* checks */))
}
}()
t.Status("waiting")
Expand Down Expand Up @@ -442,8 +446,7 @@ func loadTPCCBench(

// Load the corresponding fixture.
t.l.Printf("restoring tpcc fixture\n")
cmd := fmt.Sprintf(
"./workload fixtures load tpcc --checks=false --warehouses=%d {pgurl:1}", b.LoadWarehouses)
cmd := tpccFixturesCmd(cloud, b.LoadWarehouses, false /* checks */)
if err := c.RunE(ctx, loadNode, cmd); err != nil {
return err
}
Expand Down

0 comments on commit f5e3c29

Please sign in to comment.