Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-08-13 18:58:50 +0300
committerBeth Griggs <Bethany.Griggs@uk.ibm.com>2019-08-15 17:21:23 +0300
commitd85e4006ab931c656496a143f03473ebc69eea29 (patch)
treefc1ece5e8276067c30b417066b39589727980220
parent0acbe05ee2d0e073e52cfe96a9e701dc9891a360 (diff)
test: apply test-http2-max-session-memory-leak from v12.x
Refs: https://github.com/nodejs/node/pull/27914 Backport-PR-URL: https://github.com/nodejs/node/pull/29123 PR-URL: https://github.com/nodejs/node/pull/29122 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r--test/parallel/test-http2-max-session-memory-leak.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/parallel/test-http2-max-session-memory-leak.js b/test/parallel/test-http2-max-session-memory-leak.js
new file mode 100644
index 00000000000..b066ca80bc5
--- /dev/null
+++ b/test/parallel/test-http2-max-session-memory-leak.js
@@ -0,0 +1,46 @@
+'use strict';
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const http2 = require('http2');
+
+// Regression test for https://github.com/nodejs/node/issues/27416.
+// Check that received data is accounted for correctly in the maxSessionMemory
+// mechanism.
+
+const bodyLength = 8192;
+const maxSessionMemory = 1; // 1 MB
+const requestCount = 1000;
+
+const server = http2.createServer({ maxSessionMemory });
+server.on('stream', (stream) => {
+ stream.respond();
+ stream.end();
+});
+
+server.listen(common.mustCall(() => {
+ const client = http2.connect(`http://localhost:${server.address().port}`, {
+ maxSessionMemory
+ });
+
+ function request() {
+ return new Promise((resolve, reject) => {
+ const stream = client.request({
+ ':method': 'POST',
+ 'content-length': bodyLength
+ });
+ stream.on('error', reject);
+ stream.on('response', resolve);
+ stream.end('a'.repeat(bodyLength));
+ });
+ }
+
+ (async () => {
+ for (let i = 0; i < requestCount; i++) {
+ await request();
+ }
+
+ client.close();
+ server.close();
+ })().then(common.mustCall());
+}));