Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update test-cluster-shared-handle-bind-error #10547

Merged
merged 1 commit into from
Jan 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions test/parallel/test-cluster-shared-handle-bind-error.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (cluster.isMaster) {
// Master opens and binds the socket and shares it with the worker.
cluster.schedulingPolicy = cluster.SCHED_NONE;
// Hog the TCP port so that when the worker tries to bind, it'll fail.
net.createServer(common.fail).listen(common.PORT, function() {
var server = this;
var worker = cluster.fork();
worker.on('exit', common.mustCall(function(exitCode) {
const server = net.createServer(common.fail);

server.listen(common.PORT, common.mustCall(() => {
const worker = cluster.fork();
worker.on('exit', common.mustCall((exitCode) => {
assert.strictEqual(exitCode, 0);
server.close();
}));
});
}));
} 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.on('error', common.mustCall(function(err) {
s.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'EADDRINUSE');
process.disconnect();
}));
Expand Down