Skip to content

Commit

Permalink
use default value for number of shards
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Oct 9, 2024
1 parent 74b891b commit d5ec837
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions go/cmd/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

func testerCmd() *cobra.Command {
var cfg vttester.Config
var numberOfShards int

cmd := &cobra.Command{
Use: "tester ",
Expand All @@ -33,9 +32,6 @@ func testerCmd() *cobra.Command {
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
cfg.Tests = args
if cmd.Flags().Changed("number-of-shards") {
cfg.NumberOfShards = &numberOfShards
}
vttester.Run(cfg)
},
}
Expand All @@ -48,7 +44,7 @@ func testerCmd() *cobra.Command {
cmd.Flags().BoolVar(&cfg.OLAP, "olap", false, "Use OLAP to run the queries.")
cmd.Flags().BoolVar(&cfg.XUnit, "xunit", false, "Get output in an xml file instead of errors directory")
cmd.Flags().BoolVar(&cfg.Sharded, "sharded", false, "Run all tests on a sharded keyspace and using auto-vschema. This cannot be used with either -vschema or -vtexplain-vschema.")
cmd.Flags().IntVar(&numberOfShards, "number-of-shards", 0, "Number of shards to use for the sharded keyspace.")
cmd.Flags().IntVar(&cfg.NumberOfShards, "number-of-shards", 0, "Number of shards to use for the sharded keyspace.")

return cmd
}
8 changes: 4 additions & 4 deletions go/tester/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ type Config struct {
VtExplainVschemaFile string
TraceFile string
Tests []string
NumberOfShards *int
NumberOfShards int
}

func (cfg Config) GetNumberOfShards() int {
if cfg.NumberOfShards == nil {
if cfg.NumberOfShards == 0 {
return 2
}
return *cfg.NumberOfShards
return cfg.NumberOfShards
}

func Run(cfg Config) {
Expand All @@ -59,7 +59,7 @@ func Run(cfg Config) {
os.Exit(1)
}

if cfg.NumberOfShards != nil && !(cfg.Sharded || cfg.VschemaFile != "" || cfg.VtExplainVschemaFile != "") {
if cfg.NumberOfShards > 0 && !(cfg.Sharded || cfg.VschemaFile != "" || cfg.VtExplainVschemaFile != "") {
log.Errorf("number-of-shards can only be used with -sharded, -vschema or -vtexplain-vschema")
os.Exit(1)
}
Expand Down

0 comments on commit d5ec837

Please sign in to comment.