Skip to content

Commit

Permalink
roachtest: replace bare goroutine in mixedversion test
Browse files Browse the repository at this point in the history
This change now utilises the Tasker interface supplied by the mixedversion
helper to start a task. In essence a background function can also be utilised,
but for low impact go routines the utility provides a quick way of starting a
task.

Informs: #118214

Epic: None
Release note: None
  • Loading branch information
herkolategan committed Oct 25, 2024
1 parent 8d00e98 commit b864657
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/roachtest/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ go_library(
"//pkg/cmd/roachtest/roachtestutil",
"//pkg/cmd/roachtest/roachtestutil/clusterupgrade",
"//pkg/cmd/roachtest/roachtestutil/mixedversion",
"//pkg/cmd/roachtest/roachtestutil/task",
"//pkg/cmd/roachtest/spec",
"//pkg/cmd/roachtest/test",
"//pkg/gossip",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/backup_restore_roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func backupRestoreRoundTrip(
// Run backups.
t.L().Printf("starting backup %d", i+1)
collection, err := d.createBackupCollection(
ctx, t.L(), testRNG, bspec, bspec, "round-trip-test-backup",
ctx, t.L(), t, testRNG, bspec, bspec, "round-trip-test-backup",
true /* internalSystemsJobs */, false, /* isMultitenant */
)
if err != nil {
Expand Down
14 changes: 9 additions & 5 deletions pkg/cmd/roachtest/tests/mixed_version_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/clusterupgrade"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/mixedversion"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/task"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/jobs"
Expand Down Expand Up @@ -1825,6 +1826,7 @@ func (d *BackupRestoreTestDriver) saveContents(
func (d *BackupRestoreTestDriver) runBackup(
ctx context.Context,
l *logger.Logger,
tasker task.Tasker,
rng *rand.Rand,
nodes option.NodeListOption,
pauseProbability float64,
Expand Down Expand Up @@ -1889,13 +1891,14 @@ func (d *BackupRestoreTestDriver) runBackup(
}

backupErr := make(chan error)
go func() {
tasker.Go(func(ctx context.Context, l *logger.Logger) error {
defer close(backupErr)
l.Printf("waiting for job %d (%s)", jobID, collection.name)
if err := d.testUtils.waitForJobSuccess(ctx, l, rng, jobID, internalSystemJobs); err != nil {
backupErr <- err
}
}()
return nil
})

var numPauses int
for {
Expand Down Expand Up @@ -1994,7 +1997,7 @@ func (mvb *mixedVersionBackup) createBackupCollection(
}

collection, err := mvb.backupRestoreTestDriver.createBackupCollection(
ctx, l, rng, fullBackupSpec, incBackupSpec, backupNamePrefix,
ctx, l, h, rng, fullBackupSpec, incBackupSpec, backupNamePrefix,
internalSystemJobs, h.IsMultitenant(),
)
if err != nil {
Expand All @@ -2013,6 +2016,7 @@ func (mvb *mixedVersionBackup) createBackupCollection(
func (d *BackupRestoreTestDriver) createBackupCollection(
ctx context.Context,
l *logger.Logger,
tasker task.Tasker,
rng *rand.Rand,
fullBackupSpec backupSpec,
incBackupSpec backupSpec,
Expand All @@ -2028,7 +2032,7 @@ func (d *BackupRestoreTestDriver) createBackupCollection(
if err := d.testUtils.runJobOnOneOf(ctx, l, fullBackupSpec.Execute.Nodes, func() error {
var err error
collection, fullBackupEndTime, err = d.runBackup(
ctx, l, rng, fullBackupSpec.Plan.Nodes, fullBackupSpec.PauseProbability,
ctx, l, tasker, rng, fullBackupSpec.Plan.Nodes, fullBackupSpec.PauseProbability,
fullBackup{backupNamePrefix}, internalSystemJobs, isMultitenant,
)
return err
Expand All @@ -2050,7 +2054,7 @@ func (d *BackupRestoreTestDriver) createBackupCollection(
if err := d.testUtils.runJobOnOneOf(ctx, l, incBackupSpec.Execute.Nodes, func() error {
var err error
collection, latestIncBackupEndTime, err = d.runBackup(
ctx, l, rng, incBackupSpec.Plan.Nodes, incBackupSpec.PauseProbability,
ctx, l, tasker, rng, incBackupSpec.Plan.Nodes, incBackupSpec.PauseProbability,
incrementalBackup{collection: collection, incNum: i + 1}, internalSystemJobs, isMultitenant,
)
return err
Expand Down

0 comments on commit b864657

Please sign in to comment.