Skip to content

Commit 13fe17c

Browse files
Trottdanielleadams
authored andcommitted
test: split heap snapshot limit tests
test/parallel/test-heapsnapshot-near-heap-limit.js is timing out in CI on low-memory and slow-CPU devices. Split off the worker test to its own test file to allow the test to finish in time. Refs: #36961 PR-URL: #37189 Reviewed-By: Ash Cripps <acripps@redhat.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 9946c11 commit 13fe17c

File tree

2 files changed

+36
-26
lines changed

2 files changed

+36
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
require('../common');
4+
const tmpdir = require('../common/tmpdir');
5+
const assert = require('assert');
6+
const { spawnSync } = require('child_process');
7+
const fixtures = require('../common/fixtures');
8+
const fs = require('fs');
9+
const env = {
10+
...process.env,
11+
NODE_DEBUG_NATIVE: 'diagnostics'
12+
};
13+
14+
{
15+
tmpdir.refresh();
16+
const child = spawnSync(process.execPath, [
17+
fixtures.path('workload', 'grow-worker.js')
18+
], {
19+
cwd: tmpdir.path,
20+
env: {
21+
TEST_SNAPSHOTS: 1,
22+
TEST_OLD_SPACE_SIZE: 50,
23+
...env
24+
}
25+
});
26+
console.log(child.stdout.toString());
27+
const stderr = child.stderr.toString();
28+
console.log(stderr);
29+
// There should be one snapshot taken and then after the
30+
// snapshot heap limit callback is popped, the OOM callback
31+
// becomes effective.
32+
assert(stderr.includes('ERR_WORKER_OUT_OF_MEMORY'));
33+
const list = fs.readdirSync(tmpdir.path)
34+
.filter((file) => file.endsWith('.heapsnapshot'));
35+
assert.strictEqual(list.length, 1);
36+
}

test/parallel/test-heapsnapshot-near-heap-limit.js

-26
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,3 @@ const env = {
8686
.filter((file) => file.endsWith('.heapsnapshot'));
8787
assert(list.length > 0 && list.length <= 3);
8888
}
89-
90-
91-
{
92-
console.log('\nTesting worker');
93-
tmpdir.refresh();
94-
const child = spawnSync(process.execPath, [
95-
fixtures.path('workload', 'grow-worker.js')
96-
], {
97-
cwd: tmpdir.path,
98-
env: {
99-
TEST_SNAPSHOTS: 1,
100-
TEST_OLD_SPACE_SIZE: 50,
101-
...env
102-
}
103-
});
104-
console.log(child.stdout.toString());
105-
const stderr = child.stderr.toString();
106-
console.log(stderr);
107-
// There should be one snapshot taken and then after the
108-
// snapshot heap limit callback is popped, the OOM callback
109-
// becomes effective.
110-
assert(stderr.includes('ERR_WORKER_OUT_OF_MEMORY'));
111-
const list = fs.readdirSync(tmpdir.path)
112-
.filter((file) => file.endsWith('.heapsnapshot'));
113-
assert.strictEqual(list.length, 1);
114-
}

0 commit comments

Comments
 (0)