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,http: fix http dump test #19823

Closed
wants to merge 1 commit into from

Conversation

mcollina
Copy link
Member

@mcollina mcollina commented Apr 5, 2018

Fixes: #19139

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

@mcollina mcollina requested review from Trott and lpinca April 5, 2018 08:18
@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Apr 5, 2018
@@ -560,7 +560,7 @@ function resOnFinish(req, res, socket, state, server) {
// if the user never called req.read(), and didn't pipe() or
// .resume() or .on('data'), then we call req._dump() so that the
// bytes will be pulled off the wire.
if (!req._consuming && !req._readableState.resumeScheduled)
if (!req._readableState.resumeScheduled)
Copy link
Member Author

Choose a reason for hiding this comment

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

this was noted in the original PR. req._consuming is never set.

@mcollina
Copy link
Member Author

mcollina commented Apr 5, 2018

req.on('error', function(err) {
// ECONNRESET can happen if there is some data still
// being sent, as the other side is calling .destroy()
if (err.code !== 'ECONNRESET') {
Copy link
Member

Choose a reason for hiding this comment

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

I think on Windows it's ECONNABORTED, and it might also be EPIPE as per #19139 (comment). Should we just ignore the error?

req.on('end', common.mustNotCall);

// this 'data' handler will be removed when dumped
req.on('data', 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.

Can we still check that _dump() removes all data listeners?

this.removeAllListeners('data');

maybe adding an assertion for listenerCount('data') in the 'resume' handler?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@mcollina
Copy link
Member Author

mcollina commented Apr 5, 2018

Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

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

Added a few more comments. All nits that can be ignored.

req.on('resume', common.mustCall(function() {
// there is no 'data' event handler anymore
// it gets automatically removed when dumping the request
assert.strictEqual(req.listenerCount('data'), 0);
console.log('resume called');
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This can be safely removed as the listener is wrapped in mustCall().

const fs = require('fs');

let resEnd = null;

const server = http.createServer(function(req, res) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd wrap the listener with mustCall().

req.on('resume', common.mustCall(function() {
// there is no 'data' event handler anymore
// it gets automatically removed when dumping the request
assert.strictEqual(req.listenerCount('data'), 0);
console.log('resume called');

req.on('data', common.mustCallAtLeast(function(d) {
console.log('data', d);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this could also be removed.

// this checks if the request gets dumped
// resume will be triggered by res.end()
Copy link
Member

Choose a reason for hiding this comment

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

Nit: would you be so kind and punctuate each sentence and also use a capital letter for the first character of a sentence? :-) That applies to all comments in here. The reason is that it is hard to see the beginning and the end of each sentence right now.

@mcollina mcollina force-pushed the fix-http-dump-test branch from c93afee to 010c26c Compare April 6, 2018 22:10
@mcollina
Copy link
Member Author

mcollina commented Apr 6, 2018

@Trott
Copy link
Member

Trott commented Apr 7, 2018

This fixes the common.mustNotCall problem identified by @lpinca but the test is still sensitive to resource availability so we still need to do #19819 as well. I'll land that now and then resolve any resulting merge conflict that ends up here.

@Trott
Copy link
Member

Trott commented Apr 7, 2018

(I imagine this also fixes the EPIPE issue that was one of the two ways the test fails in #19139.)

@Trott Trott force-pushed the fix-http-dump-test branch from 010c26c to 37ae792 Compare April 7, 2018 04:05
@Trott
Copy link
Member

Trott commented Apr 7, 2018

@lpinca
Copy link
Member

lpinca commented Apr 7, 2018

so we still need to do #19819 as well

Do we? I don't think this is still flaky after this rewrite.

@mcollina
Copy link
Member Author

mcollina commented Apr 7, 2018

I don’t think #19819 was needed.

@mcollina mcollina force-pushed the fix-http-dump-test branch from 37ae792 to 8e245ea Compare April 7, 2018 08:02
@mcollina
Copy link
Member Author

mcollina commented Apr 7, 2018

Landed as 1f29963

@mcollina mcollina closed this Apr 7, 2018
mcollina added a commit that referenced this pull request Apr 7, 2018
Make sure the dump test actually verify what is happening and it is
not flaky.

See: #19139
PR-URL: #19823
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@Trott
Copy link
Member

Trott commented Apr 7, 2018

I don’t think #19819 was needed.

It was needed. I landed this PR on top of master locally on my machine and ran the test under system load and it was still failing.

@Trott
Copy link
Member

Trott commented Apr 7, 2018

Here's the demo that this alone wasn't enough to fix the test for parallel runs:

$ make -j4
[...SNIP...]
$ git rev-parse HEAD
1f29963eacf587817a6d40da527d05d151668198
$ cp test/sequential/test-http-dump-req-when-res-ends.js test/parallel/test-http-dump-req-when-res-ends.js                                  
$ tools/test.py -j 8 --repeat 192 test/parallel/test-http-dump-req-when-res-ends.js 
=== release test-http-dump-req-when-res-ends ===                    
Path: parallel/test-http-dump-req-when-res-ends
Mismatched <anonymous> function calls. Expected at least 1, actual 0.
    at Object.exports.mustCallAtLeast (/Users/trott/io.js/test/common/index.js:431:10)
    at IncomingMessage.<anonymous> (/Users/trott/io.js/test/parallel/test-http-dump-req-when-res-ends.js:18:27)
    at IncomingMessage.<anonymous> (/Users/trott/io.js/test/common/index.js:467:15)
    at IncomingMessage.emit (events.js:182:13)
    at resume_ (_stream_readable.js:898:10)
    at process._tickCallback (internal/process/next_tick.js:174:19)
Command: out/Release/node /Users/trott/io.js/test/parallel/test-http-dump-req-when-res-ends.js
=== release test-http-dump-req-when-res-ends ===                    
Path: parallel/test-http-dump-req-when-res-ends
Mismatched <anonymous> function calls. Expected at least 1, actual 0.
    at Object.exports.mustCallAtLeast (/Users/trott/io.js/test/common/index.js:431:10)
    at IncomingMessage.<anonymous> (/Users/trott/io.js/test/parallel/test-http-dump-req-when-res-ends.js:18:27)
    at IncomingMessage.<anonymous> (/Users/trott/io.js/test/common/index.js:467:15)
    at IncomingMessage.emit (events.js:182:13)
    at resume_ (_stream_readable.js:898:10)
    at process._tickCallback (internal/process/next_tick.js:174:19)
Command: out/Release/node /Users/trott/io.js/test/parallel/test-http-dump-req-when-res-ends.js
=== release test-http-dump-req-when-res-ends ===                    
Path: parallel/test-http-dump-req-when-res-ends
Mismatched <anonymous> function calls. Expected at least 1, actual 0.
    at Object.exports.mustCallAtLeast (/Users/trott/io.js/test/common/index.js:431:10)
    at IncomingMessage.<anonymous> (/Users/trott/io.js/test/parallel/test-http-dump-req-when-res-ends.js:18:27)
    at IncomingMessage.<anonymous> (/Users/trott/io.js/test/common/index.js:467:15)
    at IncomingMessage.emit (events.js:182:13)
    at resume_ (_stream_readable.js:898:10)
    at process._tickCallback (internal/process/next_tick.js:174:19)
Command: out/Release/node /Users/trott/io.js/test/parallel/test-http-dump-req-when-res-ends.js
[00:11|% 100|+ 189|-   3]: Done 
$

lpinca added a commit to lpinca/node that referenced this pull request Apr 8, 2018
Fix test-http-dump-req-when-res-ends and move it back to test/parallel/

Refs: nodejs#19823
@mcollina mcollina deleted the fix-http-dump-test branch April 9, 2018 07:49
@mcollina
Copy link
Member Author

mcollina commented Apr 9, 2018

@Trott on my Macbook:

~/Repositories/node (master)
$ git rev-parse HEAD
1f29963eacf587817a6d40da527d05d151668198
~/Repositories/node (master)
$ tools/test.py -j 8 --repeat 192 test/sequential/test-http-dump-req-when-res-ends.js
[00:35|% 100|+ 192|-   0]: Done

So, something weirder was at play here, but I think @lpinca is on to something in #19866.

@Trott
Copy link
Member

Trott commented Apr 9, 2018

@mcollina Try a bigger -j value. I usually don't trust a test until I can do -j 96 --repeat 192. I showed -j 8 because it was the lowest value I triggered it at. (You probably have a newer/more powerful laptop than I do. In fact, I pretty much guarantee it.)

lpinca added a commit that referenced this pull request Apr 11, 2018
Fix test-http-dump-req-when-res-ends and move it back to test/parallel/

PR-URL: #19866
Refs: #19823
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
jasnell pushed a commit that referenced this pull request Apr 16, 2018
Fix test-http-dump-req-when-res-ends and move it back to test/parallel/

PR-URL: #19866
Refs: #19823
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 1, 2018
Make sure the dump test actually verify what is happening and it is
not flaky.

See: nodejs#19139
PR-URL: nodejs#19823
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants