Skip to content

Commit

Permalink
Expose DisableTerminalOutput setting to CLI
Browse files Browse the repository at this point in the history
This is useful for shell-scripting when used in combination with another
exporter (like raw CSV or Cloudwatch or Prometheus)
  • Loading branch information
bebehei committed Apr 21, 2023
1 parent 128bc9a commit adcf007
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions cmd/cassowary/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func runLoadTest(c *client.Cassowary) error {
if err != nil {
return err
}
outPutResults(metrics)

if !c.DisableTerminalOutput {
outPutResults(metrics)
}

if c.ExportMetrics {
return outPutJSON(c.ExportMetricsFile, metrics)
Expand Down Expand Up @@ -193,26 +196,27 @@ func validateCLI(c *cli.Context) error {
}

cass := &client.Cassowary{
FileMode: fileMode,
BaseURL: c.String("url"),
ConcurrencyLevel: c.Int("concurrency"),
Requests: c.Int("requests"),
RequestHeader: header,
Duration: duration,
PromExport: prometheusEnabled,
TLSConfig: tlsConfig,
PromURL: c.String("prompushgwurl"),
Cloudwatch: c.Bool("cloudwatch"),
Boxplot: c.Bool("boxplot"),
Histogram: c.Bool("histogram"),
ExportMetrics: c.Bool("json-metrics"),
RawOutput: c.Bool("raw-output"),
ExportMetricsFile: c.String("json-metrics-file"),
DisableKeepAlive: c.Bool("disable-keep-alive"),
Timeout: c.Int("timeout"),
HTTPMethod: httpMethod,
URLPaths: urlSuffixes,
Data: data,
FileMode: fileMode,
DisableTerminalOutput: c.Bool("silent"),
BaseURL: c.String("url"),
ConcurrencyLevel: c.Int("concurrency"),
Requests: c.Int("requests"),
RequestHeader: header,
Duration: duration,
PromExport: prometheusEnabled,
TLSConfig: tlsConfig,
PromURL: c.String("prompushgwurl"),
Cloudwatch: c.Bool("cloudwatch"),
Boxplot: c.Bool("boxplot"),
Histogram: c.Bool("histogram"),
ExportMetrics: c.Bool("json-metrics"),
RawOutput: c.Bool("raw-output"),
ExportMetricsFile: c.String("json-metrics-file"),
DisableKeepAlive: c.Bool("disable-keep-alive"),
Timeout: c.Int("timeout"),
HTTPMethod: httpMethod,
URLPaths: urlSuffixes,
Data: data,
}

return runLoadTest(cass)
Expand Down Expand Up @@ -286,6 +290,11 @@ func runCLI(args []string) {
Aliases: []string{"raw-output"},
Usage: "enable to export raw per-request metrics",
},
&cli.BoolFlag{
Name: "s",
Aliases: []string{"silent"},
Usage: "Do not show progress and do not print results on terminal (useful for other output types)",
},
&cli.BoolFlag{
Name: "F",
Aliases: []string{"json-metrics"},
Expand Down

0 comments on commit adcf007

Please sign in to comment.