Skip to content

Commit b63288a

Browse files
committed
cmd/roachtest: fix stage 'latest'
Previously we would change it to '' to pass it to Stage() but this meant validation of binary types saw an empty arg and assumed we were not staging, and thus still validated local binaries. Instead, leave the flag along and just zero a copy for passing to Stage(). Release note: none. Epic: none.
1 parent 3cb6e13 commit b63288a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

pkg/cmd/roachtest/cluster.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ func initBinariesAndLibraries() {
325325
cockroachPath := roachtestflags.CockroachPath
326326
cockroachEAPath := roachtestflags.CockroachEAPath
327327
workloadPath := roachtestflags.WorkloadPath
328-
cockroach[defaultArch], _ = resolveBinary("cockroach", cockroachPath, defaultArch, true, false)
328+
// Skip cockroach binary validation if using --cockroach-stage
329+
if roachtestflags.CockroachStage == "" {
330+
cockroach[defaultArch], _ = resolveBinary("cockroach", cockroachPath, defaultArch, true, false)
331+
}
329332
// Let the test runner verify the workload binary exists if TestSpec.RequiresDeprecatedWorkload is true.
330333
workload[defaultArch], _ = resolveBinary("workload", workloadPath, defaultArch, false, false)
331334
cockroachEA[defaultArch], err = resolveBinary("cockroach-ea", cockroachEAPath, defaultArch, false, true)
@@ -336,7 +339,9 @@ func initBinariesAndLibraries() {
336339
if roachtestflags.ARM64Probability > 0 && defaultArch != vm.ArchARM64 {
337340
fmt.Printf("Locating and verifying binaries for os=%q, arch=%q\n", defaultOSName, vm.ArchARM64)
338341
// We need to verify we have all the required binaries for arm64.
339-
cockroach[vm.ArchARM64], _ = resolveBinary("cockroach", cockroachPath, vm.ArchARM64, true, false)
342+
if roachtestflags.CockroachStage == "" {
343+
cockroach[vm.ArchARM64], _ = resolveBinary("cockroach", cockroachPath, vm.ArchARM64, true, false)
344+
}
340345
workload[vm.ArchARM64], _ = resolveBinary("workload", workloadPath, vm.ArchARM64, true, false)
341346
cockroachEA[vm.ArchARM64], err = resolveBinary("cockroach-ea", cockroachEAPath, vm.ArchARM64, false, true)
342347
if err != nil {
@@ -346,7 +351,9 @@ func initBinariesAndLibraries() {
346351
if roachtestflags.FIPSProbability > 0 && defaultArch != vm.ArchFIPS {
347352
fmt.Printf("Locating and verifying binaries for os=%q, arch=%q\n", defaultOSName, vm.ArchFIPS)
348353
// We need to verify we have all the required binaries for fips.
349-
cockroach[vm.ArchFIPS], _ = resolveBinary("cockroach", cockroachPath, vm.ArchFIPS, true, false)
354+
if roachtestflags.CockroachStage == "" {
355+
cockroach[vm.ArchFIPS], _ = resolveBinary("cockroach", cockroachPath, vm.ArchFIPS, true, false)
356+
}
350357
workload[vm.ArchFIPS], _ = resolveBinary("workload", workloadPath, vm.ArchFIPS, true, false)
351358
cockroachEA[vm.ArchFIPS], err = resolveBinary("cockroach-ea", cockroachEAPath, vm.ArchFIPS, false, true)
352359
if err != nil {
@@ -1939,7 +1946,11 @@ func (c *clusterImpl) PutE(
19391946
func (c *clusterImpl) PutCockroach(ctx context.Context, l *logger.Logger, t *testImpl) error {
19401947
if roachtestflags.CockroachStage != "" {
19411948
// Use staging instead of upload when --cockroach-stage is specified
1942-
return c.Stage(ctx, l, "cockroach", roachtestflags.CockroachStage, ".", c.All())
1949+
stageVersion := roachtestflags.CockroachStage
1950+
if stageVersion == "latest" {
1951+
stageVersion = "" // Stage() expects empty string for latest
1952+
}
1953+
return c.Stage(ctx, l, "cockroach", stageVersion, ".", c.All())
19431954
}
19441955
return c.PutE(ctx, l, t.Cockroach(), test.DefaultCockroachPath, c.All())
19451956
}

pkg/cmd/roachtest/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,4 @@ func validateAndConfigure(cmd *cobra.Command, args []string) {
581581
printErrAndExit(fmt.Errorf("--cockroach and --cockroach-stage are mutually exclusive. Use one or the other"))
582582
}
583583

584-
// Normalize "latest" to empty string for staging system
585-
if roachtestflags.CockroachStage == "latest" {
586-
roachtestflags.CockroachStage = ""
587-
}
588584
}

0 commit comments

Comments
 (0)