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

test: increase Http2ServerResponse test coverage #15074

Conversation

apapirovski
Copy link
Member

A few bundled changes, all for Http2ServerResponse, that are too small for separate PRs:

  • Modified existing header tests for Http2ServerResponse to include sendDate (get and set) and headersSent
  • Expanded existing test for end to include a check for closed
  • New test for destroy

Refs: #14985

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Aug 29, 2017
@mscdex mscdex added the http2 Issues or PRs related to the http2 subsystem. label Aug 29, 2017
@benjamingr
Copy link
Member

@benjamingr
Copy link
Member

@nodejs/build

@gibfahn
Copy link
Member

gibfahn commented Sep 1, 2017

@benjamingr did you mean to cc/ @nodejs/http2

@benjamingr
Copy link
Member

@gibfahn no, I wasn't sure if these are build related failures or code related failures.

@gibfahn
Copy link
Member

gibfahn commented Sep 1, 2017

@gibfahn no, I wasn't sure if these are build related failures or code related failures.

Oh I see, I didn't realise the ping was related to CI failures.

EDIT: The arm failure is nodejs/build#857, should be fixed now. The other two failures I'm not sure about.

@apapirovski
Copy link
Member Author

It looks like OSX has been failing since 5am on 31st so it's probably not related to this.


if (path === '/error') {
req.once('error', (err) => assert.strictEqual(err, error));
res.once('error', (err) => assert.strictEqual(err, error));
Copy link
Member

Choose a reason for hiding this comment

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

Is this behavior shared with HTTP1? Can we check?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will confirm today.

Copy link
Member Author

@apapirovski apapirovski Sep 1, 2017

Choose a reason for hiding this comment

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

So in h1 it doesn't emit any server-side error events (on req, res or server itself) which seems a bit weird. It causes a socket hang up which then throws an error on the client-side request (ECONNRESET).

Copy link
Member

Choose a reason for hiding this comment

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

This case is calling destroy(err) on the response, what does happen on H1?

In #14991, errors from the underlining socket are not forwarded to req and res anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, after testing this further, this code is clearly outdated. I was working on it at the same time as you were working on refactoring how the errors are emitted. Will revise.

@mcollina
Copy link
Member

mcollina commented Sep 1, 2017

@jasnell
Copy link
Member

jasnell commented Sep 1, 2017

Looks like the osx build bot is consistently dead. ping @nodejs/build

@refack
Copy link
Contributor

refack commented Sep 1, 2017

Looks like the osx build bot is consistently dead. ping @nodejs/build

Looking into it.

Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.

Refs: nodejs#14985
@apapirovski apapirovski force-pushed the patch-test-http2-serverresponse-coverage branch from d242bb1 to ad35687 Compare September 1, 2017 19:20
@apapirovski
Copy link
Member Author

apapirovski commented Sep 1, 2017

@mcollina I had to rebase this locally to get the changes to error handling that you made. I've now rewritten the test to match the new behaviour. Should make more sense now. Thanks for the review!

(Also I really should've had common.mustCall on those error handlers then the build would've told us this wasn't working.)

@refack
Copy link
Contributor

refack commented Sep 1, 2017

OSX fail ref: nodejs/build#861


const server = http2.createServer(common.mustCall((req, res) => {
req.once('error', common.mustNotCall());
req.once('error', common.mustNotCall());
Copy link
Member

Choose a reason for hiding this comment

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

this are both req. I think res should receive the error, considering the semantics of .destroy(err) throughout the codebase. Check with H1, but I think we have a bug in the compat layer because of this.

@apapirovski
Copy link
Member Author

apapirovski commented Sep 2, 2017

@mcollina I fixed the typo and there's no error emitted on res. Also, checked H1 and it doesn't emit an error on res either. Only the socket receives the error, as far as I can tell. It doesn't bubble up.

Looking at the documentation, calling destroy on the ServerResponse isn't actually documented in H1 but it is documented for the IncomingMessage:

Calls destroy() on the socket that received the IncomingMessage. If error is provided, an 'error' event is emitted and error is passed as an argument to any listeners on the event.

And the destroy code for both is equivalent in terms of error handling.

@apapirovski apapirovski force-pushed the patch-test-http2-serverresponse-coverage branch from 7605465 to 12dfd8f Compare September 2, 2017 12:18
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@apapirovski apapirovski force-pushed the patch-test-http2-serverresponse-coverage branch from a71def2 to 12dfd8f Compare September 2, 2017 21:31
@mcollina
Copy link
Member

mcollina commented Sep 3, 2017

@BridgeAR
Copy link
Member

BridgeAR commented Sep 3, 2017

Landed in 198fcb9

@BridgeAR BridgeAR closed this Sep 3, 2017
BridgeAR pushed a commit that referenced this pull request Sep 3, 2017
Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.

PR-URL: #15074
Refs: #14985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@apapirovski apapirovski deleted the patch-test-http2-serverresponse-coverage branch September 4, 2017 14:37
addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 5, 2017
Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.

PR-URL: nodejs/node#15074
Refs: nodejs/node#14985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.

PR-URL: #15074
Refs: #14985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 11, 2017
Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.

PR-URL: #15074
Refs: #14985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
Modify existing header tests for Http2ServerResponse to include
sendDate (get and set) and headersSent. Expand existing test
for end to include a check for closed. Add a new test for destroy.

PR-URL: #15074
Refs: #14985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants