Skip to content

Commit eae0537

Browse files
committed
roachtest: add --cockroach-stage flag for remote binary staging
Add --cockroach-stage flag that stages binaries directly from cloud storage instead of uploading local files. The flag accepts version/SHA values like "latest", "v23.2.0", or commit SHAs, is mutually exclusive with --cockroach, and normalizes "latest" to empty string for proper .LATEST URL construction. Release note: none. Epic: none
1 parent c0934ae commit eae0537

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

pkg/cmd/roachtest/cluster.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,9 +1932,15 @@ func (c *clusterImpl) PutE(
19321932
}
19331933

19341934
// PutCockroach uploads a binary with or without runtime assertions enabled,
1935-
// as determined by t.Cockroach(). Note that we upload to all nodes even if they
1936-
// don't use the binary, so that the test runner can always fetch logs.
1935+
// as determined by t.Cockroach(). If --cockroach-stage flag is set, it stages
1936+
// the binary from cloud storage instead of uploading a local binary.
1937+
// Note that we upload/stage to all nodes even if they don't use the binary,
1938+
// so that the test runner can always fetch logs.
19371939
func (c *clusterImpl) PutCockroach(ctx context.Context, l *logger.Logger, t *testImpl) error {
1940+
if roachtestflags.CockroachStage != "" {
1941+
// Use staging instead of upload when --cockroach-stage is specified
1942+
return c.Stage(ctx, l, "cockroach", roachtestflags.CockroachStage, ".", c.All())
1943+
}
19381944
return c.PutE(ctx, l, t.Cockroach(), test.DefaultCockroachPath, c.All())
19391945
}
19401946

pkg/cmd/roachtest/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,16 @@ func validateAndConfigure(cmd *cobra.Command, args []string) {
573573
if roachtestflags.SelectiveTests && selectProbFlagInfo != nil {
574574
printErrAndExit(fmt.Errorf("select-probability and selective-tests=true are incompatible. Disable one of them"))
575575
}
576+
577+
// --cockroach and --cockroach-stage flags are mutually exclusive.
578+
cockroachFlagInfo := roachtestflags.Changed(&roachtestflags.CockroachPath)
579+
cockroachStageFlagInfo := roachtestflags.Changed(&roachtestflags.CockroachStage)
580+
if cockroachFlagInfo != nil && cockroachStageFlagInfo != nil {
581+
printErrAndExit(fmt.Errorf("--cockroach and --cockroach-stage are mutually exclusive. Use one or the other"))
582+
}
583+
584+
// Normalize "latest" to empty string for staging system
585+
if roachtestflags.CockroachStage == "latest" {
586+
roachtestflags.CockroachStage = ""
587+
}
576588
}

pkg/cmd/roachtest/roachtestflags/flags.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ var (
112112
Usage: `Absolute path to cockroach binary to use`,
113113
})
114114

115+
CockroachStage string
116+
_ = registerRunFlag(&CockroachStage, FlagInfo{
117+
Name: "cockroach-stage",
118+
Usage: `
119+
Stage cockroach binary from cloud storage instead of uploading local binary.
120+
Specify version/SHA (e.g., "latest", "v23.2.0", or commit SHA).
121+
Mutually exclusive with --cockroach.`,
122+
})
123+
115124
ConfigPath string
116125
_ = registerRunOpsFlag(&ConfigPath, FlagInfo{
117126
Name: "config",

0 commit comments

Comments
 (0)