diff options
author | Rich Trott <rtrott@gmail.com> | 2019-11-28 23:42:12 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-12-01 02:42:27 -0800 |
commit | 5b52a62ab153ad2b06164b8b7904581869c3c96c (patch) | |
tree | e5e311809eb6414499adaa53defe87b37e46f33e /test/parallel/test-set-http-max-http-headers.js | |
parent | 05c5ebbe12db965bcf3fa0f652352fb337b09723 (diff) | |
download | android-node-v8-5b52a62ab153ad2b06164b8b7904581869c3c96c.tar.gz android-node-v8-5b52a62ab153ad2b06164b8b7904581869c3c96c.tar.bz2 android-node-v8-5b52a62ab153ad2b06164b8b7904581869c3c96c.zip |
test: move test-http-max-http-headers to parallel
test-http-max-http-headers seems to run fine in parallel, even with
`tools/test.py -j 96 --repeat 192
test/parallel/test-http-max-http-headers.js`.
The same applies to `test-set-http-max-http-headers.js` which (as
written) depends on `test-http-max-http-headers.js` being in the same
directory. So that is being moved too.
PR-URL: https://github.com/nodejs/node/pull/30712
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-set-http-max-http-headers.js')
-rw-r--r-- | test/parallel/test-set-http-max-http-headers.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/test/parallel/test-set-http-max-http-headers.js b/test/parallel/test-set-http-max-http-headers.js new file mode 100644 index 0000000000..c4df779d2b --- /dev/null +++ b/test/parallel/test-set-http-max-http-headers.js @@ -0,0 +1,102 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const { spawn } = require('child_process'); +const path = require('path'); +const testName = path.join(__dirname, 'test-http-max-http-headers.js'); + +const timeout = common.platformTimeout(100); + +const tests = []; + +function test(fn) { + tests.push(fn); +} + +test(function(cb) { + console.log('running subtest expecting failure'); + + // Validate that the test fails if the max header size is too small. + const args = ['--expose-internals', + '--max-http-header-size=1024', + testName]; + const cp = spawn(process.execPath, args, { stdio: 'inherit' }); + + cp.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + cb(); + })); +}); + +test(function(cb) { + console.log('running subtest expecting success'); + + const env = Object.assign({}, process.env, { + NODE_DEBUG: 'http' + }); + + // Validate that the test now passes if the same limit is large enough. + const args = ['--expose-internals', + '--max-http-header-size=1024', + testName, + '1024']; + const cp = spawn(process.execPath, args, { + env, + stdio: 'inherit' + }); + + cp.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + cb(); + })); +}); + +// Next, repeat the same checks using NODE_OPTIONS if it is supported. +if (!process.config.variables.node_without_node_options) { + const env = Object.assign({}, process.env, { + NODE_OPTIONS: '--max-http-header-size=1024' + }); + + test(function(cb) { + console.log('running subtest expecting failure'); + + // Validate that the test fails if the max header size is too small. + const args = ['--expose-internals', testName]; + const cp = spawn(process.execPath, args, { env, stdio: 'inherit' }); + + cp.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + cb(); + })); + }); + + test(function(cb) { + // Validate that the test now passes if the same limit is large enough. + const args = ['--expose-internals', testName, '1024']; + const cp = spawn(process.execPath, args, { env, stdio: 'inherit' }); + + cp.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + cb(); + })); + }); +} + +function runTest() { + const fn = tests.shift(); + + if (!fn) { + return; + } + + fn(() => { + setTimeout(runTest, timeout); + }); +} + +runTest(); |