Skip to content

Commit

Permalink
test: fix tests to work with restify@9 (#3031)
Browse files Browse the repository at this point in the history
restify@9 was recently released. It only works with node >=v14.18.0
because it added use of https://nodejs.org/api/modules.html#core-modules
This updates restify testing to skip out when there is an incompat
(restify, node) version pair.

Also an unrelated change in "http-run-context.test.js" to get better
debug output if a spurious error is hit in it again.
  • Loading branch information
trentm authored Nov 17, 2022
1 parent 13d3095 commit 4d52d72
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 364 deletions.
20 changes: 16 additions & 4 deletions .tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,28 @@ cassandra-driver:
versions: '>=3 <3.1.0 || >3.1.0 <5'
commands: node test/instrumentation/modules/cassandra-driver/index.test.js

restify-old:
# Restify
# - restify <v10 doesn't work with node v18+ (https://github.com/restify/node-restify/issues/1888)
# - restify v9 used `require('node:...')` that requires node >v14.18.0
# (https://nodejs.org/api/modules.html#core-modules)
restify-v5-v8:
name: restify
versions: '>=5.2.0 <8.0.0'
node: '<18.0.0'
commands:
- node test/instrumentation/modules/restify/basic.test.js
- node test/instrumentation/modules/restify/set-framework.test.js
restify-new:
restify-v8-v9:
name: restify
node: '>=8.6.0'
versions: '>=8.0.0'
versions: '>=8.0.0 <9.0.0'
node: '>=8.6.0 <18.0.0'
commands:
- node test/instrumentation/modules/restify/basic.test.js
- node test/instrumentation/modules/restify/set-framework.test.js
restify:
name: restify
versions: '>=9.0.0'
node: '>=14.18.0 <18.0.0'
commands:
- node test/instrumentation/modules/restify/basic.test.js
- node test/instrumentation/modules/restify/set-framework.test.js
Expand Down
8 changes: 7 additions & 1 deletion lib/instrumentation/modules/restify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ const semver = require('semver')
const shimmer = require('../shimmer')

module.exports = function (restify, agent, { version, enabled }) {
if (!enabled) return restify
if (!enabled) {
return restify
}
if (!semver.satisfies(version, '>=5.2.0 <10.0.0')) {
agent.logger.debug('restify version %s not supported, skipping', version)
return restify
}

agent.setFramework({ name: 'restify', version, overwrite: false })

Expand Down
Loading

0 comments on commit 4d52d72

Please sign in to comment.