From 2a80007fa02c66e1d14b82030a600196598924c1 Mon Sep 17 00:00:00 2001 From: DarrylWong Date: Tue, 22 Oct 2024 15:45:45 -0400 Subject: [PATCH] roachtest: add validation for version binary override flag 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. --- pkg/cmd/roachtest/roachtestflags/flags.go | 2 +- pkg/cmd/roachtest/run.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/roachtest/roachtestflags/flags.go b/pkg/cmd/roachtest/roachtestflags/flags.go index 5761e7dc5102..5b6d65e1191f 100644 --- a/pkg/cmd/roachtest/roachtestflags/flags.go +++ b/pkg/cmd/roachtest/roachtestflags/flags.go @@ -365,7 +365,7 @@ var ( List of =. If a certain version 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 . Example: 20.1.4=cockroach-20.1,20.2.0=cockroach-20.2.`, + stage . Example: v20.1.4=cockroach-20.1,v20.2.0=cockroach-20.2.`, }) SlackToken string diff --git a/pkg/cmd/roachtest/run.go b/pkg/cmd/roachtest/run.go index 5f1e95592aa4..aaa1bfb840c5 100644 --- a/pkg/cmd/roachtest/run.go +++ b/pkg/cmd/roachtest/run.go @@ -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" @@ -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 }