summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-10-08 14:35:07 +0400
committerFedor Indutny <fedor@indutny.com>2014-10-08 15:44:40 +0400
commitd87480beb29b764ba37cd983b594ad25a406a4c7 (patch)
tree5c8b7b0eaa2becf73d8a649c1fdbc54733086381
parent685ac099e9d8085c363a51a15c718d160a6dcd5c (diff)
downloadnode-d87480beb29b764ba37cd983b594ad25a406a4c7.tar.gz
test: fix debug-signal-cluster after da update
The cluster children are hitting breakpoint at `cluster.onread` and hanging on a Semaphore wait now. This prevents them from disconnecting gracefully. Considering that the test is checking different thing, the cluster children needs to be force killed from the grand parent process. Reviewed-By: Trevor Norris <trevnorris@gmail.com> PR-URL: https://github.com/joyent/node/pull/8476
-rw-r--r--test/fixtures/clustered-server/app.js10
-rw-r--r--test/simple/test-debug-signal-cluster.js26
2 files changed, 32 insertions, 4 deletions
diff --git a/test/fixtures/clustered-server/app.js b/test/fixtures/clustered-server/app.js
index 4053cd3af..3fca2aaa4 100644
--- a/test/fixtures/clustered-server/app.js
+++ b/test/fixtures/clustered-server/app.js
@@ -16,6 +16,16 @@ if (cluster.isMaster) {
}
});
+ process.on('message', function(msg) {
+ if (msg.type === 'getpids') {
+ var pids = [];
+ pids.push(process.pid);
+ for (var key in cluster.workers)
+ pids.push(cluster.workers[key].process.pid);
+ process.send({ type: 'pids', pids: pids });
+ }
+ });
+
for (var i = 0; i < NUMBER_OF_WORKERS; i++) {
cluster.fork();
}
diff --git a/test/simple/test-debug-signal-cluster.js b/test/simple/test-debug-signal-cluster.js
index 09dc3b4c2..27d53910b 100644
--- a/test/simple/test-debug-signal-cluster.js
+++ b/test/simple/test-debug-signal-cluster.js
@@ -24,11 +24,15 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var args = [ common.fixturesDir + '/clustered-server/app.js' ];
-var child = spawn(process.execPath, args);
+var child = spawn(process.execPath, args, {
+ stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ]
+});
var outputLines = [];
var outputTimerId;
var waitingForDebuggers = false;
+var pids = null;
+
child.stderr.on('data', function(data) {
var lines = data.toString().replace(/\r/g, '').trim().split('\n');
var line = lines[0];
@@ -42,8 +46,20 @@ child.stderr.on('data', function(data) {
outputLines = outputLines.concat(lines);
outputTimerId = setTimeout(onNoMoreLines, 800);
} else if (line === 'all workers are running') {
- waitingForDebuggers = true;
- process._debugProcess(child.pid);
+ child.on('message', function(msg) {
+ if (msg.type !== 'pids')
+ return;
+
+ pids = msg.pids;
+ console.error('got pids %j', pids);
+
+ waitingForDebuggers = true;
+ process._debugProcess(child.pid);
+ });
+
+ child.send({
+ type: 'getpids'
+ });
}
});
@@ -57,7 +73,9 @@ setTimeout(function testTimedOut() {
}, 6000);
process.on('exit', function onExit() {
- child.kill();
+ pids.forEach(function(pid) {
+ process.kill(pid);
+ });
});
function assertOutputLines() {