Skip to content

Commit 07247df

Browse files
committed
test: reduce TAV test matrix for slowest jobs (#3321)
This tweaks the .tav.yml config for most TAV test matrix jobs that were observed to be taking >20 minutes in CI recently. One job was taking longer than 40 minutes and being aborted: test-tav (14, bluebird,got,mimic-response) - mimic-response: The agent instruments and will only ever instrument a single version: v1.0.0. Therefore there is no need for to "test all versions" as long as the regular non-TAV tests test that version. Lock package.json to that version. - bluebird, got, pg, mongodb-core, knex, tedious: Massively reduce the number of versions tested when the latest release for a given major version was more than 2-3 years ago. - fastify, aws-sdk: Update the tested ranges to test the first, last, and approximately 5 versions in between. (Added ./dev-utils/tav-versions-fastify.sh for this.) Also: - Fix a test in bluebird.test.js to be less flaky. In a local run it was observed to fail the 'new Promise -> timeout (timed out)' test case with: `Error: start + 49 should be <= 1683227232779 - was 1683227232782`.
1 parent d56f784 commit 07247df

File tree

6 files changed

+105
-50
lines changed

6 files changed

+105
-50
lines changed

.ci/tav.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@
3535
"ws",
3636
"@koa/router,koa-router",
3737
"handlebars,pug",
38-
"bluebird,got,mimic-response"
38+
"bluebird,got"
3939
]
4040
}

.tav.yml

+42-32
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,28 @@ generic-pool:
1111
versions: ^2.0.0 || ^3.1.0
1212
commands: node test/instrumentation/modules/generic-pool.test.js
1313

14-
mimic-response:
15-
versions: ^1.0.0
16-
commands:
17-
- node test/instrumentation/modules/mimic-response.test.js
18-
- node test/instrumentation/modules/http/github-179.test.js
19-
2014
# Testing 'got' was initially added to test an issue in its usage of
2115
# [email protected]. However, this test case serves to sanity test 'got'
2216
# usage with the agent. Got@12 is pure ESM, so cannot currently be tested with
2317
# the current test script.
18+
#
19+
# Supported got versions: '>=4 <12'. As of v11.8.6, this range includes 103
20+
# got versions. Testing all these versions as a "sanity test" is a waste of
21+
# resources. Instead we test just a few: the latest 8.x, 9.x, and 10.x (all
22+
# no longer getting releases); and >=11.8.6.
2423
got-v4-v9:
2524
name: got
26-
versions: '>=4.0.0 <9.0.0'
25+
versions: '8.3.2'
2726
node: '>=5'
2827
commands: node test/instrumentation/modules/http/github-423.test.js
2928
got-v9:
3029
name: got
31-
versions: ^9.0.0
30+
versions: '9.6.0'
3231
node: '>=8.3'
3332
commands: node test/instrumentation/modules/http/github-423.test.js
3433
got-v10-v12:
3534
name: got
36-
versions: '>=10.0.0 <10.5.1 || >10.5.1 <12' # v10.5.1 is broken
35+
versions: '10.7.0 || >=11.8.6 <12'
3736
node: '>=10.16.0'
3837
commands: node test/instrumentation/modules/http/github-423.test.js
3938

@@ -109,10 +108,11 @@ pg-old-node:
109108
name: pg
110109
# We want this version range:
111110
# versions: '>=4 <9'
112-
# but only the latest MAJOR.MINOR.x to reduce the test matrix.
111+
# but test a subset to reduce the test matrix. The last 4.x release was in
112+
# 2017, 5.x in 2017, 6.x in 2017, 7.x in 2020.
113113
#
114114
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
115-
versions: '4.0.0 || 4.1.1 || 4.2.0 || 4.3.0 || 4.4.6 || 4.5.7 || 5.0.0 || 5.1.0 || 5.2.1 || 6.0.5 || 6.1.6 || 6.2.5 || 6.3.3 || 6.4.2 || 7.0.3 || 7.1.2 || 7.2.0 || 7.3.0 || 7.4.3 || 7.5.0 || 7.6.1 || 7.7.1 || 7.8.2 || 7.9.0 || 7.10.0 || 7.11.0 || 7.12.1 || 7.13.0 || 7.14.0 || 7.15.2 || 7.16.1 || 7.17.1 || 7.18.2 || 8.0.3 || 8.1.0 || 8.2.2 || 8.3.3 || 8.4.2 || 8.5.1 || 8.6.0 || >8.6.0 <9'
115+
versions: '4.0.0 || 4.5.7 || 5.2.1 || 6.4.2 || 7.18.2 || 8.0.3 || 8.1.0 || 8.2.2 || 8.3.3 || 8.4.2 || 8.5.1 || 8.6.0 || 8.7.3 || 8.8.0 || 8.9.0 || 8.10.0 || >8.10.0 <9'
116116
node: '<14'
117117
peerDependencies:
118118
- bluebird@^3.0.0
@@ -127,16 +127,19 @@ pg-new-node:
127127
# but only the latest MAJOR.MINOR.x to reduce the test matrix.
128128
#
129129
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
130-
versions: '8.0.3 || 8.1.0 || 8.2.2 || 8.3.3 || 8.4.2 || 8.5.1 || 8.6.0 || >8.6.0 <9'
130+
versions: '8.0.3 || 8.1.0 || 8.2.2 || 8.3.3 || 8.4.2 || 8.5.1 || 8.6.0 || 8.7.3 || 8.8.0 || 8.9.0 || 8.10.0 || >8.10.0 <9'
131131
node: '>=14'
132132
peerDependencies:
133133
- bluebird@^3.0.0
134134
- knex@^0.17.3
135135
commands:
136136
- node test/instrumentation/modules/pg/pg.test.js
137137
- node test/instrumentation/modules/pg/knex.test.js
138+
139+
# Latest mongodb-core release (v3.2.7) was released in 2019. We test a subset
140+
# of the full supported range.
138141
mongodb-core:
139-
versions: '>=1.2.19 <4'
142+
versions: '1.2.19 || 1.2.32 || 1.3.21 || 2.0.14 || 2.1.20 || 3.0.11 || 3.1.11 || 3.2.7' # latest minors subset of '>=1.2.19 <4'
140143
commands: node test/instrumentation/modules/mongodb-core.test.js
141144

142145
mongodb-3:
@@ -154,30 +157,37 @@ mongodb:
154157
node: '>=14.20.1'
155158
commands: node test/instrumentation/modules/mongodb.test.js
156159

160+
# Bluebird is effectively deprecated (https://github.com/petkaantonov/bluebird#%EF%B8%8Fnote%EF%B8%8F).
161+
# Testing the full set of supported bluebird releases (`>=2 <4`) is currently
162+
# 119 releases. The last release was in 2019. Testing that many is a waste of
163+
# resources. Instead we test just the latest 3.x release.
157164
bluebird:
158-
versions: '>=2 <4'
165+
versions: '3.7.2'
159166
commands:
160167
- node test/instrumentation/modules/bluebird/bluebird.test.js
161168
- node test/instrumentation/modules/bluebird/cancel.test.js
169+
162170
# knex (https://github.com/knex/knex/blob/master/UPGRADING.md)
163171
# - knex 0.18.0 min supported node is v8
164172
# - knex 0.21.0 min supported node is v10
165173
# - knex 1.0.0 min supported node is v12
166174
knex-v0.9-v0.17:
167175
name: knex
168-
# v0.16.4 accidentally dropped support for Node.js 6
169-
versions: ^0.16.5 || <0.16.4 >=0.16.0 || ^0.15.0 || ^0.14.0 || ^0.13.0 || ^0.12.5 || <0.12.4 >0.11.6 || <0.11.6 >0.9.0
176+
# Latest 0.16 release was in 2019, therefore only test first and last in this range.
177+
versions: '0.9.0 || 0.16.5'
170178
commands: node test/instrumentation/modules/pg/knex.test.js
171179
knex-v0.17-v0.21:
172180
name: knex
173181
node: '>=8.6.0'
174-
versions: '>=0.17 <0.21'
182+
# Latest 0.20.x release was 2020-04, there only test first and last in this range.
183+
versions: '0.17.0 || 0.20.15'
175184
commands: node test/instrumentation/modules/pg/knex.test.js
176185
knex-v0.21-v1:
177186
name: knex
178187
node: '>=10.22.0'
179-
versions: '>=0.21 <1' # Use '<1' to catch a 0.96.x release if there ever is one.
188+
versions: '0.21.21 || 0.95.15' # latest minors subset of '>=0.21 <1'
180189
commands: node test/instrumentation/modules/pg/knex.test.js
190+
181191
ws-old:
182192
name: ws
183193
versions: '>=1 <7'
@@ -371,26 +381,24 @@ pug:
371381
tedious-v1-v11:
372382
name: tedious
373383
node: '>=6'
374-
# - tedious@4.0.0 was broken, fixed in 4.0.1 by https://github.com/tediousjs/tedious/commit/4eceb48
375-
versions: '^1.9.0 || 2.x || 3.x || ^4.0.1 || 5.x || 6.x || 7.x || 8.x || 9.x || 10.x'
384+
# latest majors subset of '>=1.9.0 <4.0.0 || >4.0.1 <11'
385+
versions: '1.9.0 || 1.15.0 || 2.7.1 || 3.0.1 || 4.2.0 || 5.0.3 || 6.7.1 || 7.0.0 || 8.3.1 || 9.2.3 || 10.0.0'
376386
commands: node test/instrumentation/modules/tedious.test.js
377-
378387
tedious-v11-v12:
379388
name: tedious
380389
node: '>=10.17.0'
381-
versions: '11.x'
390+
versions: '11.0.0 || 11.8.0' # first and last subset of '11.x'
382391
commands: node test/instrumentation/modules/tedious.test.js
383-
384392
tedious-v12-v15:
385393
name: tedious
386394
node: '>=12.3.0'
387-
versions: '12.x || 13.x || 14.x'
395+
# first and last majors subset of '12.x || 13.x || 14.x'
396+
versions: '12.0.0 || 12.3.0 || 13.0.0 || 13.2.0 || 14.0.0 || 14.7.0 || >14.7.0 <15'
388397
commands: node test/instrumentation/modules/tedious.test.js
389-
390398
tedious:
391399
name: tedious
392400
node: '>=14'
393-
versions: '15.x'
401+
versions: '15.0.0 || 15.1.3 || >15.1.3 <16' # first and last majors subset of '15.x'
394402
commands: node test/instrumentation/modules/tedious.test.js
395403

396404
cassandra-driver:
@@ -440,23 +448,24 @@ restify-v10-v12:
440448
# for fastify >=3.
441449
fastify-v1:
442450
name: fastify
443-
versions: '1.x'
451+
versions: '1.0.0 || 1.14.6' # subset of '1.x'
444452
node: '>=6 <12'
445453
commands:
446454
- node test/instrumentation/modules/fastify/fastify.test.js
447455
- node test/instrumentation/modules/fastify/async-await.test.js
448456
- node test/instrumentation/modules/fastify/set-framework.test.js
449457
fastify-v2:
450458
name: fastify
451-
versions: '>=2.0.0 <2.4.0 || >2.4.0 <3'
459+
versions: '2.0.0 || 2.15.3' # subset of '>=2.0.0 <2.4.0 || >2.4.0 <3'
452460
node: '>=6 <15'
453461
commands:
454462
- node test/instrumentation/modules/fastify/fastify.test.js
455463
- node test/instrumentation/modules/fastify/async-await.test.js
456464
- node test/instrumentation/modules/fastify/set-framework.test.js
457465
fastify-v3:
458466
name: fastify
459-
versions: '>=3.0.0 <4'
467+
# Update versions periodically with "./dev-utils/tav-versions-fastify.sh".
468+
versions: '3.0.0 || 3.6.0 || 3.14.2 || 3.20.1 || 3.24.0 || 3.29.0 || 3.29.5 || >3.29.5 <4' # subset of '>=3 <4'
460469
peerDependencies: '@fastify/formbody@^6.0.1'
461470
node: '>=10'
462471
commands:
@@ -466,7 +475,8 @@ fastify-v3:
466475
- node test/sanitize-field-names/fastify.test.js
467476
fastify:
468477
name: fastify
469-
versions: '>=4 <4.0.1 || >4.0.1 <4.16.0 || >4.16.2'
478+
# Update versions periodically with "./dev-utils/tav-versions-fastify.sh".
479+
versions: '4.0.0 || 4.2.1 || 4.5.2 || 4.8.1 || 4.10.1 || 4.14.0 || 4.17.0 || >4.17.0' # subset of '>=4 <4.0.1 || >4.0.1 <4.16.0 || >4.16.2'
470480
peerDependencies: '@fastify/formbody@^7'
471481
node: '>=14.6.0'
472482
commands:
@@ -498,8 +508,8 @@ aws-sdk:
498508
# Maintenance note: This should be updated periodically using:
499509
# ./dev-utils/aws-sdk-tav-versions.sh
500510
#
501-
# Test v2.858.0, every N=88 of 445 releases, and current latest.
502-
versions: '2.858.0 || 2.946.0 || 2.1034.0 || 2.1122.0 || 2.1210.0 || 2.1298.0 || 2.1302.0 || >2.1302.0 <3'
511+
# Test v2.858.0, every N=102 of 515 releases, and current latest.
512+
versions: '2.858.0 || 2.960.0 || 2.1062.0 || 2.1164.0 || 2.1266.0 || 2.1368.0 || 2.1372.0 || >2.1372.0 <3'
503513
commands:
504514
- node test/instrumentation/modules/aws-sdk/aws4-retries.test.js
505515
- node test/instrumentation/modules/aws-sdk/s3.test.js

dev-utils/tav-versions-fastify.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
#
3+
# Calculate and emit the "versions:" blocks of ".tav.yml" for "fastify".
4+
#
5+
# This will include:
6+
# - the first supported release (2.858.0)
7+
# - the latest current release
8+
# - and ~5 releases in between
9+
10+
# For the `fastify-v3:` block.
11+
npm info -j fastify | node -e '
12+
var semver = require("semver");
13+
var chunks = [];
14+
process.stdin
15+
.resume()
16+
.on("data", (chunk) => { chunks.push(chunk) })
17+
.on("end", () => {
18+
var fullRange = ">=3 <4";
19+
var input = JSON.parse(chunks.join(""));
20+
var vers = input.versions.filter(v => semver.satisfies(v, fullRange));
21+
var modulus = Math.floor((vers.length - 2) / 5);
22+
vers = vers.filter((v, idx, arr) => idx % modulus === 0 || idx === arr.length - 1);
23+
console.log(" versions: '\''%s || >%s <4'\'' # subset of '\''%s'\''", vers.join(" || "), vers[vers.length-1], fullRange)
24+
})
25+
'
26+
27+
# For the `fastify:` block.
28+
npm info -j fastify | node -e '
29+
var semver = require("semver");
30+
var chunks = [];
31+
process.stdin
32+
.resume()
33+
.on("data", (chunk) => { chunks.push(chunk) })
34+
.on("end", () => {
35+
var fullRange = ">=4 <4.0.1 || >4.0.1 <4.16.0 || >4.16.2";
36+
var input = JSON.parse(chunks.join(""));
37+
var vers = input.versions.filter(v => semver.satisfies(v, fullRange));
38+
var modulus = Math.floor((vers.length - 2) / 5);
39+
vers = vers.filter((v, idx, arr) => idx % modulus === 0 || idx === arr.length - 1);
40+
console.log(" versions: '\''%s || >%s'\'' # subset of '\''%s'\''", vers.join(" || "), vers[vers.length-1], fullRange)
41+
})
42+
'

package-lock.json

+8-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"koa-router": "^12.0.0",
177177
"lambda-local": "^2.0.2",
178178
"memcached": "^2.2.2",
179-
"mimic-response": "^2.1.0",
179+
"mimic-response": "1.0.0",
180180
"mkdirp": "^0.5.1",
181181
"mongodb": "^5.1.0",
182182
"mongodb-core": "^3.2.7",

test/instrumentation/modules/bluebird/bluebird.test.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,10 @@ test('new Promise -> timeout (reject in time)', function (t) {
11391139
})
11401140

11411141
test('new Promise -> timeout (timed out)', function (t) {
1142+
// Allowable number of ms of slop in the `.timeout(N)` actual time.
1143+
// Anecdotally, I have seen +/- 6ms locally and in CI.
1144+
const SLOP_MS = 10
1145+
11421146
t.plan(6)
11431147
twice(function () {
11441148
var trans = ins.startTransaction()
@@ -1151,11 +1155,13 @@ test('new Promise -> timeout (timed out)', function (t) {
11511155
}).timeout(50).then(function () {
11521156
t.fail('should not resolve')
11531157
}).catch(function (err) {
1154-
var expected = start + 49 // timings are hard
1155-
var now = Date.now()
1156-
t.ok(expected <= now, 'start + 49 should be <= ' + now + ' - was ' + expected)
1157-
t.ok(err instanceof Promise.TimeoutError)
1158-
t.strictEqual(ins.currTransaction().id, trans.id)
1158+
// You would think elapsed would always be >=50ms, but in busy CI I have
1159+
// seen slightly *less than* 50ms.
1160+
var elapsedMs = Date.now() - start
1161+
var diffMs = Math.abs(50 - elapsedMs)
1162+
t.ok(diffMs <= SLOP_MS, `.timeout(50) resulted in 50 +/- ${SLOP_MS}, actual elapsed was ${elapsedMs}ms`)
1163+
t.ok(err instanceof Promise.TimeoutError, 'err')
1164+
t.strictEqual(ins.currTransaction().id, trans.id, 'transaction.id')
11591165
})
11601166
})
11611167
})

0 commit comments

Comments
 (0)