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

Warn on shorthand options overriding scenarios #4176

Merged
merged 1 commit into from
Jan 17, 2025
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
17 changes: 16 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,15 @@ func getConsolidatedConfig(gs *state.GlobalState, cliConf Config, runnerOpts lib

conf = cliConf.Apply(fileConf)

warnOnShortHandOverride(conf.Options, runnerOpts, "script", gs.Logger)
conf = conf.Apply(Config{Options: runnerOpts})

conf = conf.Apply(envConf).Apply(cliConf)
warnOnShortHandOverride(conf.Options, envConf.Options, "env", gs.Logger)
conf = conf.Apply(envConf)

warnOnShortHandOverride(conf.Options, cliConf.Options, "cli", gs.Logger)
conf = conf.Apply(cliConf)

conf = applyDefault(conf)

// TODO(imiric): Move this validation where it makes sense in the configuration
Expand All @@ -215,6 +221,15 @@ func getConsolidatedConfig(gs *state.GlobalState, cliConf Config, runnerOpts lib
return conf, nil
}

func warnOnShortHandOverride(a, b lib.Options, bName string, logger logrus.FieldLogger) {
if a.Scenarios != nil &&
(b.Duration.Valid || b.Iterations.Valid || b.Stages != nil || b.Scenarios != nil) {
logger.Warnf(
"%q level configuration overrode scenarios configuration entirely",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explicitly mention implications, what do you think?

Suggested change
"%q level configuration overrode scenarios configuration entirely",
"%q level configuration overrode scenarios configuration entirely. It's highly likely, that the test load result will be different from what you expect.",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usually isn't the problem - the problem is people expect:

  1. to run their scenarios but with a different duration, iterations or VUs, but with all other options the same
  2. having some other option stay the same - for example exec, env, and also options for browser

But making the message a bunch of sentences IMO isn't a great idea. The one we have with docker and stuff about not finding files - it still gets users to post it and ask questions. I only expect this is happening less because of google actually now fidning the results from previous asks.

bName)
}
}

// applyDefault applies the default options value if it is not specified.
// This happens with types which are not supported by "gopkg.in/guregu/null.v3".
//
Expand Down
4 changes: 3 additions & 1 deletion cmd/config_consolidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
env: []string{"K6_ITERATIONS=25"},
cli: []string{"--vus", "12"},
},
exp{},
exp{
logWarning: true,
},
verifySharedIters(I(12), I(25)),
},
{
Expand Down
Loading