Skip to content

Commit 1693568

Browse files
authored
tests: fix TAV test breakage with node 17 (hapi <=16, fastify <0.36.0) (#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/
1 parent d23e9e2 commit 1693568

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

.tav.yml

+21-1
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,28 @@ restify-new:
407407
- node test/instrumentation/modules/restify/basic.test.js
408408
- node test/instrumentation/modules/restify/set-framework.test.js
409409

410+
# https://www.fastify.io/docs/latest/LTS/
411+
# - #1086 suggests [email protected] was a broken release, skip it.
412+
fastify-v1:
413+
name: fastify
414+
versions: '1.x'
415+
node: '>=6 <12'
416+
commands:
417+
- node test/instrumentation/modules/fastify/fastify.test.js
418+
- node test/instrumentation/modules/fastify/async-await.test.js
419+
- node test/instrumentation/modules/fastify/set-framework.test.js
420+
fastify-v2:
421+
name: fastify
422+
versions: '>=2.0.0 <2.4.0 || >2.4.0 <3'
423+
node: '>=6 <15'
424+
commands:
425+
- node test/instrumentation/modules/fastify/fastify.test.js
426+
- node test/instrumentation/modules/fastify/async-await.test.js
427+
- node test/instrumentation/modules/fastify/set-framework.test.js
410428
fastify:
411-
versions: '>=0.27.0 <0.29.0 || >0.29.0 <2.4.0 || >2.4.0'
429+
name: fastify
430+
versions: '>=3.0.0'
431+
node: '>=10'
412432
commands:
413433
- node test/instrumentation/modules/fastify/fastify.test.js
414434
- node test/instrumentation/modules/fastify/async-await.test.js

CHANGELOG.asciidoc

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ Notes:
3333
[float]
3434
===== Breaking changes
3535
36+
* Remove support for instrumenting versions of fastify earlier than 1.0.0.
37+
This instrumentation might still work, but is no longer supported.
38+
Fastify v1.0.0 was released in 2018. All current users should be using
39+
fastify v2 or v3 at least. See https://www.fastify.io/docs/latest/LTS/
40+
({pull}2387[#2387])
41+
3642
[float]
3743
===== Features
3844
39-
* Add initial support for version 8 of `@elastic/elasticsearch` (which is
40-
still in pre-release).
45+
* Add initial support for version 8 of `@elastic/elasticsearch`, which is
46+
still in pre-release. ({pull}2385[#2385])
4147
4248
[float]
4349
===== Bug fixes

docs/fastify.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ include::./shared-set-up.asciidoc[tag=add-your-own-data]
121121
==== Compatibility
122122

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

125126
[float]
126127
[[fastify-troubleshooting]]

docs/supported-technologies.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ These are the frameworks that we officially support:
4646
router information for full support. We currently support the most popular Koa router called
4747
https://github.com/alexmingoia/koa-router[koa-router].
4848
|<<restify,Restify>> |>=5.2.0
49-
|<<fastify,Fastify>> |>=0.27.0
49+
|<<fastify,Fastify>> |>=1.0.0; see also https://www.fastify.io/docs/latest/LTS/[Fastify's own LTS documentation]
5050
|=======================================================================
5151

5252
[float]

lib/instrumentation/modules/fastify.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict'
22

3+
// Instrumentation of fastify.
4+
// https://www.fastify.io/docs/latest/LTS/
5+
36
const semver = require('semver')
47

58
module.exports = function (fastify, agent, { version, enabled }) {

test/instrumentation/modules/hapi/shared.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,16 @@ module.exports = (moduleName) => {
524524
})
525525

526526
function makeServer (opts) {
527-
var server = new Hapi.Server({ host: 'localhost' })
527+
// Specify 'localhost' to avoid Hapi default of '0.0.0.0' which ties to
528+
// IPv4. We want a later HTTP client request using 'localhost' to work.
529+
var server
528530
if (semver.satisfies(pkg.version, '<17')) {
531+
server = new Hapi.Server()
532+
opts = opts || {}
533+
opts.host = opts.host || 'localhost'
529534
server.connection(opts)
535+
} else {
536+
server = new Hapi.Server({ host: 'localhost' })
530537
}
531538
return server
532539
}

0 commit comments

Comments
 (0)