Skip to content

Commit

Permalink
Merge pull request newrelic#148 from jmartin4563/fix-c8-oom
Browse files Browse the repository at this point in the history
Move versioned test sampling config to package.json
  • Loading branch information
bizob2828 committed Apr 26, 2023
2 parents 17440fb + ab770de commit 401e2c1
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 21 deletions.
8 changes: 4 additions & 4 deletions lib/instrumentation/koa/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/instrumentation/koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"unit": "c8 -o ./coverage/unit tap tests/unit/**/*.tap.js --no-coverage --reporter classic",
"versioned": "npm run versioned:npm7",
"versioned:major": "versioned-tests --major --all -i 2 'tests/versioned/*.tap.js'",
"versioned:npm6": "c8 -o ./coverage/versioned versioned-tests --samples 5 --minor -i 2 'tests/versioned/*.tap.js'",
"versioned:npm7": "c8 -o ./coverage/versioned versioned-tests --samples 5 --minor --all -i 2 'tests/versioned/*.tap.js'",
"versioned:npm6": "c8 -o ./coverage/versioned versioned-tests --minor -i 2 'tests/versioned/*.tap.js'",
"versioned:npm7": "c8 -o ./coverage/versioned versioned-tests --minor --all -i 2 'tests/versioned/*.tap.js'",
"lint": "eslint *.js lib tests",
"lint:fix": "eslint --fix *.js lib tests",
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
Expand Down Expand Up @@ -48,7 +48,7 @@
"koa-router": "^7.4.0",
"lint-staged": "^11.1.2",
"lockfile-lint": "^4.9.6",
"newrelic": "^9.14.0",
"newrelic": "^10.0.0",
"prettier": "^2.3.2",
"semver": "^5.7.1",
"sinon": "^15.0.1",
Expand Down
14 changes: 14 additions & 0 deletions lib/instrumentation/koa/tests/unit/getShim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2023 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

'use strict'

// TODO: remove this file once the test-utils repo has been updated and use helper.getShim() instead!
module.exports = function getShim(nodule) {
const [shimSymbol] = Object.getOwnPropertySymbols(nodule).filter(
(key) => key.toString() === 'Symbol(shim)'
)
return nodule[shimSymbol]
}
3 changes: 2 additions & 1 deletion lib/instrumentation/koa/tests/unit/koa.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

const tap = require('tap')
const utils = require('@newrelic/test-utilities')
const getShim = require('./getShim')

utils.tap

Expand All @@ -22,7 +23,7 @@ tap.test('Koa instrumentation', function (t) {
shimName: 'koa'
})
const Koa = require('koa')
const shim = helper.getShim()
const shim = getShim(Koa)

wrapped.forEach(function (method) {
t.ok(shim.isWrapped(Koa.prototype[method]), method + ' is wrapped, as expected')
Expand Down
5 changes: 3 additions & 2 deletions lib/instrumentation/koa/tests/unit/route.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const tap = require('tap')
const utils = require('@newrelic/test-utilities')
const { METHODS } = require('../../lib/http-methods')
const getShim = require('./getShim')

tap.test('koa-route', function (t) {
const helper = utils.TestAgent.makeInstrumented()
Expand All @@ -23,10 +24,10 @@ tap.test('koa-route', function (t) {
shimName: 'koa'
})

const shim = helper.getShim()
const route = require('koa-route')
const shim = getShim(route)

t.test('methods', function (t) {
const route = require('koa-route')
METHODS.forEach(function checkWrapped(method) {
t.ok(shim.isWrapped(route[method]), method + ' should be wrapped')
})
Expand Down
4 changes: 3 additions & 1 deletion lib/instrumentation/koa/tests/unit/router.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const tap = require('tap')
const utils = require('@newrelic/test-utilities')
const instrumentation = require('../../lib/router-instrumentation.js')
const { METHODS } = require('../../lib/http-methods')
const getShim = require('./getShim.js')
const WRAPPED_METHODS = ['param', 'register', 'routes', 'middleware', 'allowedMethods']
const UNWRAPPED_METHODS = METHODS.concat([
'use',
Expand All @@ -29,7 +30,6 @@ koaRouterMods.forEach((koaRouterMod) => {
t.teardown(function () {
helper.unload()
})
const shim = helper.getShim()

helper.registerInstrumentation({
type: 'web-framework',
Expand All @@ -40,6 +40,7 @@ koaRouterMods.forEach((koaRouterMod) => {

t.test('mounting paramware', function (t) {
var Router = require(koaRouterMod)
const shim = getShim(Router)
var router = new Router()
router.param('second', function () {})
t.ok(shim.isWrapped(router.params.second), 'param function should be wrapped')
Expand All @@ -48,6 +49,7 @@ koaRouterMods.forEach((koaRouterMod) => {

t.test('methods', function (t) {
var Router = require(koaRouterMod)
const shim = getShim(Router)
WRAPPED_METHODS.forEach(function checkWrapped(method) {
t.ok(
shim.isWrapped(Router.prototype[method]),
Expand Down
40 changes: 32 additions & 8 deletions lib/instrumentation/koa/tests/versioned/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"node": ">=14"
},
"dependencies": {
"koa": "^1.5.0"
"koa": {
"versions": "^1.5.0",
"samples": 5
}
},
"files": [
"koa-v1.tap.js"
Expand All @@ -24,7 +27,10 @@
"node": ">=14"
},
"dependencies": {
"koa": ">=2.0.0"
"koa": {
"versions": ">=2.0.0",
"samples": 5
}
},
"files": [
"koa.tap.js",
Expand All @@ -36,8 +42,14 @@
"node": ">=14"
},
"dependencies": {
"koa": ">=2.0.0",
"koa-router": ">=7.1.0"
"koa": {
"versions": ">=2.0.0",
"samples": 5
},
"koa-router": {
"versions": ">=7.1.0",
"samples": 5
}
},
"files": [
"koa-router.tap.js",
Expand All @@ -49,8 +61,14 @@
"node": ">=14"
},
"dependencies": {
"koa": ">=2.0.0",
"@koa/router": ">=8.0.0"
"koa": {
"versions": ">=2.0.0",
"samples": 5
},
"@koa/router": {
"versions": ">=8.0.0",
"samples": 5
}
},
"files": [
"scoped-koa-router.tap.js",
Expand All @@ -62,8 +80,14 @@
"node": ">=14"
},
"dependencies": {
"koa": ">=2.0.0",
"koa-route": ">=3.0.0"
"koa": {
"versions": ">=2.0.0",
"samples": 5
},
"koa-route": {
"versions": ">=3.0.0",
"samples": 5
}
},
"files": [
"koa-route.tap.js"
Expand Down
4 changes: 2 additions & 2 deletions lib/instrumentation/koa/third_party_manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lastUpdated": "Mon Apr 24 2023 09:59:57 GMT-0400 (Eastern Daylight Time)",
"lastUpdated": "Tue Apr 25 2023 18:18:18 GMT-0400 (Eastern Daylight Time)",
"projectName": "New Relic Koa Instrumentation",
"projectUrl": "https://github.com/newrelic/node-newrelic-koa",
"includeOptDeps": false,
Expand Down Expand Up @@ -209,7 +209,7 @@
"newrelic@10.0.0": {
"name": "newrelic",
"version": "10.0.0",
"range": "^9.14.0",
"range": "^10.0.0",
"licenses": "Apache-2.0",
"repoUrl": "https://github.com/newrelic/node-newrelic",
"versionedRepoUrl": "https://github.com/newrelic/node-newrelic/tree/v10.0.0",
Expand Down

0 comments on commit 401e2c1

Please sign in to comment.