summaryrefslogtreecommitdiff
path: root/test/sequential/test-http-regr-gh-2928.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-01-10 19:27:54 -0800
committerRich Trott <rtrott@gmail.com>2016-01-12 19:49:01 -0800
commit9164c00bdb88acade543f1d0e2cefbb5c14ad0c4 (patch)
treebb025476a247f6be027983d67c7532d986bf805a /test/sequential/test-http-regr-gh-2928.js
parenta254507dfa0901818d5528109a4bc1ead8808be5 (diff)
downloadandroid-node-v8-9164c00bdb88acade543f1d0e2cefbb5c14ad0c4.tar.gz
android-node-v8-9164c00bdb88acade543f1d0e2cefbb5c14ad0c4.tar.bz2
android-node-v8-9164c00bdb88acade543f1d0e2cefbb5c14ad0c4.zip
test: move resource intensive tests to sequential
To enable greater parallelization of tests on CI, move resource intensive tests out of parallel and into sequential. Ref: https://github.com/nodejs/node/pull/4476 PR-URL: https://github.com/nodejs/node/pull/4615 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/sequential/test-http-regr-gh-2928.js')
-rw-r--r--test/sequential/test-http-regr-gh-2928.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js
new file mode 100644
index 0000000000..92cfd9ca35
--- /dev/null
+++ b/test/sequential/test-http-regr-gh-2928.js
@@ -0,0 +1,51 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const httpCommon = require('_http_common');
+const HTTPParser = process.binding('http_parser').HTTPParser;
+const net = require('net');
+
+const PARALLEL = 30;
+const COUNT = httpCommon.parsers.max + 100;
+
+const parsers = new Array(COUNT);
+for (var i = 0; i < parsers.length; i++)
+ parsers[i] = httpCommon.parsers.alloc();
+
+var gotRequests = 0;
+var gotResponses = 0;
+
+function execAndClose() {
+ process.stdout.write('.');
+ if (parsers.length === 0)
+ return;
+
+ const parser = parsers.pop();
+ parser.reinitialize(HTTPParser.RESPONSE);
+ const socket = net.connect(common.PORT);
+ parser.consume(socket._handle._externalStream);
+
+ parser.onIncoming = function onIncoming() {
+ process.stdout.write('+');
+ gotResponses++;
+ parser.unconsume(socket._handle._externalStream);
+ httpCommon.freeParser(parser);
+ socket.destroy();
+ setImmediate(execAndClose);
+ };
+}
+
+var server = net.createServer(function(c) {
+ if (++gotRequests === COUNT)
+ server.close();
+ c.end('HTTP/1.1 200 OK\r\n\r\n', function() {
+ c.destroySoon();
+ });
+}).listen(common.PORT, function() {
+ for (var i = 0; i < PARALLEL; i++)
+ execAndClose();
+});
+
+process.on('exit', function() {
+ assert.equal(gotResponses, COUNT);
+});