-
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: http2 client settings errors #16096
Conversation
|
||
const errorMustCall = common.expectsError(test.error, 2); | ||
const errorMustNotCall = common.mustNotCall( | ||
`${test.error.code} should emit on ${test.type}` |
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.
test.type
does not appear to be defined in this test. I think it should be replaced with a plain string that says session
. (Maybe the message isn't even necessary to be honest since it only emits on session.)
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.
Great catch @apapirovski
I'd copied this template from other tests which checks for errors which had types. I've replace ${test.type}
with plain string session
runTest(tests.shift()); | ||
|
||
function runTest(test) { | ||
const server = http2.createServer(common.mustNotCall()); |
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 might be missing something but is there a reason the server needs to be started on each test run rather than having a single server for the whole test?
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.
The sessionError
is thrown on the server.
A single server was used originally, but I was not able to override the error thrown on that server. So a new server was created per test.
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.
Would it be possible to just do server.once('sessionError', fn)
inside runTest
and have all the code around creating a server and initiating it outside of runTest
? If not, no worries.
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.
server.once('sessionError', fn)
worked!
Thanks for the suggestion. I've updated the commit.
client.settings({ | ||
maxHeaderListSize: 1 | ||
}); | ||
server.on( |
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'm not sure I'm following what's going on with the changes in this file. Is there a reason everything needs to be scoped within the stream handler? This looks like a lot of churn and I'm having trouble following why.
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 originally started working on this file and formatted the code using Prettier.
I created test-http2-client-settings-errors.js
after coming across the template used by other tests which checked for errors.
I've scoped method assertSettings
within stream handler, as it's only used within that block.
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.
My concern is just that it's a bit easier to follow the file history (git blame
) when changes aren't made just for the sake of changing code style, unless the clarity is a significant problem. That said, this is a nit so if no one else cares then this is fine. Thanks for the explanation 👍
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 agree that code change shouldn't be made just for changing code style.
I added changed in test-http2-session-settings.js
as the formatting was already done. I'll remove it from the commit if more people raise it in the reviews.
Btw, I created an issue at #16115 to check if we can move to Javascript formatter like Prettier.
ffdc72d
to
efa4ab1
Compare
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.
LGTM. Just nits above. 👍
efa4ab1
to
b16419c
Compare
Can someone create CI link for this pull request? |
b16419c
to
262beed
Compare
Fixed linting errors and rebased from upstream/master |
Looks like on slower systems this test is failing because server.on('sessionError', () => {}); // not being tested |
262beed
to
a1bf7a0
Compare
Moved sessionError to top level scope as tests are failing on slower systems. |
Failures are unrelated. |
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.
LGTM
Landing this. |
Landed as c3eeb28. |
Refs: nodejs/node#14985 PR-URL: nodejs/node#16096 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This code change adds tests for checking errors in
client.settings()
Refs: #14985
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test, http2