Skip to content

Commit

Permalink
chore: Updated integration tests to node:test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Dec 11, 2024
1 parent 7a53a19 commit 2c32e60
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ module.exports = {
'consistent-return': 'off'
},
parserOptions: {
ecmaVersion: '2020'
ecmaVersion: '2021'
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint:fix": "eslint . --fix",
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
"unit": "c8 -o ./coverage/unit borp --expose-gc --timeout 180000 'tests/unit/*.test.js'",
"integration": "c8 -o ./coverage/integration tap --timeout 360000 --jobs=1 --no-coverage tests/integration/*.tap.js",
"integration": "c8 -o ./coverage/integration borp --timeout 360000 'tests/integration/*.test.js'",
"native": "node tests/native/*.js",
"test": "npm run unit && npm run integration",
"install": "node-gyp-build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* Copyright 2024 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

'use strict'

const tap = require('tap')
const test = require('node:test')
const assert = require('node:assert')

const TEST_DURATION = 30 * 1000
const TEST_DURATION = 30 * 1_000
let performanceThreshold = 0.98
if (process.platform === 'darwin') {
// The GitHub macOS runners are slow and vary widely in their slowness
Expand All @@ -17,7 +18,7 @@ if (process.platform === 'darwin') {
performanceThreshold = 0.97
}

tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, function (t) {
test('loop performance test', { timeout: 2 * TEST_DURATION + 1_000 }, (t, end) => {
// The purpose of this test is to measure how much tracking metrics
// impacts the processing overhead of the application loop. To do so, we:
//
Expand All @@ -32,13 +33,13 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio
let callCount = 0
let natives = null

t.teardown(function () {
t.after(function () {
if (natives) {
natives.unbind()
}
})

t.comment('measuring without loop counter')
// measuring without loop counter
setTimeoutCount()
setTimeout(function () {
const noMetricsCount = callCount
Expand All @@ -48,22 +49,22 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio
natives = require('../../')()
const readInterval = setInterval(function () {
natives.getLoopMetrics() // To reset the metrics
}, 1000)
}, 1_000)

t.comment('measuring with loop counter')
// measuring with loop counter
setTimeoutCount()
setTimeout(function () {
const withMetricsCount = callCount
callCount = 0
clearTimeout(timeout)
clearInterval(readInterval)

t.comment(noMetricsCount + ' vs ' + withMetricsCount)
t.ok(
// console.log(noMetricsCount + ' vs ' + withMetricsCount)
assert.ok(
noMetricsCount * performanceThreshold < withMetricsCount,
`should not impact performance by more than ${1 - performanceThreshold}%`
)
t.end()
end()
}, TEST_DURATION)
}, TEST_DURATION)

Expand Down

0 comments on commit 2c32e60

Please sign in to comment.