Skip to content

Commit

Permalink
roachtest: add validation for version binary override flag
Browse files Browse the repository at this point in the history
Previously the help message for this flag had an incorrect example
usage that listed the version without the leading `v`. Doing this
would cause the override to never be used as the override checked
for version with the leading `v`.

This change fixes the usage message as well as adds validation that
overrided versions are parseable.
  • Loading branch information
DarrylWong committed Oct 22, 2024
1 parent 5eb9caf commit 2a80007
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/roachtestflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ var (
List of <version>=<path to cockroach binary>. If a certain version <ver>
is present in the list, the respective binary will be used when a
mixed-version test asks for the respective binary, instead of roachprod
stage <ver>. Example: 20.1.4=cockroach-20.1,20.2.0=cockroach-20.2.`,
stage <ver>. Example: v20.1.4=cockroach-20.1,v20.2.0=cockroach-20.2.`,
})

SlackToken string
Expand Down
7 changes: 7 additions & 0 deletions pkg/cmd/roachtest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/log/logpb"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/version"
"github.com/cockroachdb/errors"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -304,6 +305,12 @@ func initRunFlagsBinariesAndLibraries(cmd *cobra.Command) error {
if roachtestflags.SelectProbability > 0 && roachtestflags.SelectProbability < 1 {
fmt.Printf("Matching tests will be selected with probability %.2f\n", roachtestflags.SelectProbability)
}

for override := range roachtestflags.VersionsBinaryOverride {
if _, err := version.Parse(override); err != nil {
return errors.Wrapf(err, "binary version override %s is not a valid version", override)
}
}
return nil
}

Expand Down

0 comments on commit 2a80007

Please sign in to comment.