Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI flags #80

Merged
merged 7 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 43 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,49 @@ All documentation at [ghz.sh](https://ghz.sh).

## Usage

```sh
Usage: ghz [options...] host
Options:

-config Path to the JSON or TOML config file that specifies all the test run settings.

-proto The Protocol Buffer .proto file.
-protoset The compiled protoset file. Alternative to proto. -proto takes precedence.
-call A fully-qualified method name in 'package.Service/method' or 'package.Service.Method' format.
-i Comma separated list of proto import paths. The current working directory and the directory
of the protocol buffer file are automatically added to the import list.
-rmd Reflect metadata as stringified JSON used only for reflection request.

-cacert File containing trusted root certificates for verifying the server.
-cert File containing client certificate (public key), to present to the server. Must also provide -key option.
-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.
-insecure Use plaintext and insecure connection.
-authority Value to be used as the :authority pseudo-header. Only works if -insecure is used.

-c Number of requests to run concurrently.
Total number of requests cannot be smaller than the concurrency level. Default is 50.
-n Number of requests to run. Default is 200.
-q Rate limit, in queries per second (QPS). Default is no rate limit.
-t Timeout for each request in seconds. Default is 20, use 0 for infinite.
-z 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 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.

-d The call data as stringified JSON.
If the value is '@' then the request contents are read from stdin.
-D Path for call data JSON file. Examples: /home/user/file.json or ./file.json.
-b The call data comes as serialized binary message read from stdin.
-B Path for the call data as serialized binary message.
-m Request metadata as stringified JSON.
-M Path for call metadata JSON file. Examples: /home/user/metadata.json or ./metadata.json.

-si Stream interval duration. Spread stream sends by given amount.
Only applies to client and bidi streaming calls. Example: 100ms

-o Output path. If none provided stdout is used.
-O Output type. If none provided, a summary is printed.
"csv" outputs the response metrics in comma-separated values format.
"json" outputs the metrics report in JSON format.
"pretty" outputs the metrics report in pretty JSON format.
"html" outputs the metrics report as HTML.
"influx-summary" outputs the metrics summary as influxdb line protocol.
"influx-details" outputs the metrics details as influxdb line protocol.

-T Connection timeout in seconds for the initial connection dial. Default is 10.
-L Keepalive time in seconds. Only used if present and above 0.

-name User specified name for the test.
-tags JSON representation of user-defined string tags.

-cpus Number of used cpu cores.

-v Print the version.
```
usage: ghz [<flags>] [<host>]

Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--config= Path to the JSON or TOML config file that specifies all the test run settings.
--proto= The Protocol Buffer .proto file.
--protoset= The compiled protoset file. Alternative to proto. -proto takes precedence.
--call= A fully-qualified method name in 'package.Service/method' or 'package.Service.Method' format.
-i, --import-paths= Comma separated list of proto import paths. The current working directory and the directory of the protocol buffer file are automatically added to the import list.
--cacert= File containing trusted root certificates for verifying the server.
--cert= File containing client certificate (public key), to present to the server. Must also provide -key option.
--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.
--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.
-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=20 Timeout for each request in seconds. Default is 20, 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.
-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 read from stdin.
-B, --binary-file= File path for the call data as serialized binary message.
-m, --metadata= Request metadata as stringified JSON.
-M, --metadata-file= File path for call metadata JSON file. Examples: /home/user/metadata.json or ./metadata.json.
--stream-interval=0 Interval for stream requests between message sends.
--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. If none provided, a summary is printed.
--connect-timeout=10 Connection timeout in seconds for the initial connection dial. Default is 10.
--keepalive=0 Keepalive time in seconds. Only used if present and above 0.
--name= User specified name for the test.
--tags= JSON representation of user-defined string tags.
--cpus=8 Number of cpu cores to use.
-v, --version Show application version.

Args:
[<host>] Host and port to test.
```

## Go Package
Expand Down
38 changes: 19 additions & 19 deletions cmd/ghz/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,29 @@ type config struct {
CName string `json:"cname" toml:"cname" yaml:"cname"`
Authority string `json:"authority" toml:"authority" yaml:"authority"`
Insecure bool `json:"insecure,omitempty" toml:"insecure,omitempty" yaml:"insecure,omitempty"`
N uint `json:"n" toml:"n" yaml:"n" default:"200"`
C uint `json:"c" toml:"c" yaml:"c" default:"50"`
QPS uint `json:"q" toml:"q" yaml:"q"`
Z Duration `json:"z" toml:"z" yaml:"z"`
X Duration `json:"x" toml:"x" yaml:"x"`
Timeout uint `json:"t" toml:"t" yaml:"t" default:"20"`
Data interface{} `json:"d,omitempty" toml:"d,omitempty" yaml:"d,omitempty"`
DataPath string `json:"D" toml:"D" yaml:"D"`
N uint `json:"total" toml:"total" yaml:"total" default:"200"`
C uint `json:"concurrency" toml:"concurrency" yaml:"concurrency" default:"50"`
QPS uint `json:"qps" toml:"qps" yaml:"qps"`
Z Duration `json:"duration" toml:"duration" yaml:"duration"`
X Duration `json:"max-duration" toml:"max-duration" yaml:"max-duration"`
Timeout uint `json:"timeout" toml:"timeout" yaml:"timeout" default:"20"`
Data interface{} `json:"data,omitempty" toml:"data,omitempty" yaml:"data,omitempty"`
DataPath string `json:"data-file" toml:"data-file" yaml:"data-file"`
BinData []byte `json:"-" toml:"-" yaml:"-"`
BinDataPath string `json:"B" toml:"B" yaml:"B"`
Metadata *map[string]string `json:"m,omitempty" toml:"m,omitempty" yaml:"m,omitempty"`
MetadataPath string `json:"M" toml:"M" yaml:"M"`
SI Duration `json:"si" toml:"si" yaml:"si"`
Output string `json:"o" toml:"o" yaml:"o"`
Format string `json:"O" toml:"O" yaml:"O"`
Host string `json:"host" toml:"host" yaml:"host"`
DialTimeout uint `json:"T" toml:"T" yaml:"T" default:"10"`
KeepaliveTime uint `json:"L" toml:"L" yaml:"L"`
BinDataPath string `json:"binary-file" toml:"binary-file" yaml:"binary-file"`
Metadata *map[string]string `json:"metadata,omitempty" toml:"metadata,omitempty" yaml:"metadata,omitempty"`
MetadataPath string `json:"metadata-file" toml:"metadata-file" yaml:"metadata-file"`
SI Duration `json:"stream-interval" toml:"stream-interval" yaml:"stream-interval"`
Output string `json:"output" toml:"output" yaml:"output"`
Format string `json:"format" toml:"format" yaml:"format"`
DialTimeout uint `json:"connect-timeout" toml:"connect-timeout" yaml:"connect-timeout" default:"10"`
KeepaliveTime uint `json:"keepalive" toml:"keepalive" yaml:"keepalive"`
CPUs uint `json:"cpus" toml:"cpus" yaml:"cpus"`
ImportPaths []string `json:"i,omitempty" toml:"i,omitempty" yaml:"i,omitempty"`
ImportPaths []string `json:"import-paths,omitempty" toml:"import-paths,omitempty" yaml:"import-paths,omitempty"`
Name string `json:"name,omitempty" toml:"name,omitempty" yaml:"name,omitempty"`
Tags *map[string]string `json:"tags,omitempty" toml:"tags,omitempty" yaml:"tags,omitempty"`
ReflectMetadata *map[string]string `json:"rmd,omitempty" toml:"rmd,omitempty" yaml:"rmd,omitempty"`
ReflectMetadata *map[string]string `json:"reflect-metadata,omitempty" toml:"reflect-metadata,omitempty" yaml:"reflect-metadata,omitempty"`
Host string `json:"host" toml:"host" yaml:"host"`
}

// UnmarshalJSON is our custom implementation to handle the Duration fields
Expand Down
Loading