test: update test-cluster-shared-handle-bind-error
- Remove assignment of this to variable. - Add common.mustCall() as needed. - Move from var to const. PR-URL: https://github.com/nodejs/node/pull/10547 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
1d11b47aa7
commit
b978aff719
@ -1,25 +1,26 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
var net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
// Master opens and binds the socket and shares it with the worker.
|
// Master opens and binds the socket and shares it with the worker.
|
||||||
cluster.schedulingPolicy = cluster.SCHED_NONE;
|
cluster.schedulingPolicy = cluster.SCHED_NONE;
|
||||||
// Hog the TCP port so that when the worker tries to bind, it'll fail.
|
// Hog the TCP port so that when the worker tries to bind, it'll fail.
|
||||||
net.createServer(common.fail).listen(common.PORT, function() {
|
const server = net.createServer(common.fail);
|
||||||
var server = this;
|
|
||||||
var worker = cluster.fork();
|
server.listen(common.PORT, common.mustCall(() => {
|
||||||
worker.on('exit', common.mustCall(function(exitCode) {
|
const worker = cluster.fork();
|
||||||
|
worker.on('exit', common.mustCall((exitCode) => {
|
||||||
assert.strictEqual(exitCode, 0);
|
assert.strictEqual(exitCode, 0);
|
||||||
server.close();
|
server.close();
|
||||||
}));
|
}));
|
||||||
});
|
}));
|
||||||
} else {
|
} else {
|
||||||
var s = net.createServer(common.fail);
|
const s = net.createServer(common.fail);
|
||||||
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
|
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
|
||||||
s.on('error', common.mustCall(function(err) {
|
s.on('error', common.mustCall((err) => {
|
||||||
assert.strictEqual(err.code, 'EADDRINUSE');
|
assert.strictEqual(err.code, 'EADDRINUSE');
|
||||||
process.disconnect();
|
process.disconnect();
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user