Skip to content

Commit

Permalink
tests: fix TAV test breakage with node 17 (hapi <=16, fastify <0.36.0) (
Browse files Browse the repository at this point in the history
#2387)

This was broken in #2380. Versions of hapi <=16 did not support the
'host' option to `new Server`, but instead to `server.connection`.
Also really old versions of fastify (v0.35.7) cannot even be npm installed
with the npm included in node v17. This drops support for fastify <1.0.0
and updates the TAV test matrix to only test a given fastify version
with its supported versions of node per https://www.fastify.io/docs/latest/LTS/
  • Loading branch information
trentm authored Oct 25, 2021
1 parent d23e9e2 commit 1693568
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
22 changes: 21 additions & 1 deletion .tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,28 @@ restify-new:
- node test/instrumentation/modules/restify/basic.test.js
- node test/instrumentation/modules/restify/set-framework.test.js

# https://www.fastify.io/docs/latest/LTS/
# - #1086 suggests [email protected] was a broken release, skip it.
fastify-v1:
name: fastify
versions: '1.x'
node: '>=6 <12'
commands:
- node test/instrumentation/modules/fastify/fastify.test.js
- node test/instrumentation/modules/fastify/async-await.test.js
- node test/instrumentation/modules/fastify/set-framework.test.js
fastify-v2:
name: fastify
versions: '>=2.0.0 <2.4.0 || >2.4.0 <3'
node: '>=6 <15'
commands:
- node test/instrumentation/modules/fastify/fastify.test.js
- node test/instrumentation/modules/fastify/async-await.test.js
- node test/instrumentation/modules/fastify/set-framework.test.js
fastify:
versions: '>=0.27.0 <0.29.0 || >0.29.0 <2.4.0 || >2.4.0'
name: fastify
versions: '>=3.0.0'
node: '>=10'
commands:
- node test/instrumentation/modules/fastify/fastify.test.js
- node test/instrumentation/modules/fastify/async-await.test.js
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ Notes:
[float]
===== Breaking changes
* Remove support for instrumenting versions of fastify earlier than 1.0.0.
This instrumentation might still work, but is no longer supported.
Fastify v1.0.0 was released in 2018. All current users should be using
fastify v2 or v3 at least. See https://www.fastify.io/docs/latest/LTS/
({pull}2387[#2387])
[float]
===== Features
* Add initial support for version 8 of `@elastic/elasticsearch` (which is
still in pre-release).
* Add initial support for version 8 of `@elastic/elasticsearch`, which is
still in pre-release. ({pull}2385[#2385])
[float]
===== Bug fixes
Expand Down
1 change: 1 addition & 0 deletions docs/fastify.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ include::./shared-set-up.asciidoc[tag=add-your-own-data]
==== Compatibility

include::./shared-set-up.asciidoc[tag=compatibility-link]
See also: https://www.fastify.io/docs/latest/LTS/[Fastify's own LTS documentation.]

[float]
[[fastify-troubleshooting]]
Expand Down
2 changes: 1 addition & 1 deletion docs/supported-technologies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ These are the frameworks that we officially support:
router information for full support. We currently support the most popular Koa router called
https://github.com/alexmingoia/koa-router[koa-router].
|<<restify,Restify>> |>=5.2.0
|<<fastify,Fastify>> |>=0.27.0
|<<fastify,Fastify>> |>=1.0.0; see also https://www.fastify.io/docs/latest/LTS/[Fastify's own LTS documentation]
|=======================================================================

[float]
Expand Down
3 changes: 3 additions & 0 deletions lib/instrumentation/modules/fastify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict'

// Instrumentation of fastify.
// https://www.fastify.io/docs/latest/LTS/

const semver = require('semver')

module.exports = function (fastify, agent, { version, enabled }) {
Expand Down
9 changes: 8 additions & 1 deletion test/instrumentation/modules/hapi/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,16 @@ module.exports = (moduleName) => {
})

function makeServer (opts) {
var server = new Hapi.Server({ host: 'localhost' })
// Specify 'localhost' to avoid Hapi default of '0.0.0.0' which ties to
// IPv4. We want a later HTTP client request using 'localhost' to work.
var server
if (semver.satisfies(pkg.version, '<17')) {
server = new Hapi.Server()
opts = opts || {}
opts.host = opts.host || 'localhost'
server.connection(opts)
} else {
server = new Hapi.Server({ host: 'localhost' })
}
return server
}
Expand Down

0 comments on commit 1693568

Please sign in to comment.