Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f88cbd

Browse filesBrowse files
realwakkaaddaleax
authored andcommitted
test: refactor test-http-server-keep-alive-timeout
Make the same reliability changes that were applied to the https test in ce5745b. Refs: #13312 PR-URL: #13448 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
1 parent bdbeb33 commit 1f88cbd
Copy full SHA for 1f88cbd

File tree

Expand file treeCollapse file tree

1 file changed

+10
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-28
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-server-keep-alive-timeout.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-server-keep-alive-timeout.js
+10-28Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,20 @@ function run() {
2020
}
2121

2222
test(function serverEndKeepAliveTimeoutWithPipeline(cb) {
23-
let socket;
24-
let destroyedSockets = 0;
25-
let timeoutCount = 0;
2623
let requestCount = 0;
2724
process.on('exit', () => {
28-
assert.strictEqual(timeoutCount, 1);
2925
assert.strictEqual(requestCount, 3);
30-
assert.strictEqual(destroyedSockets, 1);
3126
});
3227
const server = http.createServer((req, res) => {
33-
socket = req.socket;
3428
requestCount++;
3529
res.end();
3630
});
37-
server.setTimeout(200, (socket) => {
38-
timeoutCount++;
31+
server.setTimeout(500, common.mustCall((socket) => {
32+
// End this test and call `run()` for the next test (if any).
3933
socket.destroy();
40-
});
34+
server.close();
35+
cb();
36+
}));
4137
server.keepAliveTimeout = 50;
4238
server.listen(0, common.mustCall(() => {
4339
const options = {
@@ -49,32 +45,23 @@ test(function serverEndKeepAliveTimeoutWithPipeline(cb) {
4945
c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
5046
c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
5147
});
52-
setTimeout(() => {
53-
server.close();
54-
if (socket.destroyed) destroyedSockets++;
55-
cb();
56-
}, 1000);
5748
}));
5849
});
5950

6051
test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) {
61-
let socket;
62-
let destroyedSockets = 0;
63-
let timeoutCount = 0;
6452
let requestCount = 0;
6553
process.on('exit', () => {
66-
assert.strictEqual(timeoutCount, 1);
6754
assert.strictEqual(requestCount, 3);
68-
assert.strictEqual(destroyedSockets, 1);
6955
});
7056
const server = http.createServer((req, res) => {
71-
socket = req.socket;
7257
requestCount++;
7358
});
74-
server.setTimeout(200, (socket) => {
75-
timeoutCount++;
59+
server.setTimeout(500, common.mustCall((socket) => {
60+
// End this test and call `run()` for the next test (if any).
7661
socket.destroy();
77-
});
62+
server.close();
63+
cb();
64+
}));
7865
server.keepAliveTimeout = 50;
7966
server.listen(0, common.mustCall(() => {
8067
const options = {
@@ -86,10 +73,5 @@ test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) {
8673
c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
8774
c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
8875
});
89-
setTimeout(() => {
90-
server.close();
91-
if (socket.destroyed) destroyedSockets++;
92-
cb();
93-
}, 1000);
9476
}));
9577
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.