Skip to content

Commit

Permalink
bazel: make dev bench disable crdb_test
Browse files Browse the repository at this point in the history
crdb_test enables metamorphic variables and various "extra" debug
checking code paths that can interfere with performance testing. This
is also consistent with how make bench behaved.

If for whatever reason crdb_test is desirable the new flag
'--crdb-test-on' can be used.

If you want crdb_test on but no metamorphic variables the bazel test_env
argument can be used like so:

--test_env=COCKROACH_INTERNAL_DISABLE_METAMORPHIC_TESTING=true

Informs: cockroachdb#83599

Release note: None
  • Loading branch information
cucaroach committed Aug 15, 2022
1 parent 47dfddf commit c73d3e9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/cmd/dev/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
)

const (
benchTimeFlag = "bench-time"
benchMemFlag = "bench-mem"
benchTimeFlag = "bench-time"
benchMemFlag = "bench-mem"
crdbTestOnFlag = "crdb-test-on"
)

// makeBenchCmd constructs the subcommand used to run the specified benchmarks.
Expand Down Expand Up @@ -49,6 +50,7 @@ func makeBenchCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Com
benchCmd.Flags().Bool(benchMemFlag, false, "print memory allocations for benchmarks")
benchCmd.Flags().Bool(streamOutputFlag, false, "stream bench output during run")
benchCmd.Flags().String(testArgsFlag, "", "additional arguments to pass to go test binary")
benchCmd.Flags().Bool(crdbTestOnFlag, false, "run the benchmarks with crdb_test tag on")

return benchCmd
}
Expand All @@ -68,6 +70,7 @@ func (d *dev) bench(cmd *cobra.Command, commandLine []string) error {
benchMem = mustGetFlagBool(cmd, benchMemFlag)
streamOutput = mustGetFlagBool(cmd, streamOutputFlag)
testArgs = mustGetFlagString(cmd, testArgsFlag)
crdbTestOn = mustGetFlagBool(cmd, crdbTestOnFlag)
)

// Enumerate all benches to run.
Expand Down Expand Up @@ -153,8 +156,12 @@ func (d *dev) bench(cmd *cobra.Command, commandLine []string) error {
}
args = append(args, goTestArgs...)
}
if !crdbTestOn {
args = append(args, "--crdb_test_off")
}
args = append(args, d.getTestOutputArgs(false /* stress */, verbose, showLogs, streamOutput)...)
args = append(args, additionalBazelArgs...)
args = append(args)
logCommand("bazel", args...)
return d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...)
}

0 comments on commit c73d3e9

Please sign in to comment.