FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: fix flaky test-worker-prof by Trott · Pull Request #37372 · nodejs/node · GitHub

/ node Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) .status  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 0 additions & 4 deletions test/sequential/sequential.status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ prefix sequential
test-cpu-prof-dir-worker: PASS, FLAKY

[$system==win32]
# https://github.com/nodejs/node/issues/26401
test-worker-prof: PASS, FLAKY

[$system==linux]

Expand All @@ -31,5 +29,3 @@ test-buffer-creation-regression: SKIP
test-perf-hooks: SKIP

[$arch==arm]
# https://github.com/nodejs/node/issues/26401#issuecomment-613095719
test-worker-prof: PASS, FLAKY
15 changes: 8 additions & 7 deletions test/sequential/test-worker-prof.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ if (process.argv[2] === 'child') {
const fs = require('fs');
const { Worker, parentPort } = require('worker_threads');
parentPort.on('message', (m) => {
if (counter++ === 10)
if (counter++ === 1024)
process.exit(0);
parentPort.postMessage(
fs.readFileSync(m.toString()).slice(0, 1024 * 1024));
parentPort.postMessage(
fs.readFileSync(m.toString()).slice(0, 1024 * 1024));
});
`;

const { Worker } = require('worker_threads');
const w = new Worker(pingpong, { eval: true });
w.on('message', (m) => {
w.postMessage(process.execPath);
w.postMessage(__filename);
});

w.on('exit', common.mustCall(() => {
Expand All @@ -46,12 +46,13 @@ if (process.argv[2] === 'child') {
}
process.exit(0);
}));
w.postMessage(process.execPath);
w.postMessage(__filename);
} else {
tmpdir.refresh();
const timeout = common.platformTimeout(30_000);
const spawnResult = spawnSync(
process.execPath, ['--prof', __filename, 'child'],
{ cwd: tmpdir.path, encoding: 'utf8', timeout: 30_000 });
{ cwd: tmpdir.path, encoding: 'utf8', timeout });
assert.strictEqual(spawnResult.stderr.toString(), '',
`child exited with an error: \
${util.inspect(spawnResult)}`);
Expand All @@ -72,7 +73,7 @@ if (process.argv[2] === 'child') {
// Test that at least 15 ticks have been recorded for both parent and child
// threads. When not tracking Worker threads, only 1 or 2 ticks would
// have been recorded.
// When running locally on x64 Linux, this number is usually at least 200
// When running locally, this number is usually around 200
// for both threads, so 15 seems like a very safe threshold.
assert(ticks >= 15, `${ticks} >= 15`);
}
Expand Down

Back | FazBrowse Home | New Git URL