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

Show bundled extension versions in the k6 version output #2805

Merged
merged 9 commits into from
Dec 13, 2022

Conversation

imiric
Copy link
Contributor

@imiric imiric commented Dec 6, 2022

This is based on the work done in #2754 (thanks @HarrisChu!), and the suggested changes there.

It evolved into something slightly more elaborate, where the bulk of the changes are to unify the extension registry, so that registration and retrieval of extension information is done in a single place. See commit cf5fa61 for details. We still need to keep the existing registration functions in js/modules/ and output/ to avoid breaking extensions, but internally they're both now handled in the new root ext package. This DRYs the handling of extensions, and simplifies adding new types of extensions. It also simplifies the retrieval of extension versions, which is why it was done on top of #2754.

Here's how it currently looks:

$ xk6 build 4df8d46169ecc3a0417fd902bdcb28800e8098f0 \
  --with github.com/vesoft-inc/k6-plugin \
  --with github.com/grafana/xk6-output-influxdb
[...]

$ ./k6 version
k6 v0.41.0 ((devel), go1.19.1, linux/amd64)
Extensions:
  github.com/grafana/xk6-output-influxdb v0.2.2, xk6-influxdb [output]
  github.com/vesoft-inc/k6-plugin v1.0.1, aggcsv [output]
  github.com/vesoft-inc/k6-plugin v1.0.1, k6/x/nebulagraph [js]

edit by @na-- : after some internal discussions, we removed the changes to k6 run, for now.

Closes #1741

HarrisChu and others added 5 commits December 6, 2022 17:03
Co-authored-by: HarrisChu <1726587+HarrisChu@users.noreply.github.com>

This adds some structure and extracts common functionality for
registering and retrieving extension information into a standalone
package.

Partly based on the work and feedback in #2754.
@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2022

Codecov Report

Merging #2805 (5bae34a) into master-next (a403c90) will decrease coverage by 0.17%.
The diff coverage is 65.93%.

❗ Current head 5bae34a differs from pull request most recent head b975746. Consider uploading reports for the commit b975746 to get more accurate results

@@               Coverage Diff               @@
##           master-next    #2805      +/-   ##
===============================================
- Coverage        76.13%   75.96%   -0.18%     
===============================================
  Files              212      211       -1     
  Lines            16501    16559      +58     
===============================================
+ Hits             12563    12579      +16     
- Misses            3170     3205      +35     
- Partials           768      775       +7     
Flag Coverage Δ
ubuntu 75.96% <65.93%> (-0.05%) ⬇️
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
output/extensions.go 0.00% <0.00%> (-40.00%) ⬇️
cmd/outputs.go 54.16% <45.45%> (-0.38%) ⬇️
ext/ext.go 60.65% <60.65%> (ø)
cmd/ui.go 66.97% <100.00%> (+1.75%) ⬆️
cmd/version.go 100.00% <100.00%> (ø)
js/jsmodules.go 100.00% <100.00%> (ø)
js/modules/modules.go 33.33% <100.00%> (-33.34%) ⬇️
loader/filesystems.go 60.00% <0.00%> (-40.00%) ⬇️
js/common/initenv.go 66.66% <0.00%> (-33.34%) ⬇️
api/v1/status_routes.go 32.65% <0.00%> (-22.45%) ⬇️
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@na-- na-- added this to the v0.43.0 milestone Dec 6, 2022
Copy link
Contributor

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

I love that PR 😍

I left a couple of comments in PR and have one more general.

Although an extension output looks excellent, there are no questions for the k6 version.

But I feel it's not always relevant to have the same level of details (precisely version and repository) for the k6 run 🤔 I had an impression that we tend to keep it minimal.

cmd/ui.go Outdated Show resolved Hide resolved
ext/ext.go Outdated Show resolved Hide resolved
ext/ext.go Outdated Show resolved Hide resolved
ext/ext.go Show resolved Hide resolved
@imiric
Copy link
Contributor Author

imiric commented Dec 7, 2022

Thanks for reviewing @olegbespalov!

You raise a good point regarding k6 version/k6 run. I also think that k6 run output is a bit cluttered now.

Since extension versions and maybe even the package path is not relevant for k6 run, WDYT about shortening it to:

 extensions: aggcsv [output], k6/x/nebulagraph [js], xk6-influxdb [output]

?

I kind of don't even want to split them over multiple lines, but if we show them on the same line we'd have to make sure to wrap properly if many extensions are in use or the terminal is too narrow.

I can look into it if everyone else agrees. Let me know.

Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

Really great work @imiric 👍🏻 🎉 🦖

I'm also super happy to see this happen! I left a couple of nitpicks for your consideration, but I wouldn't consider any of them blocking in any way. Personally, I don't necessarily mind the k6 run output as it is now 🙇🏻


// All supported k6 extension types.
const (
JSExtension ExtensionType = iota + 1
Copy link
Member

Choose a reason for hiding this comment

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

That looks like an opportunity to learn something: why the +1 on the iota here? 😇

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a convention to avoid constants with a value of 0. That way you can identify when a value was set or not.

ext/ext.go Outdated
case JSExtension:
s = "js"
case OutputExtension:
s = "out"
Copy link
Member

Choose a reason for hiding this comment

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

UX nit: I would find "output" to be more explicit, especially if we show this to the user. "out" is quite a polysemic word, used in a ton of different contexts, and as a user, I think I could be confused/unclear by what it refers to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"output" is definitely clearer, but I wanted to keep this short, since it's shown in k6 run which is already loaded with information, especially if we decide to show it in a single line. Considering the context of this is "extensions", I doubt there would be confusion about what "out" means, especially if shown next to "js" (which I also want to keep short).

But OK, I renamed it in b975746.

// Extension is a generic container for any k6 extension.
type Extension struct {
Name, Path, Version string
Type ExtensionType
Copy link
Member

Choose a reason for hiding this comment

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

Another very personal nit you should feel free to dismiss: would you consider renaming the field and type to Kind ExtensionKind. I find it to be some somewhat more accurate in that context, and it avoids using a name that's a language keyword. But I want to acknowledge this is a very personal thing 🙇🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 I think we've always referred to these as extension "types", so I wouldn't want to change our vocabulary just because it's a reserved keyword. Though in this case type is the keyword, and Type works just fine, so I'd rather keep calling it this, if you don't mind.

type Extension struct {
Name, Path, Version string
Type ExtensionType
Module interface{}
Copy link
Member

Choose a reason for hiding this comment

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

This comment might be caused by the fact that I'm only partially through the PR, but I must admit that looking at this field's definition and how it's used in Register as a user, I would be unclear as to what kind of value I should use to set the Module field.

Copy link
Contributor Author

@imiric imiric Dec 12, 2022

Choose a reason for hiding this comment

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

Sure, it is confusing. 😞 We initially called this "module" when JS extensions were introduced, as JS extensions would register a struct of their JS module. But then we changed the API for output extensions and had them register a constructor function that would return a struct value, for initialization purposes. In retrospect, I think this was the wrong API to introduce, but since I doubt we'll change this, every extension type is now free to choose what works best.

Since I can't think of a more generic name that would fit better, I'm inclined to leave it as Module, but let me know if you have a better idea.

Copy link
Contributor

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

Changes look good to me 👍

Approving, but ideally, before merging we should check with the broader team if #2805 (comment) makes sense or my concerns are not relevant, and we can go with the current implementations 👍

@na--
Copy link
Member

na-- commented Dec 13, 2022

My vote would be to show extension information only in k6 version, but not in k6 run 🤔 Maybe we can add a debug-level log message with that information in all other commands (k6 run, k6 archive, k6 inspect), but that's it

k6 run is already quite noisy, so we shouldn't add more things in there that might be completely unconnected to the actual test run 🤔 Whatever extensions were compiled into the current k6 binary, there is no guarantee that they are being used at the moment. Besides, we don't show the k6 version, why should we show the extensions that were bundled in it?

@codebien codebien merged commit cd1ae8a into master-next Dec 13, 2022
@codebien codebien deleted the feat/1741-extension-version branch December 13, 2022 10:10
@na-- na-- changed the title Show bundled extension versions in k6 run and k6 version outputs Show bundled extension versions in the k6 version output Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants