Skip to content

Commit cd044a1

Browse files
committed
roachtest: use versioned bank workloads for mixed version
As of #149374, the bank workload is no longer backwards compatible. This changes mixed version tests that use the bank workload to upload a versioned binary and use that to import the workload.
1 parent 0af528e commit cd044a1

File tree

7 files changed

+51
-13
lines changed

7 files changed

+51
-13
lines changed

pkg/cmd/roachtest/roachtestutil/mixedversion/mixedversion.go

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,16 @@ func (t *Test) BackgroundCommand(
826826
// if passed, is the command run to initialize the workload; it is run
827827
// synchronously as a regular startup function. `runCmd` is the
828828
// command to actually run the command; it is run in the background.
829+
//
830+
// If overrideBinary is true, the binary used to run the command(s) will
831+
// be replaced with the cockroach binary of the current version the
832+
// cluster is running in.
833+
// TODO(testeng): Replace with https://github.com/cockroachdb/cockroach/issues/147374
829834
func (t *Test) Workload(
830-
name string, node option.NodeListOption, initCmd, runCmd *roachtestutil.Command,
835+
name string,
836+
node option.NodeListOption,
837+
initCmd, runCmd *roachtestutil.Command,
838+
overrideBinary bool,
831839
) StopFunc {
832840
seed := uint64(t.prng.Int63())
833841
addSeed := func(cmd *roachtestutil.Command) {
@@ -838,11 +846,31 @@ func (t *Test) Workload(
838846

839847
if initCmd != nil {
840848
addSeed(initCmd)
841-
t.OnStartup(fmt.Sprintf("initialize %s workload", name), t.runCommandFunc(node, initCmd.String()))
849+
t.OnStartup(fmt.Sprintf("initialize %s workload", name), func(ctx context.Context, l *logger.Logger, rng *rand.Rand, h *Helper) error {
850+
if overrideBinary {
851+
binary, err := clusterupgrade.UploadCockroach(ctx, t.rt, t.logger, t.cluster, node, h.System.FromVersion)
852+
if err != nil {
853+
t.rt.Fatal(err)
854+
}
855+
initCmd.Binary = binary
856+
}
857+
l.Printf("running command `%s` on nodes %v", initCmd.String(), node)
858+
return t.cluster.RunE(ctx, option.WithNodes(node), initCmd.String())
859+
})
842860
}
843861

844862
addSeed(runCmd)
845-
return t.BackgroundCommand(fmt.Sprintf("%s workload", name), node, runCmd)
863+
return t.BackgroundFunc(fmt.Sprintf("%s workload", name), func(ctx context.Context, l *logger.Logger, rng *rand.Rand, h *Helper) error {
864+
if overrideBinary {
865+
binary, err := clusterupgrade.UploadCockroach(ctx, t.rt, t.logger, t.cluster, node, h.System.FromVersion)
866+
if err != nil {
867+
t.rt.Fatal(err)
868+
}
869+
runCmd.Binary = binary
870+
}
871+
l.Printf("running command `%s` on nodes %v", runCmd.String(), node)
872+
return t.cluster.RunE(ctx, option.WithNodes(node), runCmd.String())
873+
})
846874
}
847875

848876
// Run is like RunE, except it fatals the test if any error occurs.

pkg/cmd/roachtest/roachtestutil/mixedversion/planner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func TestTestPlanner(t *testing.T) {
126126
case "workload":
127127
initCmd := roachtestutil.NewCommand("./cockroach workload init some-workload")
128128
runCmd := roachtestutil.NewCommand("./cockroach workload run some-workload")
129-
mvt.Workload(d.CmdArgs[0].Vals[0], nodes, initCmd, runCmd)
129+
mvt.Workload(d.CmdArgs[0].Vals[0], nodes, initCmd, runCmd, false /* overrideBinary */)
130130
case "background-command":
131131
cmd := roachtestutil.NewCommand("./cockroach some-command")
132132
mvt.BackgroundCommand(d.CmdArgs[0].Vals[0], nodes, cmd)

pkg/cmd/roachtest/tests/mixed_version_backup.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,8 +2954,13 @@ func registerBackupMixedVersion(r registry.Registry) {
29542954
// the cluster relatively busy while the backup and restores
29552955
// take place. Its schema is also more complex, and the
29562956
// operations more closely resemble a customer workload.
2957-
stopBank := mvt.Workload("bank", c.WorkloadNode(), bankInit, bankRun)
2958-
stopTPCC := mvt.Workload("tpcc", c.WorkloadNode(), tpccInit, tpccRun)
2957+
2958+
// Use the same versioned workload binary as the cluster. The bank workload
2959+
// is no longer backwards compatible after #149374, so we need to use the same
2960+
// version as the cockroach cluster.
2961+
// TODO(testeng): Replace with https://github.com/cockroachdb/cockroach/issues/147374
2962+
stopBank := mvt.Workload("bank", c.WorkloadNode(), bankInit, bankRun, true /* overrideBinary */)
2963+
stopTPCC := mvt.Workload("tpcc", c.WorkloadNode(), tpccInit, tpccRun, false /* overrideBinary */)
29592964
stopSystemWriter := mvt.BackgroundFunc("system table writer", backupTest.systemTableWriter)
29602965

29612966
mvt.InMixedVersion("plan and run backups", backupTest.planAndRunBackups)

pkg/cmd/roachtest/tests/mixed_version_c2c.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (cm *c2cMixed) WorkloadHook(ctx context.Context) {
276276
Arg("{pgurl%s}", cm.c.Range(1, cm.sp.srcNodes)).
277277
Option("tolerate-errors").
278278
Flag("warehouses", 500)
279-
cm.workloadStopper = cm.sourceMvt.Workload("tpcc", cm.c.WorkloadNode(), tpccInitCmd, tpccRunCmd)
279+
cm.workloadStopper = cm.sourceMvt.Workload("tpcc", cm.c.WorkloadNode(), tpccInitCmd, tpccRunCmd, false /* overrideBinary */)
280280

281281
readerTenantName := fmt.Sprintf("%s-readonly", destTenantName)
282282

@@ -286,7 +286,7 @@ func (cm *c2cMixed) WorkloadHook(ctx context.Context) {
286286
Flag("warehouses", 500).
287287
Flag("mix", "newOrder=0,payment=0,orderStatus=1,delivery=0,stockLevel=1")
288288

289-
cm.readOnlyWorkloadStopper = cm.destMvt.Workload("tpcc-read-only", cm.c.WorkloadNode(), nil, tpccStandbyRunCmd)
289+
cm.readOnlyWorkloadStopper = cm.destMvt.Workload("tpcc-read-only", cm.c.WorkloadNode(), nil, tpccStandbyRunCmd, false /* overrideBinary */)
290290

291291
}
292292

pkg/cmd/roachtest/tests/mixed_version_ldr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ func (lm *ldrMixed) SetupHook(ctx context.Context) {
258258

259259
func (lm *ldrMixed) WorkloadHook(ctx context.Context) {
260260
leftWorkloadCmd := workloadRunCmd(lm.sp.LeftNodesList())
261-
lm.leftWorkloadStopper = lm.leftMvt.Workload("kv", lm.c.WorkloadNode(), nil, leftWorkloadCmd)
261+
lm.leftWorkloadStopper = lm.leftMvt.Workload("kv", lm.c.WorkloadNode(), nil, leftWorkloadCmd, false /* overrideBinary */)
262262

263263
rightWorkloadCmd := workloadRunCmd(lm.sp.RightNodesList())
264-
lm.rightWorkloadStopper = lm.rightMvt.Workload("kv", lm.c.WorkloadNode(), nil, rightWorkloadCmd)
264+
lm.rightWorkloadStopper = lm.rightMvt.Workload("kv", lm.c.WorkloadNode(), nil, rightWorkloadCmd, false /* overrideBinary */)
265265
}
266266

267267
func (lm *ldrMixed) LatencyHook(ctx context.Context) {

pkg/cmd/roachtest/tests/mixed_version_sql_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func runSQLStatsMixedVersion(ctx context.Context, t test.Test, c cluster.Cluster
7474
}
7575

7676
mvt.OnStartup("set cluster settings", setClusterSettings)
77-
stopTpcc := mvt.Workload("tpcc", c.WorkloadNode(), initWorkload, runWorkload)
77+
stopTpcc := mvt.Workload("tpcc", c.WorkloadNode(), initWorkload, runWorkload, false /* overrideBinary */)
7878
defer stopTpcc()
7979

8080
requestTypes := map[string]serverpb.CombinedStatementsStatsRequest_StatsType{

pkg/cmd/roachtest/tests/tpcc.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,16 @@ func runTPCCMixedHeadroom(ctx context.Context, t test.Test, c cluster.Cluster) {
602602
// upgrade machinery, in which a) all ranges are touched and b) work proportional
603603
// to the amount data may be carried out.
604604
importLargeBank := func(ctx context.Context, l *logger.Logger, rng *rand.Rand, h *mixedversion.Helper) error {
605+
randomNode := c.Node(c.CRDBNodes().SeededRandNode(rng)[0])
606+
// Upload a versioned cockroach binary to the random node. The bank workload
607+
// is no longer backwards compatible after #149374, so we need to use the same
608+
// version as the cockroach cluster.
609+
// TODO(testeng): Replace with https://github.com/cockroachdb/cockroach/issues/147374
610+
binary := uploadCockroach(ctx, t, c, randomNode, h.System.FromVersion)
605611
l.Printf("waiting for tenant features to be enabled")
606612
<-tenantFeaturesEnabled
607613

608-
randomNode := c.Node(c.CRDBNodes().SeededRandNode(rng)[0])
609-
cmd := roachtestutil.NewCommand("%s workload fixtures import bank", test.DefaultCockroachPath).
614+
cmd := roachtestutil.NewCommand("%s workload fixtures import bank", binary).
610615
Arg("{pgurl%s}", randomNode).
611616
Flag("payload-bytes", 10240).
612617
Flag("rows", bankRows).

0 commit comments

Comments
 (0)