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: remove './cockroach sql' incantations from restore roachtests #106216

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions pkg/cmd/roachtest/tests/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ func (rd *restoreDriver) getAOST(ctx context.Context) {
}

func (rd *restoreDriver) restoreCmd(target, opts string) string {
return fmt.Sprintf(`./cockroach sql --insecure -e "RESTORE %s FROM %s IN %s AS OF SYSTEM TIME '%s' %s"`,
return fmt.Sprintf(`RESTORE %s FROM %s IN %s AS OF SYSTEM TIME '%s' %s`,
target, rd.sp.backup.fullBackupDir, rd.sp.backup.backupCollection(), rd.aost, opts)
}

Expand All @@ -838,20 +838,25 @@ func (rd *restoreDriver) restoreCmd(target, opts string) string {
// - "DATABASE tpce" will execute a database restore on the tpce cluster.
// - "" will execute a cluster restore.
func (rd *restoreDriver) run(ctx context.Context, target string) error {
return rd.c.RunE(ctx, rd.c.Node(1), rd.restoreCmd(target, ""))
conn, err := rd.c.ConnE(ctx, rd.t.L(), 1)
if err != nil {
return errors.Wrapf(err, "failed to connect to node 1; running restore")
}
_, err = conn.ExecContext(ctx, rd.restoreCmd(target, ""))
return err
}

func (rd *restoreDriver) runDetached(
ctx context.Context, target string, node int,
) (jobspb.JobID, error) {
if err := rd.c.RunE(ctx, rd.c.Node(node), rd.restoreCmd(target, "WITH DETACHED")); err != nil {
return 0, err
}

db, err := rd.c.ConnE(ctx, rd.t.L(), rd.c.Node(node)[0])
if err != nil {
return 0, errors.Wrapf(err, "failed to connect to node %d; running restore detached", node)
}
if _, err = db.ExecContext(ctx, rd.restoreCmd(target,
"WITH DETACHED")); err != nil {
return 0, err
}
var jobID jobspb.JobID
if err := db.QueryRow(`SELECT job_id FROM [SHOW JOBS] WHERE job_type = 'RESTORE'`).Scan(&jobID); err != nil {
return 0, err
Expand Down