Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ce3b544

Browse filesBrowse files
Sebastian PlesciucMylesBorins
authored andcommitted
test: dynamic port in cluster worker send
Remove common.PORT from test-cluster-send-deadlock and test-cluster-send-handle-twice to reduce possibility that a dynamic port used in another test will collide with common.PORT. PR-URL: #12472 Ref: #12376 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent a755ef0 commit ce3b544
Copy full SHA for ce3b544

File tree

Expand file treeCollapse file tree

2 files changed

+12
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-8
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-cluster-send-deadlock.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-send-deadlock.js
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Testing mutual send of handles: from master to worker, and from worker to
33
// master.
44

5-
const common = require('../common');
5+
require('../common');
66
const assert = require('assert');
77
const cluster = require('cluster');
88
const net = require('net');
@@ -19,14 +19,15 @@ if (cluster.isMaster) {
1919
worker.send('handle', socket);
2020
});
2121

22-
server.listen(common.PORT, function() {
23-
worker.send('listen');
22+
server.listen(0, function() {
23+
worker.send({message: 'listen', port: server.address().port});
2424
});
2525
} else {
2626
process.on('message', function(msg, handle) {
27-
if (msg === 'listen') {
28-
const client1 = net.connect({ host: 'localhost', port: common.PORT });
29-
const client2 = net.connect({ host: 'localhost', port: common.PORT });
27+
if (msg.message && msg.message === 'listen') {
28+
assert(msg.port);
29+
const client1 = net.connect({ host: 'localhost', port: msg.port });
30+
const client2 = net.connect({ host: 'localhost', port: msg.port });
3031
let waiting = 2;
3132
client1.on('close', onclose);
3233
client2.on('close', onclose);
Collapse file

‎test/parallel/test-cluster-send-handle-twice.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-send-handle-twice.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ if (cluster.isMaster) {
2424
process.send('send-handle-2', socket);
2525
});
2626

27-
server.listen(common.PORT, function() {
28-
const client = net.connect({ host: 'localhost', port: common.PORT });
27+
server.listen(0, function() {
28+
const client = net.connect({
29+
host: 'localhost',
30+
port: server.address().port
31+
});
2932
client.on('close', common.mustCall(() => { cluster.worker.disconnect(); }));
3033
setTimeout(function() { client.end(); }, 50);
3134
}).on('error', function(e) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.