Skip to content

Commit

Permalink
test: unflake nsolid-env-metrics test
Browse files Browse the repository at this point in the history
PR-URL: #236
Reviewed-By: Juan José Arboleda <[email protected]>
PR-URL: #245
Reviewed-By: Rafael Gonzaga <[email protected]>
  • Loading branch information
santigimeno committed Jan 13, 2025
1 parent 2d7ccc1 commit eb2932c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/addons/nsolid-env-metrics/nsolid-env-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ process.on('beforeExit', mustCall(() => {
assert.strictEqual(binding.getCbCntr(), 11);
}));

const workers = [];
for (let i = 0; i < 10; i++) {
const worker = new Worker(__filename, { argv: [process.pid] });
worker.on('exit', (code) => {
Expand All @@ -33,12 +34,18 @@ for (let i = 0; i < 10; i++) {
worker.on('message', mustCall((msg) => {
assert.strictEqual(msg, 'init');
binding.getMetrics(worker.threadId);
worker.postMessage('exit');
}));
workers.push(worker);
}

// Let then main thread be a bit idle so we can check that loop_utilization is
// correctly calculdate.
setTimeout(() => {
binding.getMetrics();
}, 100);
const interval = setInterval(() => {
if (binding.getCbCntr() === 11) {
clearInterval(interval);
workers.forEach((worker) => worker.postMessage('exit'));
}
}, 50);
}, 300);

0 comments on commit eb2932c

Please sign in to comment.