Skip to content

Commit

Permalink
Merge #53579
Browse files Browse the repository at this point in the history
53579: roachtest: fix dump-backwards-compatability roachtest r=pbardea a=adityamaru

Elide the --insecure flag deprecation message until roachtest
is taught to run on a secure cluster.

Fixes: #53514, #53460

Release justification: non-production code changes

Co-authored-by: Aditya Maru <adityamaru@gmail.com>
  • Loading branch information
craig[bot] and adityamaru committed Aug 31, 2020
2 parents 0cb4247 + 9e3fcde commit ce1ef2a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,20 @@ func execCmdWithBuffer(ctx context.Context, l *logger, args ...string) ([]byte,
return out, nil
}

// execCmdWithStdout executes the given command and returns its stdout
// output. If the return code is not 0, an error is also returned.
// l is used to log the command before running it. No output is logged.
func execCmdWithStdout(ctx context.Context, l *logger, args ...string) ([]byte, error) {
l.Printf("> %s\n", strings.Join(args, " "))
cmd := exec.CommandContext(ctx, args[0], args[1:]...)

out, err := cmd.Output()
if err != nil {
return out, errors.Wrapf(err, `%s`, strings.Join(args, ` `))
}
return out, nil
}

func makeGCEClusterName(name string) string {
name = strings.ToLower(name)
name = regexp.MustCompile(`[^-a-z0-9]+`).ReplaceAllString(name, "-")
Expand Down Expand Up @@ -2283,6 +2297,18 @@ func (c *cluster) RunWithBuffer(
append([]string{roachprod, "run", c.makeNodes(node), "--"}, args...)...)
}

// RunWithStdout runs a command on the specified node, returning the resulting
// stdout.
func (c *cluster) RunWithStdout(
ctx context.Context, l *logger, node nodeListOption, args ...string,
) ([]byte, error) {
if err := errors.Wrap(ctx.Err(), "cluster.RunWithStdout"); err != nil {
return nil, err
}
return execCmdWithStdout(ctx, l,
append([]string{roachprod, "run", c.makeNodes(node), "--"}, args...)...)
}

// pgURL returns the Postgres endpoint for the specified node. It accepts a flag
// specifying whether the URL should include the node's internal or external IP
// address. In general, inter-cluster communication and should use internal IPs
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func runDump(nodes nodeListOption, mainVersion, expected string) versionStep {
return func(ctx context.Context, t *test, u *versionUpgradeTest) {
// Put the new version of Cockroach onto the node.
u.uploadVersion(ctx, t, nodes, mainVersion)
raw, err := u.c.RunWithBuffer(ctx, t.logger(), nodes, `./cockroach dump --insecure d`)
raw, err := u.c.RunWithStdout(ctx, t.logger(), nodes, `./cockroach dump --insecure d`)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit ce1ef2a

Please sign in to comment.