Skip to content

Commit

Permalink
Allow skip and remove superfluous threads warning in test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpt-erikgeiser committed Jul 12, 2023
1 parent 85bbc02 commit 586d0ee
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions cmd/fuzz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
"golang.org/x/sync/errgroup"
)

const (
defaultNumberOfThreads = 5
defaultBufferSize = 100000
)

// Options collect options for a run.

type Options struct {
Expand Down Expand Up @@ -168,25 +173,19 @@ func (opts *Options) valid() (err error) {
var ignoredOptions []string

if opts.IsTest {
if opts.Threads > 0 {
if opts.Threads != defaultNumberOfThreads {
ignoredOptions = append(ignoredOptions, "threads")
}

if opts.RequestsPerSecond > 0 {
ignoredOptions = append(ignoredOptions, "requests-per-second")
}

if opts.Skip > 0 {
ignoredOptions = append(ignoredOptions, "skip")
}

if opts.Limit > 0 {
if opts.Limit < 0 || opts.Limit > 1 {
ignoredOptions = append(ignoredOptions, "limit")
}

opts.Limit = 1
opts.Skip = 0

if len(opts.Values) > 0 {
opts.Limit = len(opts.Values)
}
Expand Down Expand Up @@ -246,8 +245,8 @@ func AddCommand(c *cobra.Command) {
fs.StringVar(&opts.Logfile, "logfile", "", "write copy of printed messages to `filename`.log")
fs.StringVar(&opts.Logdir, "logdir", os.Getenv("MONSOON_LOG_DIR"), "automatically log all output to files in `dir`")

fs.IntVarP(&opts.Threads, "threads", "t", 5, "make as many as `n` parallel requests")
fs.IntVar(&opts.BufferSize, "buffer-size", 100000, "set number of buffered items to `n`")
fs.IntVarP(&opts.Threads, "threads", "t", defaultNumberOfThreads, "make as many as `n` parallel requests")
fs.IntVar(&opts.BufferSize, "buffer-size", defaultBufferSize, "set number of buffered items to `n`")
fs.IntVar(&opts.Skip, "skip", 0, "skip the first `n` requests")
fs.IntVar(&opts.Limit, "limit", 0, "only run `n` requests, then exit")
fs.Float64Var(&opts.RequestsPerSecond, "requests-per-second", 0, "do at most `n` requests per second (e.g. 0.5)")
Expand Down

0 comments on commit 586d0ee

Please sign in to comment.