From 971d5be57c6b230af936b8236fbdf65e916490e3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 2 Feb 2021 06:41:50 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/36961 PR-URL: https://github.com/nodejs/node/pull/37189 Reviewed-By: Ash Cripps Reviewed-By: Antoine du Hamel Reviewed-By: Filip Skokan Reviewed-By: James M Snell Reviewed-By: Richard Lau --- ...est-heapsnapshot-near-heap-limit-worker.js | 36 +++++++++++++++++++ .../test-heapsnapshot-near-heap-limit.js | 26 -------------- 2 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 test/parallel/test-heapsnapshot-near-heap-limit-worker.js diff --git a/test/parallel/test-heapsnapshot-near-heap-limit-worker.js b/test/parallel/test-heapsnapshot-near-heap-limit-worker.js new file mode 100644 index 00000000000000..edbe2f6c617505 --- /dev/null +++ b/test/parallel/test-heapsnapshot-near-heap-limit-worker.js @@ -0,0 +1,36 @@ +'use strict'; + +require('../common'); +const tmpdir = require('../common/tmpdir'); +const assert = require('assert'); +const { spawnSync } = require('child_process'); +const fixtures = require('../common/fixtures'); +const fs = require('fs'); +const env = { + ...process.env, + NODE_DEBUG_NATIVE: 'diagnostics' +}; + +{ + tmpdir.refresh(); + const child = spawnSync(process.execPath, [ + fixtures.path('workload', 'grow-worker.js') + ], { + cwd: tmpdir.path, + env: { + TEST_SNAPSHOTS: 1, + TEST_OLD_SPACE_SIZE: 50, + ...env + } + }); + console.log(child.stdout.toString()); + const stderr = child.stderr.toString(); + console.log(stderr); + // There should be one snapshot taken and then after the + // snapshot heap limit callback is popped, the OOM callback + // becomes effective. + assert(stderr.includes('ERR_WORKER_OUT_OF_MEMORY')); + const list = fs.readdirSync(tmpdir.path) + .filter((file) => file.endsWith('.heapsnapshot')); + assert.strictEqual(list.length, 1); +} diff --git a/test/parallel/test-heapsnapshot-near-heap-limit.js b/test/parallel/test-heapsnapshot-near-heap-limit.js index db75da221ab017..42b66871d429c2 100644 --- a/test/parallel/test-heapsnapshot-near-heap-limit.js +++ b/test/parallel/test-heapsnapshot-near-heap-limit.js @@ -86,29 +86,3 @@ const env = { .filter((file) => file.endsWith('.heapsnapshot')); assert(list.length > 0 && list.length <= 3); } - - -{ - console.log('\nTesting worker'); - tmpdir.refresh(); - const child = spawnSync(process.execPath, [ - fixtures.path('workload', 'grow-worker.js') - ], { - cwd: tmpdir.path, - env: { - TEST_SNAPSHOTS: 1, - TEST_OLD_SPACE_SIZE: 50, - ...env - } - }); - console.log(child.stdout.toString()); - const stderr = child.stderr.toString(); - console.log(stderr); - // There should be one snapshot taken and then after the - // snapshot heap limit callback is popped, the OOM callback - // becomes effective. - assert(stderr.includes('ERR_WORKER_OUT_OF_MEMORY')); - const list = fs.readdirSync(tmpdir.path) - .filter((file) => file.endsWith('.heapsnapshot')); - assert.strictEqual(list.length, 1); -}