Skip to content

Commit 4a54d45

Browse files
trentmAlan Storm
authored andcommitted
tests: fix test failure due to os.freemem() behaviour change in node v17.4.0 (#2540)
The update to libuv 1.43.0 changed the behaviour of os.freemem() on Linux to report "MemAvailable" from /proc/meminfo rather than "MemFree". Refs: #2530
1 parent 363aa6f commit 4a54d45

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/metrics/index.test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ test('reports expected metrics', function (t) {
7474
},
7575
'system.memory.actual.free': (value) => {
7676
const free = os.freemem()
77-
if (os.type() === 'Linux' && semver.lt(process.version, '18.0.0-nightly20220107')) {
77+
if (os.type() === 'Linux' &&
78+
semver.lt(process.version, '18.0.0-nightly20220107') &&
79+
semver.lt(process.version, '17.4.0')) {
7880
// On Linux we use "MemAvailable" from /proc/meminfo as the value for
79-
// this metric. In versions of Node.js before v18.0.0, `os.freemem()`
80-
// reports "MemFree" from /proc/meminfo. (This changed in
81-
// v18.0.0-nightly20220107b6b6510187 when node upgraded to libuv
82-
// 1.43.0 to include https://github.com/libuv/libuv/pull/3351.)
81+
// this metric. In versions of Node.js before v17.4.0 and v18.0.0,
82+
// `os.freemem()` reports "MemFree" from /proc/meminfo. (This changed
83+
// in v17.4.0 and v18.0.0-nightly20220107b6b6510187 when node upgraded
84+
// to libuv 1.43.0 to include https://github.com/libuv/libuv/pull/3351.)
8385
t.ok(value > free, `is larger than os.freemem() (value: ${value},
8486
free: ${free})`)
8587
} else {

0 commit comments

Comments
 (0)