Skip to content

Commit 82b7894

Browse files
indutnyFishrock123
authored andcommitted
test: make test-tick-processor.js non-flaky
Wait for a sought-for symbol to appear instead of just hard-killing subprocesses at 2s timeout. Fix: #4427 PR-URL: #8542 Reviewed-By: Rich Trott <[email protected]>
1 parent eebecef commit 82b7894

6 files changed

+155
-67
lines changed

test/fixtures/tick-processor-base.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
const common = require('../common');
3+
const fs = require('fs');
4+
const cp = require('child_process');
5+
const path = require('path');
6+
7+
common.refreshTmpDir();
8+
9+
const LOG_FILE = path.join(common.tmpDir, 'tick-processor.log');
10+
const RETRY_TIMEOUT = 750;
11+
12+
function runTest(test) {
13+
const proc = cp.spawn(process.execPath, [
14+
'--no_logfile_per_isolate',
15+
'--logfile=-',
16+
'--prof',
17+
'-pe', test.code
18+
], {
19+
stdio: [ null, 'pipe', 'inherit' ]
20+
});
21+
22+
let ticks = '';
23+
proc.stdout.on('data', chunk => ticks += chunk);
24+
25+
// Try to match after timeout
26+
setTimeout(() => {
27+
match(test.pattern, proc, () => ticks);
28+
}, RETRY_TIMEOUT);
29+
}
30+
31+
function match(pattern, parent, ticks) {
32+
// Store current ticks log
33+
fs.writeFileSync(LOG_FILE, ticks());
34+
35+
const proc = cp.spawn(process.execPath, [
36+
'--prof-process',
37+
'--call-graph-size=10',
38+
LOG_FILE
39+
], {
40+
stdio: [ null, 'pipe', 'inherit' ]
41+
});
42+
43+
let out = '';
44+
proc.stdout.on('data', chunk => out += chunk);
45+
proc.stdout.on('end', () => {
46+
// Retry after timeout
47+
if (!pattern.test(out))
48+
return setTimeout(() => match(pattern, parent, ticks), RETRY_TIMEOUT);
49+
50+
parent.kill('SIGTERM');
51+
52+
fs.unlinkSync(LOG_FILE);
53+
});
54+
}
55+
56+
exports.runTest = runTest;

test/parallel/parallel.status

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ prefix parallel
77
[true] # This section applies to all platforms
88

99
[$system==win32]
10-
test-tick-processor : PASS,FLAKY
1110

1211
[$system==linux]
1312
test-tick-processor : PASS,FLAKY
1413

1514
[$system==macos]
1615

16+
[$arch==arm || $arch==arm64]
17+
test-tick-processor-builtin : PASS,FLAKY
18+
test-tick-processor-cpp-core : PASS,FLAKY
19+
test-tick-processor-unknown : PASS,FLAKY
20+
1721
[$system==solaris] # Also applies to SmartOS
1822
test-debug-signal-cluster : PASS,FLAKY
1923

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
const common = require('../common');
3+
const path = require('path');
4+
5+
// TODO(mhdawson) Currently the test-tick-processor functionality in V8
6+
// depends on addresses being smaller than a full 64 bits. Aix supports
7+
// the full 64 bits and the result is that it does not process the
8+
// addresses correctly and runs out of memory
9+
// Disabling until we get a fix upstreamed into V8
10+
if (common.isAix) {
11+
common.skip('Aix address range too big for scripts.');
12+
return;
13+
}
14+
15+
const base = require(path.join(common.fixturesDir, 'tick-processor-base.js'));
16+
17+
if (common.isWindows ||
18+
common.isSunOS ||
19+
common.isAix ||
20+
common.isLinuxPPCBE ||
21+
common.isFreeBSD) {
22+
common.skip('C++ symbols are not mapped for this os.');
23+
return;
24+
}
25+
26+
base.runTest({
27+
pattern: /Builtin_DateNow/,
28+
code: `function f() {
29+
this.ts = Date.now();
30+
setImmediate(function() { new f(); });
31+
};
32+
f();`
33+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
const common = require('../common');
3+
const path = require('path');
4+
5+
// TODO(mhdawson) Currently the test-tick-processor functionality in V8
6+
// depends on addresses being smaller than a full 64 bits. Aix supports
7+
// the full 64 bits and the result is that it does not process the
8+
// addresses correctly and runs out of memory
9+
// Disabling until we get a fix upstreamed into V8
10+
if (common.isAix) {
11+
common.skip('Aix address range too big for scripts.');
12+
return;
13+
}
14+
15+
const base = require(path.join(common.fixturesDir, 'tick-processor-base.js'));
16+
17+
if (common.isWindows ||
18+
common.isSunOS ||
19+
common.isAix ||
20+
common.isLinuxPPCBE ||
21+
common.isFreeBSD) {
22+
common.skip('C++ symbols are not mapped for this os.');
23+
return;
24+
}
25+
26+
base.runTest({
27+
pattern: /RunInDebugContext/,
28+
code: `function f() {
29+
require(\'vm\').runInDebugContext(\'Debug\');
30+
setImmediate(function() { f(); });
31+
};
32+
f();`
33+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
const path = require('path');
4+
5+
// TODO(mhdawson) Currently the test-tick-processor functionality in V8
6+
// depends on addresses being smaller than a full 64 bits. Aix supports
7+
// the full 64 bits and the result is that it does not process the
8+
// addresses correctly and runs out of memory
9+
// Disabling until we get a fix upstreamed into V8
10+
if (common.isAix) {
11+
common.skip('Aix address range too big for scripts.');
12+
return;
13+
}
14+
15+
const base = require(path.join(common.fixturesDir, 'tick-processor-base.js'));
16+
17+
// Unknown checked for to prevent flakiness, if pattern is not found,
18+
// then a large number of unknown ticks should be present
19+
base.runTest({
20+
pattern: /LazyCompile.*\[eval\]:1|.*% UNKNOWN/,
21+
code: `function f() {
22+
for (var i = 0; i < 1000000; i++) {
23+
i++;
24+
}
25+
setImmediate(function() { f(); });
26+
};
27+
f();`
28+
});

test/parallel/test-tick-processor.js

-66
This file was deleted.

0 commit comments

Comments
 (0)