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

Add GetJSModules support from #1858 #1911

Merged
merged 5 commits into from
Apr 9, 2021
Merged

Add GetJSModules support from #1858 #1911

merged 5 commits into from
Apr 9, 2021

Conversation

mstoykov
Copy link
Contributor

This allows integration tests to have separate global module instance of
all internal js modules.

For this to be supported for extension an additional type/interface will
be required a bit more added code

@mstoykov
Copy link
Contributor Author

at this point I think that k6/js/internal/modules can be dropped and all of it to be moved to k6/js/modules

js/modules/k6/data/data.go Show resolved Hide resolved
js/internal/modules/modules.go Outdated Show resolved Hide resolved
imiric
imiric previously approved these changes Mar 18, 2021
@mstoykov mstoykov requested a review from na-- March 31, 2021 10:27
js/internal/modules/modules.go Outdated Show resolved Hide resolved
js/initcontext.go Outdated Show resolved Hide resolved
@mstoykov mstoykov requested a review from na-- April 6, 2021 08:35
Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

I saw that you requested another review, has something changed and you're now against doing this change?

Also, can you please rebase on top of the latest master, we've had a lot of changes since this PR

js/internal/modules/modules.go Outdated Show resolved Hide resolved
@@ -61,3 +61,25 @@ func Register(name string, mod interface{}) {
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check above here is done only against the modules that are registered through the Register call.

While the current usage is such they are required to have x/ in the public modules module, it still isn't technically correct.

So should I:

  1. do nothing
  2. drop the internal modules package and move everything to the public one. This way I will check it there and hope that nobody will add x/k6 standard lib.
  3. Actually check against the result of GetJSModules

Copy link
Contributor

Choose a reason for hiding this comment

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

Hhmm considering we only made the package internal to begin with was to distinguish between internal and external module registration, and internal modules don't call Register() anymore, I vote for the 2nd approach, and to do any additional checks in the public package.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I grok everything fully, but yeah, 2nd approach seems best 👍, we don't need an internal module anymore.

@mstoykov mstoykov requested review from na-- and imiric April 6, 2021 12:56
@mstoykov mstoykov added this to the v0.32.0 milestone Apr 6, 2021
js/init_and_modules_test.go Outdated Show resolved Hide resolved
Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, besides the minor nitpicks mentioned inline and another more global one.

I think @simskij mentioned it somewhere, but we should probably move the HasModuleInstancePerVU interface out of the internal package, so that extensions can also explicitly check that they implement it. Not a deal breaker, we can do that a few versions from now and keep it in internal in v0.32.0, they can still implement it by just having the appropriate method. But if we don't intend to make any more changes, we probably can make it public even now.

// GlobalHTTP is a global HTTP module for a k6 instance/test run
type GlobalHTTP struct{}

var _ modules.HasModuleInstancePerVU = new(GlobalHTTP)
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: now that we're back to interface{}, this check like

var _ modules.HasModuleInstancePerVU = New()

might be somewhat useful again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well that will mean there will be an import loop ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I put in the modules package ?

js/init_and_modules_test.go Outdated Show resolved Hide resolved
mstoykov added 4 commits April 7, 2021 16:05
This allows integration tests to have separate global module instance of
all internal js modules.

For this to be supported for extension an additional type/interface will
be required a bit more added code
And drop the SharedObjects from the InitEnvironment
@mstoykov mstoykov requested a review from na-- April 8, 2021 15:21
@mstoykov
Copy link
Contributor Author

mstoykov commented Apr 8, 2021

should I:

  • move everything to the not internal modules package
  • just have it check in the modules package that some js modules are HasModuleInstancePerVU as to not make cycles ? I can move the definition somewhere else but this seems pointless for the internal packages? Alternatively I can just move the HasModuleInstancePerVU in the public modules package and import it from there ... that should not have any cycles I think 🤔

na--
na-- previously approved these changes Apr 9, 2021
Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

LGTM, though yeah, it seems like we don't really need the internal/modules package anymore

@codecov-io
Copy link

codecov-io commented Apr 9, 2021

Codecov Report

Merging #1911 (28e4ba2) into master (e5d4d82) will increase coverage by 0.13%.
The diff coverage is 95.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1911      +/-   ##
==========================================
+ Coverage   71.28%   71.42%   +0.13%     
==========================================
  Files         183      183              
  Lines       14274    14245      -29     
==========================================
- Hits        10175    10174       -1     
+ Misses       3479     3439      -40     
- Partials      620      632      +12     
Flag Coverage Δ
ubuntu 71.37% <95.91%> (+0.15%) ⬆️
windows 71.08% <95.91%> (+0.10%) ⬆️

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

Impacted Files Coverage Δ
js/common/initenv.go 100.00% <ø> (ø)
js/modules/k6/crypto/crypto.go 93.91% <ø> (-0.06%) ⬇️
js/modules/k6/encoding/encoding.go 87.09% <ø> (-0.41%) ⬇️
js/modules/k6/grpc/grpc.go 100.00% <ø> (ø)
js/modules/k6/html/html.go 81.86% <ø> (-0.09%) ⬇️
js/modules/k6/k6.go 100.00% <ø> (ø)
js/modules/k6/metrics/metrics.go 92.30% <ø> (-0.29%) ⬇️
js/modules/k6/ws/ws.go 81.49% <ø> (-0.08%) ⬇️
js/modules/modules.go 80.00% <88.88%> (ø)
js/bundle.go 92.10% <100.00%> (-0.06%) ⬇️
... and 21 more

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 e5d4d82...28e4ba2. Read the comment docs.

@mstoykov mstoykov requested a review from imiric April 9, 2021 13:21
@mstoykov mstoykov merged commit 3eae9bd into master Apr 9, 2021
@mstoykov mstoykov deleted the getJSModules branch April 9, 2021 15:03
imiric pushed a commit that referenced this pull request Apr 28, 2021
This is not needed anymore since #1911.
imiric pushed a commit that referenced this pull request Apr 28, 2021
This is not needed anymore since #1911.
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.

4 participants