Skip to content

Commit

Permalink
docs and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Oct 21, 2020
1 parent faaec5d commit deb669b
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 81 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,31 @@ Flags:
--key= File containing client private key, to present to the server. Must also provide -cert option.
--cname= Server name override when validating TLS certificate - useful for self signed certs.
--skipTLS Skip TLS client verification of the server's certificate chain and host name.
--skipFirst=0 Skip the first X requests from the timing calculations (useful for initial warmup)
--insecure Use plaintext and insecure connection.
--authority= Value to be used as the :authority pseudo-header. Only works if -insecure is used.
-c, --concurrency=50 Number of requests to run concurrently. Total number of requests cannot be smaller than the concurrency level. Default is 50.
--async Make requests asynchronous as soon as possible. Does not wait for request to finish before sending next one.
-q, --qps=0 Queries per second (QPS) rate limit for constant load schedule. Default is no rate limit.
--load-schedule="const" Specifies the load schedule. Options are const, step, or line. Default is const.
--load-start=0 Specifies the qps load start value for step or line schedules.
--load-step=0 Specifies the load step value or slope value.
--load-end=0 Specifies the load end value for step or line load schedules.
--load-step-duration=0 Specifies the load step duration value for step load schedule.
--load-max-duration=0 Specifies the max load duration value for step or line load schedule.
-c, --concurrency=50 Number of request workers to run concurrently for const concurrency schedule. Default is 50.
--concurrency-schedule="const"
Concurrency change schedule. Options are const, step, or line. Default is const.
--concurrency-start=0 Concurrency start value for step and line concurrency schedules.
--concurrency-end=0 Concurrency end value for step and line concurrency schedules.
--concurrency-step=1 Concurrency step / slope value for step and line concurrency schedules.
--concurrency-step-duration=0
Specifies the concurrency step duration value for step concurrency schedule.
--concurrency-max-duration=0
Specifies the max concurrency adjustment duration value for step or line concurrency schedule.
-n, --total=200 Number of requests to run. Default is 200.
-q, --qps=0 Rate limit, in queries per second (QPS). Default is no rate limit.
-t, --timeout=20s Timeout for each request. Default is 20s, use 0 for infinite.
-z, --duration=0 Duration of application to send requests. When duration is reached, application stops and exits. If duration is specified, n is ignored. Examples: -z 10s -z 3m.
-x, --max-duration=0 Maximum duration of application to send requests with n setting respected. If duration is reached before n requests are completed, application stops and exits. Examples: -x 10s -x 3m.
--duration-stop="close" Specifies how duration stop is reported. Options are close, wait or ignore.
--duration-stop="close" Specifies how duration stop is reported. Options are close, wait or ignore. Default is close.
-d, --data= The call data as stringified JSON. If the value is '@' then the request contents are read from stdin.
-D, --data-file= File path for call data JSON file. Examples: /home/user/file.json or ./file.json.
-b, --binary The call data comes as serialized binary message or multiple count-prefixed messages read from stdin.
Expand All @@ -90,6 +105,7 @@ Flags:
--reflect-metadata= Reflect metadata as stringified JSON used only for reflection request.
-o, --output= Output path. If none provided stdout is used.
-O, --format= Output format. One of: summary, csv, json, pretty, html, influx-summary, influx-details. Default is summary.
--skipFirst=0 Skip the first X requests when doing the results tally.
--connections=1 Number of connections to use. Concurrency is distributed evenly among all the connections. Default is 1.
--connect-timeout=10s Connection timeout for the initial connection dial. Default is 10s.
--keepalive=0 Keepalive time duration. Only used if present and above 0.
Expand Down
32 changes: 16 additions & 16 deletions cmd/ghz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ var (
skipVerify = kingpin.Flag("skipTLS", "Skip TLS client verification of the server's certificate chain and host name.").
Default("false").IsSetByUser(&isSkipSet).Bool()

isSkipFirstSet = false
skipFirst = kingpin.Flag("skipFirst", "Skip the first X requests when doing the results tally.").
Default("0").IsSetByUser(&isSkipFirstSet).Uint()

isInsecSet = false
insecure = kingpin.Flag("insecure", "Use plaintext and insecure connection.").
Default("false").IsSetByUser(&isInsecSet).Bool()
Expand Down Expand Up @@ -118,13 +114,13 @@ var (
cschdule = kingpin.Flag("concurrency-schedule", "Concurrency change schedule. Options are const, step, or line. Default is const.").
Default("const").IsSetByUser(&isCScheduleSet).String()

isCMinSet = false
cmin = kingpin.Flag("concurrency-min", "Concurrency minimum / start value for step and line concurrency schedules.").
Default("0").IsSetByUser(&isCMinSet).Uint()
isCStartSet = false
cStart = kingpin.Flag("concurrency-start", "Concurrency start value for step and line concurrency schedules.").
Default("0").IsSetByUser(&isCStartSet).Uint()

isCMaxSet = false
cmax = kingpin.Flag("concurrency-max", "Concurrency maximum / end value for step and line concurrency schedules.").
Default("0").IsSetByUser(&isCMaxSet).Uint()
isCEndSet = false
cEnd = kingpin.Flag("concurrency-end", "Concurrency end value for step and line concurrency schedules.").
Default("0").IsSetByUser(&isCEndSet).Uint()

isCStepSet = false
cstep = kingpin.Flag("concurrency-step", "Concurrency step / slope value for step and line concurrency schedules.").
Expand Down Expand Up @@ -201,6 +197,10 @@ var (
format = kingpin.Flag("format", "Output format. One of: summary, csv, json, pretty, html, influx-summary, influx-details. Default is summary.").
Short('O').Default("summary").PlaceHolder(" ").IsSetByUser(&isFormatSet).Enum("summary", "csv", "json", "pretty", "html", "influx-summary", "influx-details")

isSkipFirstSet = false
skipFirst = kingpin.Flag("skipFirst", "Skip the first X requests when doing the results tally.").
Default("0").IsSetByUser(&isSkipFirstSet).Uint()

// Connection
isConnSet = false
conns = kingpin.Flag("connections", "Number of connections to use. Concurrency is distributed evenly among all the connections. Default is 1.").
Expand Down Expand Up @@ -446,9 +446,9 @@ func createConfigFromArgs(cfg *runner.Config) error {
cfg.LoadMaxDuration = runner.Duration(*loadMaxDuration)
cfg.Async = *async
cfg.CSchedule = *cschdule
cfg.CMin = *cmin
cfg.CStart = *cStart
cfg.CStep = *cstep
cfg.CMax = *cmax
cfg.CEnd = *cEnd
cfg.CStepDuration = runner.Duration(*cStepDuration)
cfg.CMaxDuration = runner.Duration(*cMaxDuration)

Expand Down Expand Up @@ -654,16 +654,16 @@ func mergeConfig(dest *runner.Config, src *runner.Config) error {
dest.CSchedule = src.CSchedule
}

if isCMinSet {
dest.CMin = src.CMin
if isCStartSet {
dest.CStart = src.CStart
}

if isCStepSet {
dest.CStep = src.CStep
}

if isCMaxSet {
dest.CMax = src.CMax
if isCEndSet {
dest.CEnd = src.CEnd
}

if isCStepDurSet {
Expand Down
4 changes: 2 additions & 2 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ type Config struct {
Async bool `json:"async,omitempty" toml:"async,omitempty" yaml:"async,omitempty"`
C uint `json:"concurrency" toml:"concurrency" yaml:"concurrency" default:"50"`
CSchedule string `json:"concurrency-schedule" toml:"concurrency-schedule" yaml:"concurrency-schedule" default:"const"`
CMin uint `json:"concurrency-min" toml:"concurrency-min" yaml:"concurrency-min" default:"1"`
CMax uint `json:"concurrency-max" toml:"concurrency-max" yaml:"concurrency-max" default:"0"`
CStart uint `json:"concurrency-start" toml:"concurrency-start" yaml:"concurrency-start" default:"1"`
CEnd uint `json:"concurrency-end" toml:"concurrency-end" yaml:"concurrency-end" default:"0"`
CStep int `json:"concurrency-step" toml:"concurrency-step" yaml:"concurrency-step" default:"0"`
CStepDuration Duration `json:"concurrency-step-duration" toml:"concurrency-step-duration" yaml:"concurrency-step-duration" default:"0"`
CMaxDuration Duration `json:"concurrency-max-duration" toml:"concurrency-max-duration" yaml:"concurrency-max-duration" default:"0"`
Expand Down
2 changes: 1 addition & 1 deletion runner/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestConfig_Load(t *testing.T) {
DialTimeout: Duration(10 * time.Second),
LoadSchedule: "const",
CSchedule: "const",
CMin: 1,
CStart: 1,
},
true,
},
Expand Down
37 changes: 23 additions & 14 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ type RunConfig struct {

// concurrency
c int
cMin uint
cMax uint
cStart uint
cEnd uint
cStep int
cSchedule string
cMaxDuration time.Duration
Expand Down Expand Up @@ -655,18 +655,26 @@ func NewConfig(call, host string, options ...Option) (*RunConfig, error) {
if c.loadStep == 0 {
return nil, errors.New("invalid load step")
}

if c.loadSchedule == ScheduleStep && c.loadStepDuration == 0 {
return nil, errors.New("invalid load step duration")
}
}

if c.cSchedule == ScheduleStep || c.cSchedule == ScheduleLine {
if c.cMin == c.cMax {
return nil, errors.New("concurrency min start cannot equal concurrency max")
if c.cStart == c.cEnd {
return nil, errors.New("concurrency start start cannot equal concurrency end")
}

// step value for step schedule or
// slope for line schedule
if c.cStep == 0 {
return nil, errors.New("invalid concurrency step")
}

if c.cSchedule == ScheduleStep && c.cStepDuration == 0 {
return nil, errors.New("invalid concurrency step duration")
}
}

if c.loadSchedule == ScheduleLine {
Expand Down Expand Up @@ -791,21 +799,21 @@ func WithConcurrencySchedule(schedule string) Option {
}
}

// WithConcurrencyMin specifies the concurrency minimum for line or step schedule
// WithConcurrencyMin(5)
func WithConcurrencyMin(min uint) Option {
// WithConcurrencyStart specifies the concurrency start for line or step schedule
// WithConcurrencyStart(5)
func WithConcurrencyStart(v uint) Option {
return func(o *RunConfig) error {
o.cMin = min
o.cStart = v

return nil
}
}

// WithConcurrencyMax specifies the concurrency maximum value for line or step schedule
// WithConcurrencyMax(25)
func WithConcurrencyMax(max uint) Option {
// WithConcurrencyEnd specifies the concurrency end value for line or step schedule
// WithConcurrencyEnd(25)
func WithConcurrencyEnd(v uint) Option {
return func(o *RunConfig) error {
o.cMax = max
o.cEnd = v

return nil
}
Expand Down Expand Up @@ -921,8 +929,8 @@ func fromConfig(cfg *Config) []Option {
WithLoadDuration(time.Duration(cfg.LoadMaxDuration)),
WithAsync(cfg.Async),
WithConcurrencySchedule(cfg.CSchedule),
WithConcurrencyMin(cfg.CMin),
WithConcurrencyMax(cfg.CMax),
WithConcurrencyStart(cfg.CStart),
WithConcurrencyEnd(cfg.CEnd),
WithConcurrencyStep(cfg.CStep),
WithConcurrencyStepDuration(time.Duration(cfg.CStepDuration)),
WithConcurrencyDuration(time.Duration(cfg.CMaxDuration)),
Expand Down Expand Up @@ -956,5 +964,6 @@ func fromConfig(cfg *Config) []Option {
if len(cfg.BinDataPath) > 0 {
options = append(options, WithBinaryDataFromFile(cfg.BinDataPath))
}

return options
}
24 changes: 12 additions & 12 deletions runner/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, uint(10), c.loadStart)
assert.Equal(t, uint(20), c.loadEnd)
assert.Equal(t, 20*time.Second, c.loadDuration)
assert.Equal(t, uint(5), c.loadStep)
assert.Equal(t, 5, c.loadStep)
assert.Equal(t, 5*time.Second, c.loadStepDuration)
})
})
Expand Down Expand Up @@ -552,7 +552,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, uint(0), c.loadStart)
assert.Equal(t, uint(20), c.loadEnd)
assert.Equal(t, 20*time.Second, c.loadDuration)
assert.Equal(t, uint(2), c.loadStep)
assert.Equal(t, 2, c.loadStep)
assert.Equal(t, 1*time.Second, c.loadStepDuration)
})
})
Expand All @@ -572,19 +572,19 @@ func TestRunConfig_newRunConfig(t *testing.T) {
WithProtoFile("testdata/data.proto", []string{}),
WithConcurrencySchedule(ScheduleStep),
WithConcurrencyStep(5),
WithConcurrencyMin(10),
WithConcurrencyStart(10),
WithConcurrencyDuration(20*time.Second),
WithConcurrencyStepDuration(5*time.Second),
WithConcurrencyMax(20),
WithConcurrencyEnd(20),
)

assert.NoError(t, err)

assert.Equal(t, ScheduleStep, c.cSchedule)
assert.Equal(t, uint(10), c.cMin)
assert.Equal(t, uint(20), c.cMax)
assert.Equal(t, uint(10), c.cStart)
assert.Equal(t, uint(20), c.cEnd)
assert.Equal(t, 20*time.Second, c.cMaxDuration)
assert.Equal(t, uint(5), c.cStep)
assert.Equal(t, 5, c.cStep)
assert.Equal(t, 5*time.Second, c.cStepDuration)
})
})
Expand All @@ -604,19 +604,19 @@ func TestRunConfig_newRunConfig(t *testing.T) {
WithProtoFile("testdata/data.proto", []string{}),
WithConcurrencySchedule(ScheduleLine),
WithConcurrencyStep(2),
WithConcurrencyMin(5),
WithConcurrencyStart(5),
WithConcurrencyDuration(20*time.Second),
WithConcurrencyStepDuration(5*time.Second), // overwritten
WithConcurrencyMax(20),
WithConcurrencyEnd(20),
)

assert.NoError(t, err)

assert.Equal(t, ScheduleLine, c.cSchedule)
assert.Equal(t, uint(5), c.cMin)
assert.Equal(t, uint(20), c.cMax)
assert.Equal(t, uint(5), c.cStart)
assert.Equal(t, uint(20), c.cEnd)
assert.Equal(t, 20*time.Second, c.cMaxDuration)
assert.Equal(t, uint(2), c.cStep)
assert.Equal(t, 2, c.cStep)
assert.Equal(t, 1*time.Second, c.cStepDuration)
})
})
Expand Down
8 changes: 4 additions & 4 deletions runner/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,17 +474,17 @@ func createWorkerTicker(config *RunConfig) load.WorkerTicker {
case ScheduleLine:
wt = &load.LineWorkerTicker{
C: make(chan load.TickValue),
Start: config.cMin,
Start: config.cStart,
Slope: config.cStep,
Stop: config.cMax,
Stop: config.cEnd,
LoadDuration: config.cMaxDuration,
}
case ScheduleStep:
wt = &load.StepWorkerTicker{
C: make(chan load.TickValue),
Start: config.cMin,
Start: config.cStart,
Step: config.cStep,
Stop: config.cMax,
Stop: config.cEnd,
StepDuration: config.cStepDuration,
LoadDuration: config.cMaxDuration,
}
Expand Down
Loading

0 comments on commit deb669b

Please sign in to comment.