Skip to content

Commit 3575f51

Browse files
joyeecheungitaloacasas
authored andcommitted
test: reduce unmanaged parallelism in domain test
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 #9979 (not a real fix). PR-URL: #10329 Reviewed-By: Anna Henningsen <[email protected]>
1 parent 7822d86 commit 3575f51

12 files changed

+247
-168
lines changed

test/common.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,28 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
203203
});
204204
});
205205

206+
/*
207+
* Check that when running a test with
208+
* `$node --abort-on-uncaught-exception $file child`
209+
* the process aborts.
210+
*/
211+
exports.childShouldThrowAndAbort = function() {
212+
var testCmd = '';
213+
if (!exports.isWindows) {
214+
// Do not create core files, as it can take a lot of disk space on
215+
// continuous testing and developers' machines
216+
testCmd += 'ulimit -c 0 && ';
217+
}
218+
testCmd += `${process.argv[0]} --abort-on-uncaught-exception `;
219+
testCmd += `${process.argv[1]} child`;
220+
const child = child_process.exec(testCmd);
221+
child.on('exit', function onExit(exitCode, signal) {
222+
const errMsg = 'Test should have aborted ' +
223+
`but instead exited with exit code ${exitCode}` +
224+
` and signal ${signal}`;
225+
assert(exports.nodeProcessAborted(exitCode, signal), errMsg);
226+
});
227+
};
206228

207229
exports.ddCommand = function(filename, kilobytes) {
208230
if (exports.isWindows) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
9+
d.run(function() {
10+
throw new Error('boom!');
11+
});
12+
}
13+
14+
if (process.argv[2] === 'child') {
15+
test();
16+
} else {
17+
common.childShouldThrowAndAbort();
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
const d2 = domain.create();
9+
10+
d.run(function() {
11+
d2.run(function() {
12+
throw new Error('boom!');
13+
});
14+
});
15+
}
16+
17+
if (process.argv[2] === 'child') {
18+
test();
19+
} else {
20+
common.childShouldThrowAndAbort();
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
9+
d.run(function() {
10+
setTimeout(function() {
11+
throw new Error('boom!');
12+
}, 1);
13+
});
14+
}
15+
16+
if (process.argv[2] === 'child') {
17+
test();
18+
} else {
19+
common.childShouldThrowAndAbort();
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
9+
d.run(function() {
10+
setImmediate(function() {
11+
throw new Error('boom!');
12+
});
13+
});
14+
}
15+
16+
if (process.argv[2] === 'child') {
17+
test();
18+
} else {
19+
common.childShouldThrowAndAbort();
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
9+
d.run(function() {
10+
process.nextTick(function() {
11+
throw new Error('boom!');
12+
});
13+
});
14+
}
15+
16+
if (process.argv[2] === 'child') {
17+
test();
18+
} else {
19+
common.childShouldThrowAndAbort();
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
9+
d.run(function() {
10+
var fs = require('fs');
11+
fs.exists('/non/existing/file', function onExists() {
12+
throw new Error('boom!');
13+
});
14+
});
15+
}
16+
17+
if (process.argv[2] === 'child') {
18+
test();
19+
} else {
20+
common.childShouldThrowAndAbort();
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
const d2 = domain.create();
9+
10+
d.on('error', function errorHandler() {
11+
});
12+
13+
d.run(function() {
14+
d2.run(function() {
15+
setTimeout(function() {
16+
throw new Error('boom!');
17+
}, 1);
18+
});
19+
});
20+
}
21+
22+
if (process.argv[2] === 'child') {
23+
test();
24+
} else {
25+
common.childShouldThrowAndAbort();
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
const d2 = domain.create();
9+
10+
d.on('error', function errorHandler() {
11+
});
12+
13+
d.run(function() {
14+
d2.run(function() {
15+
setImmediate(function() {
16+
throw new Error('boom!');
17+
});
18+
});
19+
});
20+
}
21+
22+
if (process.argv[2] === 'child') {
23+
test();
24+
} else {
25+
common.childShouldThrowAndAbort();
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
const d2 = domain.create();
9+
10+
d.on('error', function errorHandler() {
11+
});
12+
13+
d.run(function() {
14+
d2.run(function() {
15+
process.nextTick(function() {
16+
throw new Error('boom!');
17+
});
18+
});
19+
});
20+
}
21+
22+
if (process.argv[2] === 'child') {
23+
test();
24+
} else {
25+
common.childShouldThrowAndAbort();
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const domain = require('domain');
5+
6+
function test() {
7+
const d = domain.create();
8+
const d2 = domain.create();
9+
10+
d.on('error', function errorHandler() {
11+
});
12+
13+
d.run(function() {
14+
d2.run(function() {
15+
var fs = require('fs');
16+
fs.exists('/non/existing/file', function onExists() {
17+
throw new Error('boom!');
18+
});
19+
});
20+
});
21+
}
22+
23+
if (process.argv[2] === 'child') {
24+
test();
25+
} else {
26+
common.childShouldThrowAndAbort();
27+
}

0 commit comments

Comments
 (0)