From 30e361883955fb890966cde14bfda824718aa145 Mon Sep 17 00:00:00 2001 From: "d.poellath" Date: Wed, 4 Feb 2015 16:34:42 +0100 Subject: [PATCH 1/2] ! child.test did not exit without error, because child was killed by parent --- test/child.test.js | 58 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/test/child.test.js b/test/child.test.js index 008fd4d..9c9d12a 100644 --- a/test/child.test.js +++ b/test/child.test.js @@ -28,12 +28,12 @@ var task = { }; -test('unkown message', function (t) { +test('unknown message', function (t) { var child = fork(__dirname + '/../lib/child.js'); child.on('message', function (msg) { t.ifError(msg.job); - t.ok(msg.error); + t.ok(msg.error, 'should have error'); t.equal(msg.error, 'unknown message'); if (child.exitCode === null) { child.kill(); @@ -41,7 +41,11 @@ test('unkown message', function (t) { }); child.on('exit', function (code, signal) { - t.ok(code); + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); @@ -64,8 +68,12 @@ test('message without job', function (t) { } }); - child.on('exit', function (code) { - t.ok(code); + child.on('exit', function (code, signal) { + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); @@ -86,8 +94,12 @@ test('message without task', function (t) { } }); - child.on('exit', function (code) { - t.ok(code); + child.on('exit', function (code, signal) { + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); @@ -108,8 +120,12 @@ test('message with invalid task', function (t) { } }); - child.on('exit', function (code) { - t.ok(code); + child.on('exit', function (code, signal) { + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); @@ -138,8 +154,12 @@ test('message with successful task', function (t) { } }); - child.on('exit', function (code) { - t.ok(code); + child.on('exit', function (code, signal) { + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); @@ -168,8 +188,12 @@ test('message with failed task', function (t) { } }); - child.on('exit', function (code) { - t.ok(code); + child.on('exit', function (code, signal) { + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); @@ -206,8 +230,12 @@ test('cancel message', function (t) { } }); - child.on('exit', function (code) { - t.ok(code); + child.on('exit', function (code, signal) { + if (signal == "SIGTERM") { + t.notOk(code, "child.on('exit'): should not have code, if killed by parent"); + } else { + t.ok(code, "child.on('exit'): should have code, if exited normally"); + } t.end(); }); From 965f1faa712e5b8e268398b64f4c528c8ef5ca98 Mon Sep 17 00:00:00 2001 From: "d.poellath" Date: Thu, 5 Feb 2015 13:42:09 +0100 Subject: [PATCH 2/2] + todo's ! should changed way to delete workflow --- lib/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/api.js b/lib/api.js index 4d4263f..d0a66f2 100644 --- a/lib/api.js +++ b/lib/api.js @@ -349,6 +349,9 @@ var API = module.exports = function (opts) { req_id: req.id }; + // TODO should be handled by backend itself + // TODO direct call deleteWorkflow(uuid) + // TODO not necessary to fetch whole workflow backend.getWorkflow(req.params.uuid, function (err, workflow) { if (err) { return next(err.toRestError);