-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: Http2Stream redundant call to shutdown and call passing only callback #15612
Conversation
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.
Thanks for the work @trivikr! I think in general it's better to do these as one test since the 1st test is strictly a subset of the 2nd test. If the first mustCall
doesn't fire in the 2nd test then the results are equivalent.
I would also suggest expanding this to cover this[kState].destroyed || this[kState].destroying
behaviour (throws). (Feel free to add comments to annotate the different steps.)
stream.session.shutdown(common.mustCall(() => { | ||
assert.strictEqual( | ||
stream.session.shutdown(), | ||
undefined |
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.
I think it's better if this also checks that it doesNotThrow
.
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.
assert.strictEqual
will ensure that no error is thrown
Tested on repl
server.on('stream', common.mustCall((stream) => { | ||
stream.session.shutdown(common.mustCall(() => { | ||
assert.strictEqual( | ||
stream.session.shutdown(), |
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.
I would suggest adding common.mustNotCall()
so that it's clear that the callback only executes once.
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.
Added!
|
||
// Test blank return when a stream.session.shutdown is called twice | ||
server.on('stream', common.mustCall((stream) => { | ||
stream.session.shutdown(common.mustCall(() => { |
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.
I would also run another stream.session.shutdown(common.mustNotCall())
outside of the callback. If there are two calls in a row, it shouldn't throw or execute a callback a 2nd time. (This would cover a case where someone moves the shuttingDown
setting into a nextTick or event or something, or just removes it period.)
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.
Added!
I agree to comment by @apapirovski #15612 (review) that the test test-http2-server-shutdown-redundant.js is a subset of test in test-http2-server-shutdown-only-callback.js The test to cover |
Yeah, my bad re: the 2nd point. Should've realized, haha. :) I'm still not sure I understand what |
I've removed the test |
When the commits are squashed before merge, the commit message should be:
|
Thanks @trivikr! 👍 I realize these were sort of nits but just to explain my reasoning: There are currently over 1200+ tests and it's growing all the time, so as much as possible it's good to avoid highly specialized test cases if the same can be accomplished by a single slightly longer test case that goes through a few stages (as long as it doesn't compromise the test result). That way we can avoid having duplicate code and unnecessary amount of buildup and teardown of tests. (If you look at the node CI, it runs all the tests on some truly ancient/slow systems.) See some of these other http2 tests: |
I completely agree with @apapirovski It's difficult to run single test also. I went through Makefile and came up with a python command to runs single test Line 204 in 4f4d55d
Questions:
The above issues weren't blocking me for this task, so I didn't create issues. |
It's documented in CONTRIBUTING.md, if that is what you mean. You are welcome to add it to the 'writing tests' guide though.
No. |
328081e
to
e853dc4
Compare
Squashed all commits into a single one, and force pushed it my private branch. |
What's the procedure to merge these changes to master? Do we have wait for certain time for approvals before merging? |
e853dc4
to
1498dbb
Compare
@trivikr ... yes, PRs generally must sit for at least 48 hours during the week and 72 hours over the weekend before they can be landed. Exception is given only to trivial doc updates. Also, things must go through a CI test run. |
Oh, and I see you added a merge commit. Generally, we always use rebase and avoid using merge commits. Before I get this landed, can I ask you to drop the merge commit and rebase from master? |
695540e
to
63c865c
Compare
Dropped the merge commit and performed git rebase as suggested by @jasnell and documentation |
Landed in 27d8202 |
PR-URL: #15612 Refs: #14985 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Thanks @BridgeAR |
Congrats @trivikr! Thanks for contributing 🎉 |
PR-URL: #15612 Refs: #14985 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #15612 Refs: #14985 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: nodejs/node#15612 Refs: nodejs/node#14985 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #15612 Refs: #14985 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This PR includes test cases for the handling of:
stream.session.shutdown()
stream.session.shutdown()
with only callback (no options)Refs: #14985
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test, http2