Skip to content

Commit

Permalink
test: rename tests with descriptive filenames
Browse files Browse the repository at this point in the history
Refs: #19105
Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure

PR-URL: #19608
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
ryzokuken authored and trivikr committed Mar 28, 2018
1 parent 7e07687 commit ff7c2cc
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 231 deletions.
55 changes: 0 additions & 55 deletions test/parallel/test-async-wrap-GH13045.js

This file was deleted.

66 changes: 66 additions & 0 deletions test/parallel/test-async-wrap-tlssocket-asyncreset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) common.skip('missing crypto');
const fixtures = require('../common/fixtures');

// An HTTP Agent reuses a TLSSocket, and makes a failed call to `asyncReset`.
// Refs: https://github.com/nodejs/node/issues/13045

const assert = require('assert');
const https = require('https');

const serverOptions = {
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem'),
ca: fixtures.readKey('ca1-cert.pem')
};

const server = https.createServer(
serverOptions,
common.mustCall((req, res) => {
res.end('hello world\n');
}, 2)
);

server.listen(
0,
common.mustCall(function() {
const port = this.address().port;
const clientOptions = {
agent: new https.Agent({
keepAlive: true,
rejectUnauthorized: false
}),
port: port
};

const req = https.get(
clientOptions,
common.mustCall((res) => {
assert.strictEqual(res.statusCode, 200);
res.on('error', (err) => assert.fail(err));
res.socket.on('error', (err) => assert.fail(err));
res.resume();
// drain the socket and wait for it to be free to reuse
res.socket.once('free', () => {
// This is the pain point. Internally the Agent will call
// `socket._handle.asyncReset()` and if the _handle does not implement
// `asyncReset` this will throw TypeError
const req2 = https.get(
clientOptions,
common.mustCall((res2) => {
assert.strictEqual(res.statusCode, 200);
res2.on('error', (err) => assert.fail(err));
res2.socket.on('error', (err) => assert.fail(err));
// this should be the end of the test
res2.destroy();
server.close();
})
);
req2.on('error', (err) => assert.fail(err));
});
})
);
req.on('error', (err) => assert.fail(err));
})
);
75 changes: 75 additions & 0 deletions test/parallel/test-child-process-fork-closed-channel-segfault.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';
const common = require('../common');

// Before https://github.com/nodejs/node/pull/2847 a child process trying
// (asynchronously) to use the closed channel to it's creator caused a segfault.

const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (!cluster.isMaster) {
// Exit on first received handle to leave the queue non-empty in master
process.on('message', function() {
process.exit(1);
});
return;
}

const server = net
.createServer(function(s) {
if (common.isWindows) {
s.on('error', function(err) {
// Prevent possible ECONNRESET errors from popping up
if (err.code !== 'ECONNRESET') throw err;
});
}
setTimeout(function() {
s.destroy();
}, 100);
})
.listen(0, function() {
const worker = cluster.fork();

function send(callback) {
const s = net.connect(server.address().port, function() {
worker.send({}, s, callback);
});

// https://github.com/nodejs/node/issues/3635#issuecomment-157714683
// ECONNREFUSED or ECONNRESET errors can happen if this connection is
// still establishing while the server has already closed.
// EMFILE can happen if the worker __and__ the server had already closed.
s.on('error', function(err) {
if (
err.code !== 'ECONNRESET' &&
err.code !== 'ECONNREFUSED' &&
err.code !== 'EMFILE'
) {
throw err;
}
});
}

worker.process.once(
'close',
common.mustCall(function() {
// Otherwise the crash on `channel.fd` access may happen
assert.strictEqual(worker.process.channel, null);
server.close();
})
);

worker.on('online', function() {
send(function(err) {
assert.ifError(err);
send(function(err) {
// Ignore errors when sending the second handle because the worker
// may already have exited.
if (err && err.message !== 'Channel closed') {
throw err;
}
});
});
});
});
69 changes: 0 additions & 69 deletions test/parallel/test-child-process-fork-regr-gh-2847.js

This file was deleted.

34 changes: 34 additions & 0 deletions test/parallel/test-http-pipeline-assertionerror-finish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
const common = require('../common');

// This test ensures that Node.js doesn't crash with an AssertionError at
// `ServerResponse.resOnFinish` because of an out-of-order 'finish' bug in
// pipelining.
// https://github.com/nodejs/node/issues/2639

const http = require('http');
const net = require('net');

const COUNT = 10;

const server = http
.createServer(
common.mustCall((req, res) => {
// Close the server, we have only one TCP connection anyway
server.close();
res.writeHead(200);
res.write('data');

setTimeout(function() {
res.end();
}, (Math.random() * 100) | 0);
}, COUNT)
)
.listen(0, function() {
const s = net.connect(this.address().port);

const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);

s.write(big);
s.resume();
});
24 changes: 0 additions & 24 deletions test/parallel/test-http-pipeline-regr-2639.js

This file was deleted.

27 changes: 0 additions & 27 deletions test/parallel/test-http-pipeline-regr-3332.js

This file was deleted.

Loading

0 comments on commit ff7c2cc

Please sign in to comment.