summaryrefslogtreecommitdiff
path: root/test/known_issues
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2017-06-01 13:07:20 -0400
committerRefael Ackermann <refack@gmail.com>2017-06-16 07:14:25 -0400
commitfe2caf6fb587a8373a4e45476a9c86f6b0993861 (patch)
tree00401f07e7bfeacdaccbc581cd5580e9b0ceece5 /test/known_issues
parent9f9e3c0653cdeef597e0f7bc2f5db9d85f8f2ffc (diff)
downloadandroid-node-v8-fe2caf6fb587a8373a4e45476a9c86f6b0993861.tar.gz
android-node-v8-fe2caf6fb587a8373a4e45476a9c86f6b0993861.tar.bz2
android-node-v8-fe2caf6fb587a8373a4e45476a9c86f6b0993861.zip
test: fix test-inspector-port-zero-cluster
* re-implemented test to parse args instead of post binding (exit 12) * saved failing case as known issue PR-URL: https://github.com/nodejs/node/pull/13373 Fixes: https://github.com/nodejs/node/issues/13343 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/known_issues')
-rw-r--r--test/known_issues/test-inspector-cluster-port-clash.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/known_issues/test-inspector-cluster-port-clash.js b/test/known_issues/test-inspector-cluster-port-clash.js
new file mode 100644
index 0000000000..41b00aacc1
--- /dev/null
+++ b/test/known_issues/test-inspector-cluster-port-clash.js
@@ -0,0 +1,63 @@
+// Flags: --inspect=0
+'use strict';
+const common = require('../common');
+
+// With the current behavior of Node.js (at least as late as 8.1.0), this
+// test fails with the following error:
+// `AssertionError [ERR_ASSERTION]: worker 2 failed to bind port`
+// Ideally, there would be a way for the user to opt out of sequential port
+// assignment.
+//
+// Refs: https://github.com/nodejs/node/issues/13343
+
+common.skipIfInspectorDisabled();
+
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
+
+const ports = [process.debugPort];
+const clashPort = process.debugPort + 2;
+function serialFork() {
+ return new Promise((res) => {
+ const worker = cluster.fork();
+ worker.on('error', (err) => assert.fail(err));
+ // no common.mustCall since 1 out of 3 should fail
+ worker.on('online', () => {
+ worker.on('message', common.mustCall((message) => {
+ ports.push(message.debugPort);
+ }));
+ });
+ worker.on('exit', common.mustCall((code, signal) => {
+ assert.strictEqual(signal, null);
+ // worker 2 should fail because of port clash with `server`
+ if (code === 12) {
+ return assert.fail(`worker ${worker.id} failed to bind port`);
+ }
+ assert.strictEqual(0, code);
+ }));
+ worker.on('disconnect', common.mustCall(res));
+ });
+}
+
+if (cluster.isMaster) {
+ cluster.on('online', common.mustCall((worker) => worker.send('dbgport'), 2));
+
+ // block one of the ports with a listening socket
+ const server = net.createServer();
+ server.listen(clashPort, common.localhostIPv4, common.mustCall(() => {
+ // try to fork 3 workers No.2 should fail
+ Promise.all([serialFork(), serialFork(), serialFork()])
+ .then(common.mustNotCall())
+ .catch((err) => console.error(err));
+ }));
+ server.unref();
+} else {
+ const sentinel = common.mustCall();
+ process.on('message', (message) => {
+ if (message !== 'dbgport') return;
+ process.send({ debugPort: process.debugPort });
+ sentinel();
+ process.disconnect();
+ });
+}