diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2015-03-30 10:54:59 -0700 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-04-04 00:53:45 +0200 |
commit | b6e22c4bd57831512aef370419db319a3ac15fc2 (patch) | |
tree | 4270afa7c9b6ab676d46e4aea97cd0457cbabcd3 /test | |
parent | 65d4d25f525ada66bda66dddd2e9a40144d2ebf3 (diff) | |
download | android-node-v8-b6e22c4bd57831512aef370419db319a3ac15fc2.tar.gz android-node-v8-b6e22c4bd57831512aef370419db319a3ac15fc2.tar.bz2 android-node-v8-b6e22c4bd57831512aef370419db319a3ac15fc2.zip |
src: setup cluster workers before preloading
We need to process cluster workers before any preload modules is
executed. Otherwise, the child processes are not correctly disovered
as clustered workers inside the preloaded modules.
Fixes: https://github.com/iojs/io.js/issues/1269
PR-URL: https://github.com/iojs/io.js/pull/1314
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/cluster-preload-test.js | 7 | ||||
-rw-r--r-- | test/fixtures/cluster-preload.js | 3 | ||||
-rw-r--r-- | test/parallel/test-preload.js | 8 |
3 files changed, 18 insertions, 0 deletions
diff --git a/test/fixtures/cluster-preload-test.js b/test/fixtures/cluster-preload-test.js new file mode 100644 index 0000000000..43d3887b0d --- /dev/null +++ b/test/fixtures/cluster-preload-test.js @@ -0,0 +1,7 @@ +var cluster = require('cluster'); +if (cluster.isMaster) { + cluster.fork(); // one child + cluster.on('exit', function(worker, code, signal) { + console.log('worker terminated with code ' + code); + }); +} diff --git a/test/fixtures/cluster-preload.js b/test/fixtures/cluster-preload.js new file mode 100644 index 0000000000..651fc480e8 --- /dev/null +++ b/test/fixtures/cluster-preload.js @@ -0,0 +1,3 @@ +var cluster = require('cluster'); +cluster.isMaster || process.exit(42 + cluster.worker.id); // +42 to distinguish +// from exit(1) for other random reasons diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js index aef778b587..643edfb1d9 100644 --- a/test/parallel/test-preload.js +++ b/test/parallel/test-preload.js @@ -72,3 +72,11 @@ child_process.exec(nodeBinary + ' ' if (err) throw err; assert.equal(stdout, 'A\nB\nhello\n'); }); + +child_process.exec(nodeBinary + ' ' + + '--require ' + fixture('cluster-preload.js') + ' ' + + fixture('cluster-preload-test.js'), + function(err, stdout, stderr) { + if (err) throw err; + assert.ok(/worker terminated with code 43/.test(stdout)); + }); |