Skip to content

Commit

Permalink
Support comma in tag values through cli flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Feb 14, 2025
1 parent 36c98a3 commit b8e7f9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func optionFlagSet() *pflag.FlagSet {
metrics.DefaultSystemTagSet.SetString(),
)
flags.StringSlice("system-tags", nil, systemTagsCliHelpText)
flags.StringSlice("tag", nil, "add a `tag` to be applied to all samples, as `[name]=[value]`")
flags.StringArray("tag", nil, "add a `tag` to be applied to all samples, as `[name]=[value]`")
flags.String("console-output", "", "redirects the console logging to the provided output file")
flags.Bool("discard-response-bodies", false, "Read but don't process or save HTTP response bodies")
flags.String("local-ips", "", "Client IP Ranges and/or CIDRs from which each VU will be making requests, "+
Expand Down Expand Up @@ -210,7 +210,7 @@ func getOptions(flags *pflag.FlagSet) (lib.Options, error) {
opts.SummaryTimeUnit = null.StringFrom(summaryTimeUnit)
}

runTags, err := flags.GetStringSlice("tag")
runTags, err := flags.GetStringArray("tag")
if err != nil {
return opts, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/tests/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ func TestRunTags(t *testing.T) {

ts := getSingleFileTestState(t, script, []string{
"-u", "2", "--log-output=stdout", "--out", "json=results.json",
"--tag", "foo=bar", "--tag", "test=mest", "--tag", "over=written",
"--tag", "foo=bar", "--tag", "test=mest", "--tag", "over=written, something",
}, 0)
ts.Env["K6_ITERATIONS"] = "3"
ts.Env["K6_INSECURE_SKIP_TLS_VERIFY"] = "true"
Expand All @@ -1653,7 +1653,7 @@ func TestRunTags(t *testing.T) {
jsonResults, err := fsext.ReadFile(ts.FS, "results.json")
require.NoError(t, err)

expTags := map[string]string{"foo": "bar", "test": "mest", "over": "written", "scenario": "default"}
expTags := map[string]string{"foo": "bar", "test": "mest", "over": "written, something", "scenario": "default"}
assert.Equal(t, float64(3), sum(getSampleValues(t, jsonResults, "iterations", expTags)))
assert.Equal(t, 3, len(getSampleValues(t, jsonResults, "iteration_duration", expTags)))
assert.Less(t, float64(0), sum(getSampleValues(t, jsonResults, "data_received", expTags)))
Expand Down

0 comments on commit b8e7f9a

Please sign in to comment.