-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On some machines the report OOM tests can take too long to complete, resulting in a timeout. This splits the test into several different smaller tests to reduce the flakiness of it. PR-URL: #44389 Refs: nodejs/reliability#356 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
1 parent
8452964
commit a7ca62b
Showing
7 changed files
with
187 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const list = []; | ||
while (true) { | ||
const record = new MyRecord(); | ||
list.push(record); | ||
} | ||
|
||
function MyRecord() { | ||
this.name = 'foo'; | ||
this.id = 128; | ||
this.account = 98454324; | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
// Testcases for situations involving fatal errors, like Javascript heap OOM | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const helper = require('../common/report.js'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const tmpdir = require('../common/tmpdir'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// Common args that will cause an out-of-memory error for child process. | ||
const ARGS = [ | ||
'--max-old-space-size=20', | ||
fixtures.path('report-oom'), | ||
]; | ||
|
||
{ | ||
// Verify that --report-compact is respected when set. | ||
tmpdir.refresh(); | ||
const args = ['--report-on-fatalerror', '--report-compact', ...ARGS]; | ||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
|
||
const reports = helper.findReports(child.pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 1); | ||
|
||
const report = reports[0]; | ||
helper.validate(report); | ||
assert.strictEqual(require(report).header.threadId, null); | ||
// Subtract 1 because "xx\n".split("\n") => [ 'xx', '' ]. | ||
const lines = fs.readFileSync(report, 'utf8').split('\n').length - 1; | ||
assert.strictEqual(lines, 1); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
// Testcases for situations involving fatal errors, like Javascript heap OOM | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const helper = require('../common/report.js'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const tmpdir = require('../common/tmpdir'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// Common args that will cause an out-of-memory error for child process. | ||
const ARGS = [ | ||
'--max-old-space-size=20', | ||
fixtures.path('report-oom'), | ||
]; | ||
|
||
{ | ||
// Verify that --report-directory is respected when set. | ||
// Verify that --report-compact is respected when not set. | ||
tmpdir.refresh(); | ||
const dir = '--report-directory=' + tmpdir.path; | ||
const args = ['--report-on-fatalerror', dir, ...ARGS]; | ||
const child = spawnSync(process.execPath, args, { }); | ||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
|
||
const reports = helper.findReports(child.pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 1); | ||
|
||
const report = reports[0]; | ||
helper.validate(report); | ||
assert.strictEqual(require(report).header.threadId, null); | ||
const lines = fs.readFileSync(report, 'utf8').split('\n').length - 1; | ||
assert(lines > 10); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
// Testcases for situations involving fatal errors, like Javascript heap OOM | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const helper = require('../common/report.js'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const tmpdir = require('../common/tmpdir'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// Common args that will cause an out-of-memory error for child process. | ||
const ARGS = [ | ||
'--max-old-space-size=20', | ||
fixtures.path('report-oom'), | ||
]; | ||
|
||
{ | ||
// Verify that --report-compact is respected when set. | ||
// Verify that --report-filename is respected when set. | ||
tmpdir.refresh(); | ||
const args = [ | ||
'--report-on-fatalerror', | ||
'--report-compact', | ||
'--report-filename=stderr', | ||
...ARGS, | ||
]; | ||
const child = spawnSync(process.execPath, args, { encoding: 'utf8' }); | ||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
|
||
const reports = helper.findReports(child.pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 0); | ||
|
||
const lines = child.stderr.split('\n'); | ||
// Skip over unavoidable free-form output and gc log from V8. | ||
const report = lines.find((i) => i.startsWith('{')); | ||
const json = JSON.parse(report); | ||
|
||
assert.strictEqual(json.header.threadId, null); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
// Testcases for situations involving fatal errors, like Javascript heap OOM | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const helper = require('../common/report.js'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const tmpdir = require('../common/tmpdir'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// Common args that will cause an out-of-memory error for child process. | ||
const ARGS = [ | ||
'--max-old-space-size=20', | ||
fixtures.path('report-oom'), | ||
]; | ||
|
||
{ | ||
tmpdir.refresh(); | ||
// Verify that --report-on-fatalerror is respected when not set. | ||
const args = ARGS; | ||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
const reports = helper.findReports(child.pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 0); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
// Testcases for situations involving fatal errors, like Javascript heap OOM | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const helper = require('../common/report.js'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const tmpdir = require('../common/tmpdir'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// Common args that will cause an out-of-memory error for child process. | ||
const ARGS = [ | ||
'--max-old-space-size=20', | ||
fixtures.path('report-oom'), | ||
]; | ||
|
||
{ | ||
// Verify that --report-on-fatalerror is respected when set. | ||
tmpdir.refresh(); | ||
const args = ['--report-on-fatalerror', ...ARGS]; | ||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); | ||
assert.notStrictEqual(child.status, 0, 'Process exited unexpectedly'); | ||
|
||
const reports = helper.findReports(child.pid, tmpdir.path); | ||
assert.strictEqual(reports.length, 1); | ||
|
||
const report = reports[0]; | ||
helper.validate(report); | ||
|
||
const content = require(report); | ||
// Errors occur in a context where env is not available, so thread ID is | ||
// unknown. Assert this, to verify that the underlying env-less situation is | ||
// actually reached. | ||
assert.strictEqual(content.header.threadId, null); | ||
assert.strictEqual(content.header.trigger, 'OOMError'); | ||
} |
This file was deleted.
Oops, something went wrong.