Skip to content

Commit

Permalink
test: reduce unmanaged parallelism in domain test
Browse files Browse the repository at this point in the history
The original test lauches 10 child processes at once
and bypass `test.py`'s process regulation.
This PR reduces the unmanaged parallelism and is a
temporary workaround for nodejs#9979 (not a real fix).

PR-URL: nodejs#10329
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
joyeecheung authored and italoacasas committed Jan 19, 2017
1 parent 455c442 commit 20443d9
Show file tree
Hide file tree
Showing 12 changed files with 247 additions and 168 deletions.
22 changes: 22 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
});
});

/*
* Check that when running a test with
* `$node --abort-on-uncaught-exception $file child`
* the process aborts.
*/
exports.childShouldThrowAndAbort = function() {
var testCmd = '';
if (!exports.isWindows) {
// Do not create core files, as it can take a lot of disk space on
// continuous testing and developers' machines
testCmd += 'ulimit -c 0 && ';
}
testCmd += `${process.argv[0]} --abort-on-uncaught-exception `;
testCmd += `${process.argv[1]} child`;
const child = child_process.exec(testCmd);
child.on('exit', function onExit(exitCode, signal) {
const errMsg = 'Test should have aborted ' +
`but instead exited with exit code ${exitCode}` +
` and signal ${signal}`;
assert(exports.nodeProcessAborted(exitCode, signal), errMsg);
});
};

exports.ddCommand = function(filename, kilobytes) {
if (exports.isWindows) {
Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();

d.run(function() {
throw new Error('boom!');
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
21 changes: 21 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();
const d2 = domain.create();

d.run(function() {
d2.run(function() {
throw new Error('boom!');
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
20 changes: 20 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();

d.run(function() {
setTimeout(function() {
throw new Error('boom!');
}, 1);
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
20 changes: 20 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();

d.run(function() {
setImmediate(function() {
throw new Error('boom!');
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
20 changes: 20 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();

d.run(function() {
process.nextTick(function() {
throw new Error('boom!');
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
21 changes: 21 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();

d.run(function() {
var fs = require('fs');
fs.exists('/non/existing/file', function onExists() {
throw new Error('boom!');
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
26 changes: 26 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();
const d2 = domain.create();

d.on('error', function errorHandler() {
});

d.run(function() {
d2.run(function() {
setTimeout(function() {
throw new Error('boom!');
}, 1);
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
26 changes: 26 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();
const d2 = domain.create();

d.on('error', function errorHandler() {
});

d.run(function() {
d2.run(function() {
setImmediate(function() {
throw new Error('boom!');
});
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
26 changes: 26 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();
const d2 = domain.create();

d.on('error', function errorHandler() {
});

d.run(function() {
d2.run(function() {
process.nextTick(function() {
throw new Error('boom!');
});
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
27 changes: 27 additions & 0 deletions test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

const common = require('../common');
const domain = require('domain');

function test() {
const d = domain.create();
const d2 = domain.create();

d.on('error', function errorHandler() {
});

d.run(function() {
d2.run(function() {
var fs = require('fs');
fs.exists('/non/existing/file', function onExists() {
throw new Error('boom!');
});
});
});
}

if (process.argv[2] === 'child') {
test();
} else {
common.childShouldThrowAndAbort();
}
Loading

0 comments on commit 20443d9

Please sign in to comment.