test: rename regression tests more expressively
PR-URL: https://github.com/nodejs/node/pull/19495 Refs: https://github.com/nodejs/node/issues/19105 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
ca22c96f16
commit
eeb57022e6
@ -1,8 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
// This test ensures Math functions don't fail with an "illegal instruction"
|
||||||
|
// error on ARM devices (primarily on the Raspberry Pi 1)
|
||||||
// See https://github.com/nodejs/node/issues/1376
|
// See https://github.com/nodejs/node/issues/1376
|
||||||
// and https://code.google.com/p/v8/issues/detail?id=4019
|
// and https://code.google.com/p/v8/issues/detail?id=4019
|
||||||
|
|
||||||
require('../common');
|
|
||||||
Math.abs(-0.5);
|
Math.abs(-0.5);
|
||||||
Math.acos(-0.5);
|
Math.acos(-0.5);
|
||||||
Math.acosh(-0.5);
|
Math.acosh(-0.5);
|
@ -1,10 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
|
// This test ensures that Node.js throws a RangeError when trying to convert a
|
||||||
|
// gigantic buffer into a string.
|
||||||
|
// Regression test for https://github.com/nodejs/node/issues/649.
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const SlowBuffer = require('buffer').SlowBuffer;
|
const SlowBuffer = require('buffer').SlowBuffer;
|
||||||
|
|
||||||
// Regression test for https://github.com/nodejs/node/issues/649.
|
|
||||||
const len = 1422561062959;
|
const len = 1422561062959;
|
||||||
const message = common.expectsError({
|
const message = common.expectsError({
|
||||||
code: 'ERR_INVALID_OPT_VALUE',
|
code: 'ERR_INVALID_OPT_VALUE',
|
@ -20,9 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
// Remove this test once we support sending strings.
|
|
||||||
|
|
||||||
require('../common');
|
require('../common');
|
||||||
|
|
||||||
|
// This test ensures that a TypeError is raised when the argument to `send()`
|
||||||
|
// or `sendto()` is anything but a Buffer.
|
||||||
|
// https://github.com/nodejs/node-v0.x-archive/issues/4496
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
|
|
@ -21,18 +21,25 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
|
// This test ensures `dns.resolveNs()` does not raise a C++-land assertion error
|
||||||
|
// and throw a JavaScript TypeError instead.
|
||||||
|
// Issue https://github.com/nodejs/node-v0.x-archive/issues/7070
|
||||||
|
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
|
|
||||||
// Should not raise assertion error.
|
common.expectsError(
|
||||||
// Issue https://github.com/nodejs/node-v0.x-archive/issues/7070
|
() => dns.resolveNs([]), // bad name
|
||||||
common.expectsError(() => dns.resolveNs([]), // bad name
|
{
|
||||||
{
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
type: TypeError,
|
||||||
type: TypeError,
|
message: /^The "name" argument must be of type string/
|
||||||
message: /^The "name" argument must be of type string/
|
}
|
||||||
});
|
);
|
||||||
common.expectsError(() => dns.resolveNs(''), // bad callback
|
common.expectsError(
|
||||||
{
|
() => dns.resolveNs(''), // bad callback
|
||||||
code: 'ERR_INVALID_CALLBACK',
|
{
|
||||||
type: TypeError
|
code: 'ERR_INVALID_CALLBACK',
|
||||||
});
|
type: TypeError
|
||||||
|
}
|
||||||
|
);
|
@ -1,41 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const http = require('http');
|
|
||||||
const Countdown = require('../common/countdown');
|
|
||||||
|
|
||||||
const MAX_SOCKETS = 2;
|
|
||||||
|
|
||||||
const agent = new http.Agent({
|
|
||||||
keepAlive: true,
|
|
||||||
keepAliveMsecs: 1000,
|
|
||||||
maxSockets: MAX_SOCKETS,
|
|
||||||
maxFreeSockets: 2
|
|
||||||
});
|
|
||||||
|
|
||||||
const server = http.createServer(common.mustCall((req, res) => {
|
|
||||||
res.end('hello world');
|
|
||||||
}, 6));
|
|
||||||
|
|
||||||
const countdown = new Countdown(6, () => server.close());
|
|
||||||
|
|
||||||
function get(path, callback) {
|
|
||||||
return http.get({
|
|
||||||
host: 'localhost',
|
|
||||||
port: server.address().port,
|
|
||||||
agent: agent,
|
|
||||||
path: path
|
|
||||||
}, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
server.listen(0, common.mustCall(() => {
|
|
||||||
for (let i = 0; i < 6; i++) {
|
|
||||||
const request = get('/1', common.mustCall());
|
|
||||||
request.on('response', common.mustCall(() => {
|
|
||||||
request.abort();
|
|
||||||
const sockets = agent.sockets[Object.keys(agent.sockets)[0]];
|
|
||||||
assert(sockets.length <= MAX_SOCKETS);
|
|
||||||
countdown.dec();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}));
|
|
56
test/parallel/test-http-agent-maxsockets-respected.js
Normal file
56
test/parallel/test-http-agent-maxsockets-respected.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const Countdown = require('../common/countdown');
|
||||||
|
|
||||||
|
// This test ensures that the `maxSockets` value for `http.Agent` is respected.
|
||||||
|
// https://github.com/nodejs/node/issues/4050
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
const MAX_SOCKETS = 2;
|
||||||
|
|
||||||
|
const agent = new http.Agent({
|
||||||
|
keepAlive: true,
|
||||||
|
keepAliveMsecs: 1000,
|
||||||
|
maxSockets: MAX_SOCKETS,
|
||||||
|
maxFreeSockets: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
const server = http.createServer(
|
||||||
|
common.mustCall((req, res) => {
|
||||||
|
res.end('hello world');
|
||||||
|
}, 6)
|
||||||
|
);
|
||||||
|
|
||||||
|
const countdown = new Countdown(6, () => server.close());
|
||||||
|
|
||||||
|
function get(path, callback) {
|
||||||
|
return http.get(
|
||||||
|
{
|
||||||
|
host: 'localhost',
|
||||||
|
port: server.address().port,
|
||||||
|
agent: agent,
|
||||||
|
path: path
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.listen(
|
||||||
|
0,
|
||||||
|
common.mustCall(() => {
|
||||||
|
for (let i = 0; i < 6; i++) {
|
||||||
|
const request = get('/1', common.mustCall());
|
||||||
|
request.on(
|
||||||
|
'response',
|
||||||
|
common.mustCall(() => {
|
||||||
|
request.abort();
|
||||||
|
const sockets = agent.sockets[Object.keys(agent.sockets)[0]];
|
||||||
|
assert(sockets.length <= MAX_SOCKETS);
|
||||||
|
countdown.dec();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user