Skip to content

Commit

Permalink
Merge #119858
Browse files Browse the repository at this point in the history
119858: roachtest: restore: restart nodes with same options r=msbutler a=stevendanna

Fixes #119802
Fixes #119803

Release note: None

Co-authored-by: Steven Danna <[email protected]>
  • Loading branch information
craig[bot] and stevendanna committed Mar 11, 2024
2 parents fcf0b5a + e633dd8 commit 41a474f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
19 changes: 11 additions & 8 deletions pkg/cmd/roachtest/tests/jobs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,7 @@ type jobStarter func(c cluster.Cluster, l *logger.Logger) (jobspb.JobID, error)
func jobSurvivesNodeShutdown(
ctx context.Context, t test.Test, c cluster.Cluster, nodeToShutdown int, startJob jobStarter,
) {
cfg := nodeShutdownConfig{
shutdownNode: nodeToShutdown,
watcherNode: 1 + (nodeToShutdown)%c.Spec().NodeCount,
crdbNodes: c.All(),
waitFor3XReplication: true,
sleepBeforeShutdown: 30 * time.Second,
}
require.NoError(t, executeNodeShutdown(ctx, t, c, cfg, startJob))
require.NoError(t, executeNodeShutdown(ctx, t, c, defaultNodeShutdownConfig(c, nodeToShutdown), startJob))
}

type nodeShutdownConfig struct {
Expand All @@ -70,6 +63,16 @@ type nodeShutdownConfig struct {
rng *rand.Rand
}

func defaultNodeShutdownConfig(c cluster.Cluster, nodeToShutdown int) nodeShutdownConfig {
return nodeShutdownConfig{
shutdownNode: nodeToShutdown,
watcherNode: 1 + (nodeToShutdown)%c.Spec().NodeCount,
crdbNodes: c.All(),
waitFor3XReplication: true,
sleepBeforeShutdown: 30 * time.Second,
}
}

// executeNodeShutdown executes a node shutdown and returns all errors back to the caller.
//
// TODO(msbutler): ideally, t.L() is only passed to this function instead of t,
Expand Down
35 changes: 26 additions & 9 deletions pkg/cmd/roachtest/tests/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ func registerRestoreNodeShutdown(r registry.Registry) {

rd := makeRestoreDriver(t, c, sp)
rd.prepareCluster(ctx)
jobSurvivesNodeShutdown(ctx, t, c, nodeToShutdown, makeRestoreStarter(ctx, t, c,
gatewayNode, rd))
cfg := defaultNodeShutdownConfig(c, nodeToShutdown)
cfg.restartSettings = rd.defaultClusterSettings()
require.NoError(t,
executeNodeShutdown(ctx, t, c, cfg,
makeRestoreStarter(ctx, t, c, gatewayNode, rd)))
rd.checkFingerprint(ctx)
},
})
Expand All @@ -96,15 +99,16 @@ func registerRestoreNodeShutdown(r registry.Registry) {
Leases: registry.MetamorphicLeases,
Timeout: sp.timeout,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {

gatewayNode := 2
nodeToShutdown := 2

rd := makeRestoreDriver(t, c, sp)
rd.prepareCluster(ctx)

jobSurvivesNodeShutdown(ctx, t, c, nodeToShutdown, makeRestoreStarter(ctx, t, c,
gatewayNode, rd))
cfg := defaultNodeShutdownConfig(c, nodeToShutdown)
cfg.restartSettings = rd.defaultClusterSettings()
require.NoError(t,
executeNodeShutdown(ctx, t, c, cfg,
makeRestoreStarter(ctx, t, c, gatewayNode, rd)))
rd.checkFingerprint(ctx)
},
})
Expand Down Expand Up @@ -881,10 +885,23 @@ func makeRestoreDriver(t test.Test, c cluster.Cluster, sp restoreSpecs) restoreD
}
}

func (rd *restoreDriver) prepareCluster(ctx context.Context) {
func (rd *restoreDriver) defaultClusterSettings() []install.ClusterSettingOption {
return []install.ClusterSettingOption{
install.SecureOption(false),
}
}

func (rd *restoreDriver) roachprodOpts() option.StartOpts {
opts := option.DefaultStartOptsNoBackups()
opts.RoachprodOpts.ExtraArgs = rd.sp.extraArgs
rd.c.Start(ctx, rd.t.L(), opts, install.MakeClusterSettings(install.SecureOption(false)), rd.sp.hardware.getCRDBNodes())
opts.RoachprodOpts.ExtraArgs = append(opts.RoachprodOpts.ExtraArgs, rd.sp.extraArgs...)
return opts
}

func (rd *restoreDriver) prepareCluster(ctx context.Context) {
rd.c.Start(ctx, rd.t.L(),
rd.roachprodOpts(),
install.MakeClusterSettings(rd.defaultClusterSettings()...),
rd.sp.hardware.getCRDBNodes())
rd.getAOST(ctx)
}

Expand Down

0 comments on commit 41a474f

Please sign in to comment.