From a701dfbb2baf5e18eb77210c7d2347e16fc38342 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 24 Nov 2018 11:27:15 -0800 Subject: [PATCH] test: split out http2 from test-stream-pipeline Splitting out the http2 portion of the test has a few benfits: * We don't skip the rest of the tests if `node` is compiled without crypto. * We can find out if the http2 portion of the test is responsible for the timeouts reported in issue 24456. Refs: https://github.com/nodejs/node/issues/24456 PR-URL: https://github.com/nodejs/node/pull/24631 Reviewed-By: Refael Ackermann Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- test/parallel/parallel.status | 2 ++ test/parallel/test-stream-pipeline-http2.js | 36 +++++++++++++++++++++ test/parallel/test-stream-pipeline.js | 32 ------------------ 3 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 test/parallel/test-stream-pipeline-http2.js diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index b45e4448d97c06..cfc4e36e9a565f 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -12,6 +12,8 @@ test-net-connect-options-port: PASS,FLAKY test-http2-pipe: PASS,FLAKY test-worker-syntax-error: PASS,FLAKY test-worker-syntax-error-file: PASS,FLAKY +# https://github.com/nodejs/node/issues/24456 +test-stream-pipeline-http2: PASS,FLAKY [$system==linux] diff --git a/test/parallel/test-stream-pipeline-http2.js b/test/parallel/test-stream-pipeline-http2.js new file mode 100644 index 00000000000000..d7ff08888afb8a --- /dev/null +++ b/test/parallel/test-stream-pipeline-http2.js @@ -0,0 +1,36 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const { Readable, pipeline } = require('stream'); +const http2 = require('http2'); + +{ + const server = http2.createServer((req, res) => { + pipeline(req, res, common.mustCall()); + }); + + server.listen(0, () => { + const url = `http://localhost:${server.address().port}`; + const client = http2.connect(url); + const req = client.request({ ':method': 'POST' }); + + const rs = new Readable({ + read() { + rs.push('hello'); + } + }); + + pipeline(rs, req, common.mustCall((err) => { + server.close(); + client.close(); + })); + + let cnt = 10; + req.on('data', (data) => { + cnt--; + if (cnt === 0) rs.destroy(); + }); + }); +} diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 84fb01fe0dd48e..34928794cdc396 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -1,12 +1,9 @@ 'use strict'; const common = require('../common'); -if (!common.hasCrypto) - common.skip('missing crypto'); const { Stream, Writable, Readable, Transform, pipeline } = require('stream'); const assert = require('assert'); const http = require('http'); -const http2 = require('http2'); const { promisify } = require('util'); { @@ -275,35 +272,6 @@ const { promisify } = require('util'); }); } -{ - const server = http2.createServer((req, res) => { - pipeline(req, res, common.mustCall()); - }); - - server.listen(0, () => { - const url = `http://localhost:${server.address().port}`; - const client = http2.connect(url); - const req = client.request({ ':method': 'POST' }); - - const rs = new Readable({ - read() { - rs.push('hello'); - } - }); - - pipeline(rs, req, common.mustCall((err) => { - server.close(); - client.close(); - })); - - let cnt = 10; - req.on('data', (data) => { - cnt--; - if (cnt === 0) rs.destroy(); - }); - }); -} - { const makeTransform = () => { const tr = new Transform({