Skip to content

Commit a701dfb

Browse files
Trottrvagg
authored andcommitted
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: #24456 PR-URL: #24631 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 8849d80 commit a701dfb

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

test/parallel/parallel.status

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ test-net-connect-options-port: PASS,FLAKY
1212
test-http2-pipe: PASS,FLAKY
1313
test-worker-syntax-error: PASS,FLAKY
1414
test-worker-syntax-error-file: PASS,FLAKY
15+
# https://github.com/nodejs/node/issues/24456
16+
test-stream-pipeline-http2: PASS,FLAKY
1517

1618
[$system==linux]
1719

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const { Readable, pipeline } = require('stream');
7+
const http2 = require('http2');
8+
9+
{
10+
const server = http2.createServer((req, res) => {
11+
pipeline(req, res, common.mustCall());
12+
});
13+
14+
server.listen(0, () => {
15+
const url = `http://localhost:${server.address().port}`;
16+
const client = http2.connect(url);
17+
const req = client.request({ ':method': 'POST' });
18+
19+
const rs = new Readable({
20+
read() {
21+
rs.push('hello');
22+
}
23+
});
24+
25+
pipeline(rs, req, common.mustCall((err) => {
26+
server.close();
27+
client.close();
28+
}));
29+
30+
let cnt = 10;
31+
req.on('data', (data) => {
32+
cnt--;
33+
if (cnt === 0) rs.destroy();
34+
});
35+
});
36+
}

test/parallel/test-stream-pipeline.js

-32
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
'use strict';
22

33
const common = require('../common');
4-
if (!common.hasCrypto)
5-
common.skip('missing crypto');
64
const { Stream, Writable, Readable, Transform, pipeline } = require('stream');
75
const assert = require('assert');
86
const http = require('http');
9-
const http2 = require('http2');
107
const { promisify } = require('util');
118

129
{
@@ -275,35 +272,6 @@ const { promisify } = require('util');
275272
});
276273
}
277274

278-
{
279-
const server = http2.createServer((req, res) => {
280-
pipeline(req, res, common.mustCall());
281-
});
282-
283-
server.listen(0, () => {
284-
const url = `http://localhost:${server.address().port}`;
285-
const client = http2.connect(url);
286-
const req = client.request({ ':method': 'POST' });
287-
288-
const rs = new Readable({
289-
read() {
290-
rs.push('hello');
291-
}
292-
});
293-
294-
pipeline(rs, req, common.mustCall((err) => {
295-
server.close();
296-
client.close();
297-
}));
298-
299-
let cnt = 10;
300-
req.on('data', (data) => {
301-
cnt--;
302-
if (cnt === 0) rs.destroy();
303-
});
304-
});
305-
}
306-
307275
{
308276
const makeTransform = () => {
309277
const tr = new Transform({

0 commit comments

Comments
 (0)