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 options exporting in HAR conversion and to JS runtime #713

Merged
merged 4 commits into from Jul 17, 2018

Conversation

Projects
None yet
3 participants
@na--
Member

na-- commented Jul 16, 2018

After merging #681, I realized that my advice to @mohanprasaths there to use something like rt.Set("options", runner.GetOptions()) probably wasn't the best idea... The main reason for that was very similar to the reason I recently had to do this hack in for the options injection in the HAR file conversion. Basically, directly exporting the null-able types in lib.Options to JSON produces a lot of null and empty array/object values. Another slight drawback is that if a user adds their own non-k6 keys in the options object, they would have been overwritten and lost.

This PR adds a new method to lib.Options that allows us to flexibly traverse the lib.Options fields that are set. This improves both the HAR export format (it now uses unquoted JS keys) and the options propagation back to the JS runtime (no extra nulls and non-k6 user-defined options there won't be overwritten).

It's still not perfect... The current output of simply running script like this without any extra parameters:

export let options = {
	myOption: "test"
};

export default function (data) {
	console.log(JSON.stringify(options));
}

would be something like this:

{"myOption":"test","iterations":1,"tlsVersion":{"min":"","max":""},"systemTags":["proto","method","group","error","subproto","status","url","name","check","tls_version"]}

iterations and myOption are fine, tlsVersion appears due to this bug and systemTags is included due to a limitation in the way we (don't) track and handle complex default values...

Also, both this and in the original fix for #613 won't properly work when executing the script in the cloud (especially when there are multiple k6 instances), but fixing that would probably have to wait until we have proper cluster execution in k6 itself...

na-- added some commits Jul 16, 2018

@na-- na-- requested review from luizbafilho and robingustafsson Jul 16, 2018

na-- added some commits Jul 16, 2018

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io Jul 16, 2018

Codecov Report

Merging #713 into master will decrease coverage by 0.12%.
The diff coverage is 23.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #713      +/-   ##
==========================================
- Coverage   64.38%   64.26%   -0.13%     
==========================================
  Files         101      101              
  Lines        8275     8302      +27     
==========================================
+ Hits         5328     5335       +7     
- Misses       2598     2617      +19     
- Partials      349      350       +1
Impacted Files Coverage Δ
js/runner.go 78.81% <ø> (-0.11%) ⬇️
cmd/run.go 6.79% <0%> (ø) ⬆️
cmd/options.go 61.53% <0%> (-1.57%) ⬇️
lib/options.go 78.43% <0%> (-6.08%) ⬇️
converter/har/converter.go 17.55% <0%> (-0.35%) ⬇️
js/bundle.go 81.95% <85.71%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7b2516...a757f74. Read the comment docs.

codecov-io commented Jul 16, 2018

Codecov Report

Merging #713 into master will decrease coverage by 0.12%.
The diff coverage is 23.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #713      +/-   ##
==========================================
- Coverage   64.38%   64.26%   -0.13%     
==========================================
  Files         101      101              
  Lines        8275     8302      +27     
==========================================
+ Hits         5328     5335       +7     
- Misses       2598     2617      +19     
- Partials      349      350       +1
Impacted Files Coverage Δ
js/runner.go 78.81% <ø> (-0.11%) ⬇️
cmd/run.go 6.79% <0%> (ø) ⬆️
cmd/options.go 61.53% <0%> (-1.57%) ⬇️
lib/options.go 78.43% <0%> (-6.08%) ⬇️
converter/har/converter.go 17.55% <0%> (-0.35%) ⬇️
js/bundle.go 81.95% <85.71%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7b2516...a757f74. Read the comment docs.

@na-- na-- merged commit 1280bd0 into master Jul 17, 2018

5 checks passed

ci/circleci: build-docker-images Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@na-- na-- deleted the options-export-fixes branch Jul 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment