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: replace roachtest run --dry-run #30994

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

andreimatei
Copy link
Contributor

... with a dedicated roachtest list.
The dryrun argument was polluting and indenting the code.

Release note: None

@andreimatei
Copy link
Contributor Author

The first commit is #30146.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unfortunately removes functionality: roachtest run -n vs roachtest bench -n.

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/cmd/roachtest/main.go, line 43 at r2 (raw file):

				return fmt.Errorf("cannot specify both an existing cluster (%s) and --local", clusterName)
			}
			if !dryrun {

This was useful, though, as it prevented trying to find the roachprod and workload binaries if you weren't running a test. I think you'll want to refactor where initBinaries is performed so that it is only done if we're actually running tests.

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roachtest bench... who knew. Added roachtest list --bench.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/cmd/roachtest/main.go, line 43 at r2 (raw file):

Previously, petermattis (Peter Mattis) wrote…

This was useful, though, as it prevented trying to find the roachprod and workload binaries if you weren't running a test. I think you'll want to refactor where initBinaries is performed so that it is only done if we're actually running tests.

good catch. I left it here, but made it conditional on the command.

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is good that you got rid of the dryrun variable infecting the run implementation. But I'm less thrilled about the user ergonomics of list and list --bench. A --dry-run flag is reasonably common in tools. Did you consider leaving the flag in place, but changing the implementation to be similar to what you've implemented for listCmd? That is, the runCmd function would contain something like:

if dryrun {
	names := r.ListAll(args)
	for _, name := range names {
		fmt.Println(name)
	}
} else {
	os.Exit(r.Run(args))
}

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/cmd/roachtest/main.go, line 48 at r4 (raw file):

				"store-gen": {},
			}
			if _, ok := needsBinaries[cmd.Name()]; ok {

Nit: I think this is cleaner as a switch:

switch cmd.Name() {
case "run", "bench", "store-gen":
  initBinaries()
}

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have considered it.
--dry-run may be common enough for simple tools, but I don't think roachtest qualifies (particularly as I'm trying to make it more complex). This tool should allocate a cluster pool, then run tests through a scheduler. Were a --dry-run to exist, it'd be unclear (to me as a user) what parts should run and what parts shouldn't: how would it interact with the --parallelism and --count flags, for example?
Also, through the run() decontamination, I've also changed the output format of list/--dry-run - it no longer prints stuff like [PASS] which is a big deal as far as expectations from this tool go.
Basically, to quote a living classic, to consider --dry-run making sense with run I have to squint so hard my eyes would be closed.

Having said all this, I'll change it if you insist.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about --dry-run and you raise good points. Another approach would be to replace --dry-run with --list. That is run --list, bench --list, etc. Feel free to ignore this suggestion.

:lgtm:

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I... still prefer a top-level command (particularly as you have a good suggestion elsewhere about also optionally printing the cluster spec for each test, which I might do).

Merging on Monday.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/cmd/roachtest/main.go, line 48 at r4 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Nit: I think this is cleaner as a switch:

switch cmd.Name() {
case "run", "bench", "store-gen":
  initBinaries()
}

done

... with a dedicated `roachtest list`.
The dryrun argument was polluting and indenting the code.

Release note: None
Copy link
Contributor Author

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

craig bot pushed a commit that referenced this pull request Oct 8, 2018
30994: roachtest: replace roachtest run --dry-run r=andreimatei a=andreimatei

... with a dedicated `roachtest list`.
The dryrun argument was polluting and indenting the code.

Release note: None

Co-authored-by: Andrei Matei <[email protected]>
@craig
Copy link
Contributor

craig bot commented Oct 8, 2018

Build succeeded

@craig craig bot merged commit 3f14d9a into cockroachdb:master Oct 8, 2018
@andreimatei andreimatei deleted the roachtest-dryrun branch October 8, 2018 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants