-
Notifications
You must be signed in to change notification settings - Fork 30k
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
test: use countdown in http-agent test #17537
Conversation
ecb661b
to
48c0c96
Compare
test/parallel/test-http-agent.js
Outdated
@@ -33,12 +34,13 @@ const server = http.Server(common.mustCall(function(req, res) { | |||
}, (N * M))); // N * M = good requests (the errors will not be counted) | |||
|
|||
function makeRequests(outCount, inCount, shouldFail) { | |||
const countdown = new Countdown(1, common.mustCall(() => server.close())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit of countdown can be outCount*inCount instead of 1.
test/parallel/test-http-agent.js
Outdated
@@ -33,12 +34,13 @@ const server = http.Server(common.mustCall(function(req, res) { | |||
}, (N * M))); // N * M = good requests (the errors will not be counted) | |||
|
|||
function makeRequests(outCount, inCount, shouldFail) { | |||
const countdown = new Countdown(1, common.mustCall(() => server.close())); | |||
let responseCount = outCount * inCount; | |||
let onRequest = common.mustNotCall(); // Temporary | |||
const p = new Promise((resolve) => { | |||
onRequest = common.mustCall((res) => { | |||
if (--responseCount === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can replace this whole if block with countdown.dec();
test/parallel/test-http-agent.js
Outdated
@@ -33,12 +34,13 @@ const server = http.Server(common.mustCall(function(req, res) { | |||
}, (N * M))); // N * M = good requests (the errors will not be counted) | |||
|
|||
function makeRequests(outCount, inCount, shouldFail) { | |||
const countdown = new Countdown(1, common.mustCall(() => server.close())); | |||
let responseCount = outCount * inCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove responseCount variable.
Thanks for contribution!!! Please, do use make lint/vcbuild lint before pr. |
@sreepurnajasti Thanks for the comments, I am pretty sure that I did run Do you think this would be ok ? ...
const countdown = new Countdown(
outCount * inCount,
common.mustCall(() => server.close())
);
let onRequest = common.mustNotCall(); // Temporary
const p = new Promise((resolve) => {
onRequest = common.mustCall((res) => {
if (countdown.dec() === 0) {
resolve();
}
if (!shouldFail)
res.resume();
}, outCount * inCount);
});
... |
That should work. You can also run |
48c0c96
to
a03d533
Compare
Thanks @apapirovski, I have already run all tests and linter 😄 after amending the last commit |
@fedekau LGTM. Thanks!! |
@apapirovski Do you think that this failure is related to my change? To me seems like it is not, or is it? 🤔 |
@fedekau Completely unrelated, this PR is all good :) |
PR-URL: #17537 Reviewed-By: Anatoli Papirovski <[email protected]>
Thanks @apapirovski and @sreepurnajasti I hope this is the first of many PRs 💪 |
PR-URL: #17537 Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #17537 Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #17537 Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #17537 Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #17537 Reviewed-By: Anatoli Papirovski <[email protected]>
Hi, this is my first PR to node!
I started by tackling one of the tests listed in #17169, in particular the
test/parallel/test-http-agent.js
test. Hopefully everything looks good to you, otherwise let me know what can be improved 😄Checklist
make -j4 test
make lint