diff options
author | Refael Ackermann <refack@gmail.com> | 2017-05-18 18:58:00 -0400 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-06-09 17:14:44 -0400 |
commit | c9d45c4505a35e974c1c4b56f2ed699f2694aa14 (patch) | |
tree | b6f078f4240c76b1a5099b167836094f9e318adc /test/known_issues | |
parent | 52f358b5316a40b481a8298239ae1727e1d2bdaa (diff) | |
download | android-node-v8-c9d45c4505a35e974c1c4b56f2ed699f2694aa14.tar.gz android-node-v8-c9d45c4505a35e974c1c4b56f2ed699f2694aa14.tar.bz2 android-node-v8-c9d45c4505a35e974c1c4b56f2ed699f2694aa14.zip |
test: harden test-dgram-bind-shared-ports
* add `mustCall` and `mustNotCall` to all callbacks
* added `known_issue` for port binding
PR-URL: https://github.com/nodejs/node/pull/13100
Refs: https://github.com/nodejs/node/issues/13055
Refs: https://github.com/nodejs/node/pull/12999
Refs: https://github.com/nodejs/node/issues/13526
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/known_issues')
-rw-r--r-- | test/known_issues/test-dgram-bind-shared-ports-after-port-0.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js b/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js new file mode 100644 index 0000000000..7b750c765b --- /dev/null +++ b/test/known_issues/test-dgram-bind-shared-ports-after-port-0.js @@ -0,0 +1,56 @@ +'use strict'; +const common = require('../common'); + +// This test should fail because at present `cluster` does not know how to share +// a socket when `worker1` binds with `port: 0`, and others try to bind to the +// assigned port number from `worker1` +// +// *Note*: since this is a `known_issue` we try to swallow all errors except +// the one we are interested in + +const assert = require('assert'); +const cluster = require('cluster'); +const dgram = require('dgram'); +const BYE = 'bye'; + +if (cluster.isMaster) { + const worker1 = cluster.fork(); + + // verify that Windows doesn't support this scenario + worker1.on('error', (err) => { + if (err.code === 'ENOTSUP') throw err; + }); + + worker1.on('message', (msg) => { + if (typeof msg !== 'object') process.exit(0); + if (msg.message !== 'success') process.exit(0); + if (typeof msg.port1 !== 'number') process.exit(0); + + const worker2 = cluster.fork({ PRT1: msg.port1 }); + worker2.on('message', () => process.exit(0)); + worker2.on('exit', (code, signal) => { + // this is the droid we are looking for + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + }); + + // cleanup anyway + process.on('exit', () => { + worker1.send(BYE); + worker2.send(BYE); + }); + }); + // end master code +} else { + // worker code + process.on('message', (msg) => msg === BYE && process.exit(0)); + + // first worker will bind to '0', second will try the assigned port and fail + const PRT1 = process.env.PRT1 || 0; + const socket1 = dgram.createSocket('udp4', () => {}); + socket1.on('error', PRT1 === 0 ? () => {} : assert.fail); + socket1.bind( + { address: common.localhostIPv4, port: PRT1, exclusive: false }, + () => process.send({ message: 'success', port1: socket1.address().port }) + ); +} |