Skip to content

Commit c13f01c

Browse files
joyeecheungMylesBorins
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 ed76b4a commit c13f01c

12 files changed

+247
-168
lines changed

test/common.js

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

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

206228
exports.ddCommand = function(filename, kilobytes) {
207229
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)