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

http: add asyncRequest #2877

Merged
merged 2 commits into from
Feb 1, 2023
Merged

http: add asyncRequest #2877

merged 2 commits into from
Feb 1, 2023

Conversation

mstoykov
Copy link
Contributor

This is implementation of http.request but it return a promise and does all the networking off the event loop.

The code is pretty simple and seems fairly safe given that most possible race conditions would also happen in the case of
http.batch.

Even with that there is at least one test that previously couldn't have happened with http.batch.

closes #2825

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2023

Codecov Report

Merging #2877 (ad74aaa) into master (1268fad) will increase coverage by 0.15%.
The diff coverage is 78.90%.

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

@@            Coverage Diff             @@
##           master    #2877      +/-   ##
==========================================
+ Coverage   76.71%   76.86%   +0.15%     
==========================================
  Files         225      225              
  Lines       16807    16869      +62     
==========================================
+ Hits        12894    12967      +73     
+ Misses       3085     3067      -18     
- Partials      828      835       +7     
Flag Coverage Δ
ubuntu 76.71% <78.90%> (+0.06%) ⬆️
windows 76.62% <78.90%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
core/engine.go 85.00% <ø> (-0.37%) ⬇️
js/modules/k6/experimental/tracing/module.go 71.15% <55.55%> (-4.41%) ⬇️
js/modules/k6/experimental/tracing/client.go 68.86% <57.44%> (+7.75%) ⬆️
js/modules/k6/http/request.go 84.54% <94.11%> (+1.05%) ⬆️
execution/scheduler.go 92.83% <96.15%> (+0.63%) ⬆️
js/modules/k6/http/http.go 92.50% <100.00%> (+0.09%) ⬆️
js/modules/k6/k6.go 98.26% <100.00%> (+0.16%) ⬆️
api/v1/status_routes.go 55.10% <0.00%> (-4.09%) ⬇️
cmd/run.go 71.49% <0.00%> (-1.36%) ⬇️
output/cloud/output.go 85.01% <0.00%> (-0.58%) ⬇️
... and 7 more

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

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! 👏🏻 🎉

I've left a bunch of comments that I don't consider blocking, but that I care enough about that I'd like them to be considered.

Overall I have tried to find test cases that could be missing, but after more careful consideration, I believe the scenarios I thought of are already covered by the current test suite, or are very tied to the usage of the async/await syntax itself, and are very likely already covered by goja's test suite. I ran a few test scripts on my side too and couldn't break it, so kudos! 👏🏻

🙇🏻

js/modules/k6/http/request.go Outdated Show resolved Hide resolved
js/modules/k6/http/request.go Outdated Show resolved Hide resolved
js/modules/k6/http/async_request_test.go Show resolved Hide resolved
js/modules/k6/experimental/tracing/client.go Outdated Show resolved Hide resolved
@mstoykov mstoykov requested a review from oleiade January 30, 2023 17:25
oleiade
oleiade previously approved these changes Jan 31, 2023
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.

LGTM 👏🏻 🎉

Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

Nice work! 👏

Mostly LGTM, just left some questions and minor suggestions.

js/modules/k6/experimental/tracing/client.go Outdated Show resolved Hide resolved
js/modules/k6/http/request.go Outdated Show resolved Hide resolved
js/modules/k6/http/request.go Show resolved Hide resolved
js/modules/k6/http/async_request_test.go Show resolved Hide resolved
js/modules/k6/http/async_request_test.go Show resolved Hide resolved
imiric
imiric previously approved these changes Jan 31, 2023
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

👍

Let's just squash+rebase this.

This is implementation of http.request, but it returns a promise and
does all the networking off the event loop.

The code is pretty simple and seems fairly safe given that most possible
race conditions would also happen in the case of
`http.batch`.

Even with that there is at least one test that previously couldn't have
happened with http.batch.

closes #2825
imiric
imiric previously approved these changes Jan 31, 2023
oleiade
oleiade previously approved these changes Feb 1, 2023
js/modules/k6/experimental/tracing/client.go Outdated Show resolved Hide resolved
// Remove the trace ID from the VU's state, so that it doesn't leak into other requests.
defer func() {
c.vu.State().Tags.Modify(func(t *metrics.TagsAndMeta) {
t.DeleteMetadata(metadataTraceIDKeyName)
Copy link
Contributor

@codebien codebien Feb 1, 2023

Choose a reason for hiding this comment

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

If I remove this line nothing fails for the http and tracing module's tests.

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 do think this should be addressed separately. After taking a look this is not new I just refactor the code - if anything my code is less likely to break :P. But writing a test for this seems a bit more involved than I would prefer for this PR

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 did open an issue with it #2889

@mstoykov mstoykov dismissed stale reviews from oleiade and imiric via 99eab43 February 1, 2023 09:14
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
@mstoykov mstoykov merged commit 065b4b5 into master Feb 1, 2023
@mstoykov mstoykov deleted the httpAsyncRequest branch February 1, 2023 09:36
@mstoykov mstoykov mentioned this pull request Mar 14, 2024
5 tasks
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.

Add http.asyncRequest
5 participants