From 09769ca525ecaa6e7f8edfbcfc857a742110917f Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 27 Oct 2021 21:31:16 -0700 Subject: [PATCH 01/17] tests: move module test deps and .tav.yml to separate packages This is just a first stab, so far. --- .gitignore | 1 + .tav.yml | 10 -------- package.json | 8 +++--- .../instrumentation/modules/handlebars/.npmrc | 1 + .../modules/handlebars/.tav.yml | 3 +++ .../{ => handlebars}/handlebars.test.js | 6 ++--- .../modules/handlebars/package.json | 8 ++++++ test/instrumentation/modules/jade/.npmrc | 1 + test/instrumentation/modules/jade/.tav.yml | 3 +++ .../modules/{ => jade}/jade.test.js | 6 ++--- .../instrumentation/modules/jade/package.json | 8 ++++++ test/instrumentation/modules/pug/.npmrc | 1 + test/instrumentation/modules/pug/.tav.yml | 3 +++ test/instrumentation/modules/pug/package.json | 8 ++++++ .../modules/{ => pug}/pug.test.js | 6 ++--- test/script/prepare-tests.sh | 25 +++++++++++++++++++ test/script/run_tests.sh | 6 +++++ test/script/tav-in-module-dirs.sh | 17 +++++++++++++ test/test.js | 3 +++ 19 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 test/instrumentation/modules/handlebars/.npmrc create mode 100644 test/instrumentation/modules/handlebars/.tav.yml rename test/instrumentation/modules/{ => handlebars}/handlebars.test.js (89%) create mode 100644 test/instrumentation/modules/handlebars/package.json create mode 100644 test/instrumentation/modules/jade/.npmrc create mode 100644 test/instrumentation/modules/jade/.tav.yml rename test/instrumentation/modules/{ => jade}/jade.test.js (90%) create mode 100644 test/instrumentation/modules/jade/package.json create mode 100644 test/instrumentation/modules/pug/.npmrc create mode 100644 test/instrumentation/modules/pug/.tav.yml create mode 100644 test/instrumentation/modules/pug/package.json rename test/instrumentation/modules/{ => pug}/pug.test.js (90%) create mode 100755 test/script/prepare-tests.sh create mode 100755 test/script/tav-in-module-dirs.sh diff --git a/.gitignore b/.gitignore index 7a7f3d2b75..0d5c68d5b1 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ /node_modules /test/benchmarks/.tmp /tmp +/test/instrumentation/**/node_modules diff --git a/.tav.yml b/.tav.yml index 3d38f5d6c3..31e7b7edfb 100644 --- a/.tav.yml +++ b/.tav.yml @@ -315,16 +315,6 @@ elasticsearch: node: '>=12' commands: node test/instrumentation/modules/@elastic/elasticsearch-canary.test.js -handlebars: - versions: '*' - commands: node test/instrumentation/modules/handlebars.test.js -jade: - versions: '>0.5.5' - commands: node test/instrumentation/modules/jade.test.js -pug: - versions: '0.1.0 || >2.0.0' - commands: node test/instrumentation/modules/pug.test.js - # hapi and @hapi/hapi # - Package name: Starting with v17.9.0 and v18.2.0 the name changed from # 'hapi' to '@hapi/hapi'. diff --git a/package.json b/package.json index 1f8ffa2e92..a65a63b871 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,11 @@ "lint": "standard", "lint:fix": "standard --fix", "coverage": "COVERAGE=true ./test/script/run_tests.sh", + "test:prepare": "./test/script/prepare-tests.sh", "test": "./test/script/run_tests.sh", "test:cli": "node test/script/cli.js", - "test:deps": "dependency-check start.js index.js 'lib/**/*.js' 'test/**/*.js' --no-dev -i async_hooks -i perf_hooks -i parseurl", - "test:tav": "tav --quiet", + "test:deps": "dependency-check start.js index.js 'lib/**/*.js' 'test/**/*.js' '!test/instrumentation/modules/**' --no-dev -i async_hooks -i perf_hooks -i parseurl", + "test:tav": "./test/scripts/tav-in-module-dirs.sh && tav --quiet", "test:docs": "./test/script/docker/run_docs.sh", "test:types": "tsc --project test/types/tsconfig.json && tsc --project test/types/transpile/tsconfig.json && node test/types/transpile/index.js && tsc --project test/types/transpile-default/tsconfig.json && node test/types/transpile-default/index.js", "test:babel": "babel test/babel/src.js --out-file test/babel/out.js && node test/babel/out.js", @@ -149,12 +150,10 @@ "get-port": "^5.1.1", "got": "^9.6.0", "graphql": "^15.3.0", - "handlebars": "^4.7.3", "hapi": "^18.1.0", "https-pem": "^2.0.0", "inquirer": "^0.12.0", "ioredis": "^4.16.0", - "jade": "^1.11.0", "knex": "^0.21.2", "koa": "^2.11.0", "koa-bodyparser": "^3.2.0", @@ -174,7 +173,6 @@ "once": "^1.4.0", "p-finally": "^2.0.1", "pg": "^8.7.1", - "pug": "^2.0.4", "redis": "^3.0.2", "request": "^2.88.2", "restify": "^8.5.1", diff --git a/test/instrumentation/modules/handlebars/.npmrc b/test/instrumentation/modules/handlebars/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/handlebars/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/handlebars/.tav.yml b/test/instrumentation/modules/handlebars/.tav.yml new file mode 100644 index 0000000000..003cd76f27 --- /dev/null +++ b/test/instrumentation/modules/handlebars/.tav.yml @@ -0,0 +1,3 @@ +handlebars: + versions: '*' + commands: node handlebars.test.js diff --git a/test/instrumentation/modules/handlebars.test.js b/test/instrumentation/modules/handlebars/handlebars.test.js similarity index 89% rename from test/instrumentation/modules/handlebars.test.js rename to test/instrumentation/modules/handlebars/handlebars.test.js index 312c030436..3e7aec8ac1 100644 --- a/test/instrumentation/modules/handlebars.test.js +++ b/test/instrumentation/modules/handlebars/handlebars.test.js @@ -2,7 +2,7 @@ process.env.ELASTIC_APM_TEST = true -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -14,8 +14,8 @@ var agent = require('../../..').start({ var handlebars = require('handlebars') var test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test('handlebars compile and render', function userLandCode (t) { resetAgent(function (data) { diff --git a/test/instrumentation/modules/handlebars/package.json b/test/instrumentation/modules/handlebars/package.json new file mode 100644 index 0000000000..d8b7461f4d --- /dev/null +++ b/test/instrumentation/modules/handlebars/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-handlebars", + "version": "1.0.0", + "private": true, + "dependencies": { + "handlebars": "^4.7.3" + } +} diff --git a/test/instrumentation/modules/jade/.npmrc b/test/instrumentation/modules/jade/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/jade/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/jade/.tav.yml b/test/instrumentation/modules/jade/.tav.yml new file mode 100644 index 0000000000..7e46a6e1d9 --- /dev/null +++ b/test/instrumentation/modules/jade/.tav.yml @@ -0,0 +1,3 @@ +jade: + versions: '>0.5.5' + commands: node jade.test.js diff --git a/test/instrumentation/modules/jade.test.js b/test/instrumentation/modules/jade/jade.test.js similarity index 90% rename from test/instrumentation/modules/jade.test.js rename to test/instrumentation/modules/jade/jade.test.js index 24637f2789..3b90a74fd2 100644 --- a/test/instrumentation/modules/jade.test.js +++ b/test/instrumentation/modules/jade/jade.test.js @@ -2,7 +2,7 @@ process.env.ELASTIC_APM_TEST = true -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -14,8 +14,8 @@ var agent = require('../../..').start({ var jade = require('jade') var test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test('jade compile and render', function userLandCode (t) { resetAgent(function (data) { diff --git a/test/instrumentation/modules/jade/package.json b/test/instrumentation/modules/jade/package.json new file mode 100644 index 0000000000..5ef7702732 --- /dev/null +++ b/test/instrumentation/modules/jade/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-jade", + "version": "1.0.0", + "private": true, + "dependencies": { + "jade": "^1.11.0" + } +} diff --git a/test/instrumentation/modules/pug/.npmrc b/test/instrumentation/modules/pug/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/pug/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/pug/.tav.yml b/test/instrumentation/modules/pug/.tav.yml new file mode 100644 index 0000000000..c2d62e83fa --- /dev/null +++ b/test/instrumentation/modules/pug/.tav.yml @@ -0,0 +1,3 @@ +pug: + versions: '0.1.0 || >2.0.0' + commands: node pug.test.js diff --git a/test/instrumentation/modules/pug/package.json b/test/instrumentation/modules/pug/package.json new file mode 100644 index 0000000000..b219b4fe85 --- /dev/null +++ b/test/instrumentation/modules/pug/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-pug", + "version": "1.0.0", + "private": true, + "dependencies": { + "pug": "^3.0.2" + } +} diff --git a/test/instrumentation/modules/pug.test.js b/test/instrumentation/modules/pug/pug.test.js similarity index 90% rename from test/instrumentation/modules/pug.test.js rename to test/instrumentation/modules/pug/pug.test.js index cf95f88455..e380bf2a3a 100644 --- a/test/instrumentation/modules/pug.test.js +++ b/test/instrumentation/modules/pug/pug.test.js @@ -2,7 +2,7 @@ process.env.ELASTIC_APM_TEST = true -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -14,8 +14,8 @@ var agent = require('../../..').start({ var pug = require('pug') var test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test('pug compile and render', function userLandCode (t) { resetAgent(function (data) { diff --git a/test/script/prepare-tests.sh b/test/script/prepare-tests.sh new file mode 100755 index 0000000000..53d27f0e3e --- /dev/null +++ b/test/script/prepare-tests.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Prepare for testing by 'npm install'ing in module test dirs with package.json +# files. +# + +if [ "$TRACE" != "" ]; then + export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + set -o xtrace +fi +set -o errexit +set -o pipefail + +TESTDIR=$(cd $(dirname $0)/.. >/dev/null && pwd) + +function fatal { + echo "$(basename $0): error: $*" + exit 1 +} + +ls $TESTDIR/instrumentation/modules/*/package.json | while read f; do + d=$(dirname $f) + echo "# $d" + (cd $d && npm install) +done diff --git a/test/script/run_tests.sh b/test/script/run_tests.sh index 5d3017dbdd..891e2b4f22 100755 --- a/test/script/run_tests.sh +++ b/test/script/run_tests.sh @@ -41,6 +41,12 @@ run_test_suite () { standard npm run test:deps + # Automatically prepare for tests if this looks like a first time run of + # 'npm test'. Using 'pug/' as a canary dir. + if [[ ! -d test/instrumentation/modules/pug/node_modules ]]; then + npm run test:prepare + fi + if [ -z "$COVERAGE" ] then node test/test.js diff --git a/test/script/tav-in-module-dirs.sh b/test/script/tav-in-module-dirs.sh new file mode 100755 index 0000000000..1a17245189 --- /dev/null +++ b/test/script/tav-in-module-dirs.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Run `tav` in each of the test/instrumentation/modules/$module dirs. +# + +if [ "$TRACE" != "" ]; then + export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + set -o xtrace +fi +set -o errexit +set -o pipefail + +TAV=$(pwd)/node_modules/.bin/tav +find ./test/instrumentation/modules -name .tav.yml | while read f; do + echo "-- $f" + (cd $(dirname $f) && $TAV) +done diff --git a/test/test.js b/test/test.js index 7dff126d39..965f91a07a 100644 --- a/test/test.js +++ b/test/test.js @@ -80,13 +80,16 @@ var directories = [ 'test/instrumentation/modules/cassandra-driver', 'test/instrumentation/modules/express', 'test/instrumentation/modules/fastify', + 'test/instrumentation/modules/handlebars', 'test/instrumentation/modules/hapi', 'test/instrumentation/modules/http', + 'test/instrumentation/modules/jade', 'test/instrumentation/modules/koa', 'test/instrumentation/modules/koa-router', 'test/instrumentation/modules/mysql', 'test/instrumentation/modules/mysql2', 'test/instrumentation/modules/pg', + 'test/instrumentation/modules/pug', 'test/instrumentation/modules/restify', 'test/instrumentation/modules/aws-sdk', 'test/instrumentation/run-context', From 67055b568ab5ee89dc5dce3a57d20a6928ccdfe8 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 19:16:48 -0700 Subject: [PATCH 02/17] fix broken 'disableInstrumentations' test --- .ci/Jenkinsfile | 2 + test/config.test.js | 95 +++++++++++++-------------------------------- 2 files changed, 29 insertions(+), 68 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 30536a1081..89cf65f435 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -414,8 +414,10 @@ def getSmartTAVContext() { } } else if (params.Run_As_Master_Branch) { context.ghDescription = 'TAV Test param-triggered' + // XXX could change this to look for .tav.yml files under test/instrumentation/modules context.tav = readYaml(file: '.ci/.jenkins_tav.yml') } else if (env.CHANGE_ID && env.TAV_UPDATED != "false") { + // XXX What is this used for? context.ghContextName = 'TAV Test Subset' context.ghDescription = 'TAV Test changes-triggered' sh '.ci/scripts/get_tav.sh .ci/.jenkins_generated_tav.yml' diff --git a/test/config.test.js b/test/config.test.js index 2b99d226f2..264fe5611b 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -860,82 +860,41 @@ usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { }) test('disableInstrumentations', function (t) { - var expressGraphqlVersion = require('express-graphql/package.json').version - var esVersion = safeGetPackageVersion('@elastic/elasticsearch') - const esCanaryVersion = safeGetPackageVersion('@elastic/elasticsearch-canary') + // The set of "all" modules that have instrumentations and that can be + // require'd, given what is in "dependencies" in package.json. + const allModules = new Set(['http', 'https', 'http2']) - // require('apollo-server-core') is a hard crash on nodes < 12.0.0 - const apolloServerCoreVersion = require('apollo-server-core/package.json').version + function testADisableInstrumentationsValue (configValue) { + var modulesToDisable = new Set(typeof configValue === 'string' + ? configValue.split(',') + : configValue) - var flattenedModules = Instrumentation.modules.reduce((acc, val) => acc.concat(val), []) - var modules = new Set(flattenedModules) - if (isHapiIncompat('hapi')) { - modules.delete('hapi') - } - if (isHapiIncompat('@hapi/hapi')) { - modules.delete('@hapi/hapi') - } - if (semver.lt(process.version, '7.6.0') && semver.gte(expressGraphqlVersion, '0.9.0')) { - modules.delete('express-graphql') - } - if (semver.lt(process.version, '10.0.0') && semver.gte(esVersion, '7.12.0')) { - modules.delete('@elastic/elasticsearch') - } - if (semver.lt(process.version, '10.0.0') && semver.gte(esCanaryVersion, '7.12.0')) { - modules.delete('@elastic/elasticsearch-canary') - } - // As of mongodb@4 only supports node >=v12. - const mongodbVersion = require('../node_modules/mongodb/package.json').version - if (semver.gte(mongodbVersion, '4.0.0') && semver.lt(process.version, '12.0.0')) { - modules.delete('mongodb') - } - - if (semver.gte(apolloServerCoreVersion, '3.0.0') && semver.lt(process.version, '12.0.0')) { - modules.delete('apollo-server-core') - } - - function testSlice (t, name, selector) { - var selection = selector(modules) - var selectionSet = new Set(typeof selection === 'string' ? selection.split(',') : selection) - - t.test(name + ' -> ' + Array.from(selectionSet).join(','), function (t) { - var agent = new Agent() - agent.start(Object.assign( - {}, - agentOptsNoopTransport, - { disableInstrumentations: selection } - )) - - var found = new Set() - - agent._instrumentation._patchModule = function (exports, name, version, enabled) { - if (!enabled) found.add(name) - return exports - } + var agent = new Agent() + agent.start(Object.assign( + {}, + agentOptsNoopTransport, + { disableInstrumentations: configValue } + )) - for (const mod of modules) { - require(mod) + var found = new Set() + agent._instrumentation._patchModule = function (exports, name, version, enabled) { + if (!enabled) { + found.add(name) } + return exports + } - t.deepEqual(selectionSet, found, 'disabled all selected modules') - - agent.destroy() - t.end() - }) - } + for (const mod of allModules) { + require(mod) + } + t.deepEqual(modulesToDisable, found, 'disabled all selected modules: ' + JSON.stringify(configValue)) - for (const mod of modules) { - testSlice(t, 'individual modules', () => new Set([mod])) + agent.destroy() } - testSlice(t, 'multiple modules by array', modules => { - return Array.from(modules).filter((value, index) => index % 2) - }) - - testSlice(t, 'multiple modules by csv string', modules => { - return Array.from(modules).filter((value, index) => !(index % 2)) - }) - + testADisableInstrumentationsValue('http2') // single value + testADisableInstrumentationsValue(['http2', 'http']) // array of values + testADisableInstrumentationsValue('https,http2') // comma-sep array of values t.end() }) From ccda718574013242736fb101f2b7a9aff97c6ba9 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 19:59:08 -0700 Subject: [PATCH 03/17] fix tav-in-modules-dirs dir; add generic-pool --- .tav.yml | 3 --- package.json | 3 +-- test/instrumentation/modules/generic-pool/.npmrc | 1 + test/instrumentation/modules/generic-pool/.tav.yml | 3 +++ .../modules/{ => generic-pool}/generic-pool.test.js | 2 +- test/instrumentation/modules/generic-pool/package.json | 8 ++++++++ test/script/tav-in-module-dirs.sh | 4 ++-- 7 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 test/instrumentation/modules/generic-pool/.npmrc create mode 100644 test/instrumentation/modules/generic-pool/.tav.yml rename test/instrumentation/modules/{ => generic-pool}/generic-pool.test.js (98%) create mode 100644 test/instrumentation/modules/generic-pool/package.json diff --git a/.tav.yml b/.tav.yml index 31e7b7edfb..8ae628be2e 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,6 +1,3 @@ -generic-pool: - versions: ^2.0.0 || ^3.1.0 - commands: node test/instrumentation/modules/generic-pool.test.js mimic-response: versions: ^1.0.0 commands: diff --git a/package.json b/package.json index a65a63b871..b12d28e5ee 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test": "./test/script/run_tests.sh", "test:cli": "node test/script/cli.js", "test:deps": "dependency-check start.js index.js 'lib/**/*.js' 'test/**/*.js' '!test/instrumentation/modules/**' --no-dev -i async_hooks -i perf_hooks -i parseurl", - "test:tav": "./test/scripts/tav-in-module-dirs.sh && tav --quiet", + "test:tav": "./test/script/tav-in-module-dirs.sh && tav --quiet", "test:docs": "./test/script/docker/run_docs.sh", "test:types": "tsc --project test/types/tsconfig.json && tsc --project test/types/transpile/tsconfig.json && node test/types/transpile/index.js && tsc --project test/types/transpile-default/tsconfig.json && node test/types/transpile-default/index.js", "test:babel": "babel test/babel/src.js --out-file test/babel/out.js && node test/babel/out.js", @@ -146,7 +146,6 @@ "fastify": "^2.12.0", "fastify-formbody": "^3.2", "finalhandler": "^1.1.2", - "generic-pool": "^3.7.1", "get-port": "^5.1.1", "got": "^9.6.0", "graphql": "^15.3.0", diff --git a/test/instrumentation/modules/generic-pool/.npmrc b/test/instrumentation/modules/generic-pool/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/generic-pool/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/generic-pool/.tav.yml b/test/instrumentation/modules/generic-pool/.tav.yml new file mode 100644 index 0000000000..bf509aaa6c --- /dev/null +++ b/test/instrumentation/modules/generic-pool/.tav.yml @@ -0,0 +1,3 @@ +generic-pool: + versions: ^2.0.0 || ^3.1.0 + commands: node generic-pool.test.js diff --git a/test/instrumentation/modules/generic-pool.test.js b/test/instrumentation/modules/generic-pool/generic-pool.test.js similarity index 98% rename from test/instrumentation/modules/generic-pool.test.js rename to test/instrumentation/modules/generic-pool/generic-pool.test.js index 13a9320167..e818153c8c 100644 --- a/test/instrumentation/modules/generic-pool.test.js +++ b/test/instrumentation/modules/generic-pool/generic-pool.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, diff --git a/test/instrumentation/modules/generic-pool/package.json b/test/instrumentation/modules/generic-pool/package.json new file mode 100644 index 0000000000..faa2f4035d --- /dev/null +++ b/test/instrumentation/modules/generic-pool/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-generic-pool", + "version": "1.0.0", + "private": true, + "dependencies": { + "generic-pool": "^3.7.1" + } +} diff --git a/test/script/tav-in-module-dirs.sh b/test/script/tav-in-module-dirs.sh index 1a17245189..5b157f2f00 100755 --- a/test/script/tav-in-module-dirs.sh +++ b/test/script/tav-in-module-dirs.sh @@ -10,8 +10,8 @@ fi set -o errexit set -o pipefail -TAV=$(pwd)/node_modules/.bin/tav +TAV_EXEC=$(pwd)/node_modules/.bin/tav find ./test/instrumentation/modules -name .tav.yml | while read f; do echo "-- $f" - (cd $(dirname $f) && $TAV) + (cd $(dirname $f) && $TAV_EXEC --quiet) done From 3152021ab5201b3f5a6e3f6cc3ecd80bba3590e4 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 20:22:09 -0700 Subject: [PATCH 04/17] migrate: got, mimic-response --- .tav.yml | 20 ------------------- package.json | 2 -- test/instrumentation/modules/got/.npmrc | 1 + test/instrumentation/modules/got/.tav.yml | 15 ++++++++++++++ .../modules/{http => got}/github-423.test.js | 0 test/instrumentation/modules/got/package.json | 8 ++++++++ .../modules/mimic-response/.npmrc | 1 + .../modules/mimic-response/.tav.yml | 5 +++++ .../github-179.test.js | 0 .../mimic-response.test.js | 2 +- .../modules/mimic-response/package.json | 8 ++++++++ test/test.js | 3 +++ 12 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 test/instrumentation/modules/got/.npmrc create mode 100644 test/instrumentation/modules/got/.tav.yml rename test/instrumentation/modules/{http => got}/github-423.test.js (100%) create mode 100644 test/instrumentation/modules/got/package.json create mode 100644 test/instrumentation/modules/mimic-response/.npmrc create mode 100644 test/instrumentation/modules/mimic-response/.tav.yml rename test/instrumentation/modules/{http => mimic-response}/github-179.test.js (100%) rename test/instrumentation/modules/{ => mimic-response}/mimic-response.test.js (96%) create mode 100644 test/instrumentation/modules/mimic-response/package.json diff --git a/.tav.yml b/.tav.yml index 8ae628be2e..8441f1741f 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,23 +1,3 @@ -mimic-response: - versions: ^1.0.0 - commands: - - node test/instrumentation/modules/mimic-response.test.js - - node test/instrumentation/modules/http/github-179.test.js -got-very-old: - name: got - versions: '>=4.0.0 <9.0.0' - node: '>=5' - commands: node test/instrumentation/modules/http/github-423.test.js -got-old: - name: got - versions: ^9.0.0 - node: '>=8.3' - commands: node test/instrumentation/modules/http/github-423.test.js -got-new: - name: got - versions: '>=10.0.0 <10.5.1 || >10.5.1' # v10.5.1 is broken - node: '>=10' - commands: node test/instrumentation/modules/http/github-423.test.js mysql: versions: ^2.0.0 commands: diff --git a/package.json b/package.json index b12d28e5ee..79f5b45436 100644 --- a/package.json +++ b/package.json @@ -147,7 +147,6 @@ "fastify-formbody": "^3.2", "finalhandler": "^1.1.2", "get-port": "^5.1.1", - "got": "^9.6.0", "graphql": "^15.3.0", "hapi": "^18.1.0", "https-pem": "^2.0.0", @@ -159,7 +158,6 @@ "koa-router": "^9.0.1", "lambda-local": "^1.7.1", "memcached": "^2.2.2", - "mimic-response": "^2.1.0", "mkdirp": "^0.5.1", "module-details-from-path": "^1.0.3", "mongodb": "^4.1.0", diff --git a/test/instrumentation/modules/got/.npmrc b/test/instrumentation/modules/got/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/got/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/got/.tav.yml b/test/instrumentation/modules/got/.tav.yml new file mode 100644 index 0000000000..c938f0936f --- /dev/null +++ b/test/instrumentation/modules/got/.tav.yml @@ -0,0 +1,15 @@ +got-very-old: + name: got + versions: '>=4.0.0 <9.0.0' + node: '>=5' + commands: node github-423.test.js +got-old: + name: got + versions: ^9.0.0 + node: '>=8.3' + commands: node github-423.test.js +got-new: + name: got + versions: '>=10.0.0 <10.5.1 || >10.5.1' # v10.5.1 is broken + node: '>=10' + commands: node github-423.test.js diff --git a/test/instrumentation/modules/http/github-423.test.js b/test/instrumentation/modules/got/github-423.test.js similarity index 100% rename from test/instrumentation/modules/http/github-423.test.js rename to test/instrumentation/modules/got/github-423.test.js diff --git a/test/instrumentation/modules/got/package.json b/test/instrumentation/modules/got/package.json new file mode 100644 index 0000000000..50f43f2820 --- /dev/null +++ b/test/instrumentation/modules/got/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-got", + "version": "1.0.0", + "private": true, + "dependencies": { + "got": "^9.6.0" + } +} diff --git a/test/instrumentation/modules/mimic-response/.npmrc b/test/instrumentation/modules/mimic-response/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/mimic-response/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/mimic-response/.tav.yml b/test/instrumentation/modules/mimic-response/.tav.yml new file mode 100644 index 0000000000..de16993ce8 --- /dev/null +++ b/test/instrumentation/modules/mimic-response/.tav.yml @@ -0,0 +1,5 @@ +mimic-response: + versions: ^1.0.0 + commands: + - node mimic-response.test.js + - node github-179.test.js diff --git a/test/instrumentation/modules/http/github-179.test.js b/test/instrumentation/modules/mimic-response/github-179.test.js similarity index 100% rename from test/instrumentation/modules/http/github-179.test.js rename to test/instrumentation/modules/mimic-response/github-179.test.js diff --git a/test/instrumentation/modules/mimic-response.test.js b/test/instrumentation/modules/mimic-response/mimic-response.test.js similarity index 96% rename from test/instrumentation/modules/mimic-response.test.js rename to test/instrumentation/modules/mimic-response/mimic-response.test.js index 278c687caf..92adfe145c 100644 --- a/test/instrumentation/modules/mimic-response.test.js +++ b/test/instrumentation/modules/mimic-response/mimic-response.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', captureExceptions: false, metricsInterval: 0, diff --git a/test/instrumentation/modules/mimic-response/package.json b/test/instrumentation/modules/mimic-response/package.json new file mode 100644 index 0000000000..0ffc55ca59 --- /dev/null +++ b/test/instrumentation/modules/mimic-response/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-mimic-response", + "version": "1.0.0", + "private": true, + "dependencies": { + "mimic-response": "^2.1.0" + } +} diff --git a/test/test.js b/test/test.js index 965f91a07a..7562f8c857 100644 --- a/test/test.js +++ b/test/test.js @@ -80,12 +80,15 @@ var directories = [ 'test/instrumentation/modules/cassandra-driver', 'test/instrumentation/modules/express', 'test/instrumentation/modules/fastify', + 'test/instrumentation/modules/generic-pool', + 'test/instrumentation/modules/got', 'test/instrumentation/modules/handlebars', 'test/instrumentation/modules/hapi', 'test/instrumentation/modules/http', 'test/instrumentation/modules/jade', 'test/instrumentation/modules/koa', 'test/instrumentation/modules/koa-router', + 'test/instrumentation/modules/mimic-response', 'test/instrumentation/modules/mysql', 'test/instrumentation/modules/mysql2', 'test/instrumentation/modules/pg', From db80ef1489e956a62bbba032607f466faf9f3ff7 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 20:39:00 -0700 Subject: [PATCH 05/17] migrate mysql tav; restore removed devDependencies --- .tav.yml | 5 ----- package.json | 6 ++++++ test/instrumentation/modules/mysql/.npmrc | 1 + test/instrumentation/modules/mysql/.tav.yml | 5 +++++ test/instrumentation/modules/mysql/package.json | 8 ++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 test/instrumentation/modules/mysql/.npmrc create mode 100644 test/instrumentation/modules/mysql/.tav.yml create mode 100644 test/instrumentation/modules/mysql/package.json diff --git a/.tav.yml b/.tav.yml index 8441f1741f..d4420984e7 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,8 +1,3 @@ -mysql: - versions: ^2.0.0 - commands: - - node test/instrumentation/modules/mysql/mysql.test.js - - node test/instrumentation/modules/mysql/pool-release-1.test.js mysql2-old: name: mysql2 versions: '>=1.0.0 <1.6.0' diff --git a/package.json b/package.json index 79f5b45436..09bd60101d 100644 --- a/package.json +++ b/package.json @@ -146,18 +146,23 @@ "fastify": "^2.12.0", "fastify-formbody": "^3.2", "finalhandler": "^1.1.2", + "generic-pool": "^3.7.1", "get-port": "^5.1.1", + "got": "^9.6.0", "graphql": "^15.3.0", + "handlebars": "^4.7.3", "hapi": "^18.1.0", "https-pem": "^2.0.0", "inquirer": "^0.12.0", "ioredis": "^4.16.0", + "jade": "^1.11.0", "knex": "^0.21.2", "koa": "^2.11.0", "koa-bodyparser": "^3.2.0", "koa-router": "^9.0.1", "lambda-local": "^1.7.1", "memcached": "^2.2.2", + "mimic-response": "^2.1.0", "mkdirp": "^0.5.1", "module-details-from-path": "^1.0.3", "mongodb": "^4.1.0", @@ -170,6 +175,7 @@ "once": "^1.4.0", "p-finally": "^2.0.1", "pg": "^8.7.1", + "pug": "^2.0.4", "redis": "^3.0.2", "request": "^2.88.2", "restify": "^8.5.1", diff --git a/test/instrumentation/modules/mysql/.npmrc b/test/instrumentation/modules/mysql/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/mysql/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/mysql/.tav.yml b/test/instrumentation/modules/mysql/.tav.yml new file mode 100644 index 0000000000..fd13536ec3 --- /dev/null +++ b/test/instrumentation/modules/mysql/.tav.yml @@ -0,0 +1,5 @@ +mysql: + versions: ^2.0.0 + commands: + - node mysql.test.js + - node pool-release-1.test.js diff --git a/test/instrumentation/modules/mysql/package.json b/test/instrumentation/modules/mysql/package.json new file mode 100644 index 0000000000..a3921c5939 --- /dev/null +++ b/test/instrumentation/modules/mysql/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-mysql", + "version": "1.0.0", + "private": true, + "dependencies": { + "mysql": "^2.18.1" + } +} From ef16ed72ed6e5cedd493d54522b3dd574f080519 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 20:56:19 -0700 Subject: [PATCH 06/17] migrate tav: mysql2, redis, ioredis --- .tav.yml | 25 ------------------- test/instrumentation/modules/ioredis/.npmrc | 1 + test/instrumentation/modules/ioredis/.tav.yml | 9 +++++++ .../modules/{ => ioredis}/ioredis.test.js | 4 +-- .../modules/ioredis/package.json | 8 ++++++ test/instrumentation/modules/mysql2/.npmrc | 1 + test/instrumentation/modules/mysql2/.tav.yml | 13 ++++++++++ .../modules/mysql2/package.json | 8 ++++++ test/instrumentation/modules/redis/.npmrc | 1 + test/instrumentation/modules/redis/.tav.yml | 3 +++ .../modules/redis/package.json | 8 ++++++ .../modules/{ => redis}/redis.test.js | 6 ++--- test/test.js | 2 ++ 13 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 test/instrumentation/modules/ioredis/.npmrc create mode 100644 test/instrumentation/modules/ioredis/.tav.yml rename test/instrumentation/modules/{ => ioredis}/ioredis.test.js (97%) create mode 100644 test/instrumentation/modules/ioredis/package.json create mode 100644 test/instrumentation/modules/mysql2/.npmrc create mode 100644 test/instrumentation/modules/mysql2/.tav.yml create mode 100644 test/instrumentation/modules/mysql2/package.json create mode 100644 test/instrumentation/modules/redis/.npmrc create mode 100644 test/instrumentation/modules/redis/.tav.yml create mode 100644 test/instrumentation/modules/redis/package.json rename test/instrumentation/modules/{ => redis}/redis.test.js (93%) diff --git a/.tav.yml b/.tav.yml index d4420984e7..46b8a370dd 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,28 +1,3 @@ -mysql2-old: - name: mysql2 - versions: '>=1.0.0 <1.6.0' - commands: - - node test/instrumentation/modules/mysql2/mysql.test.js - - node test/instrumentation/modules/mysql2/pool-release-1.test.js -mysql2-new: - name: mysql2 - versions: '1.6.0 || 1.6.1 || >=1.6.3 <3' # v1.6.2 is broken: https://github.com/sidorares/node-mysql2/issues/869 - node: '>=6.0.0' - commands: - - node test/instrumentation/modules/mysql2/mysql.test.js - - node test/instrumentation/modules/mysql2/pool-release-1.test.js -redis: - versions: '>=2.0.0 <4.0.0' - commands: node test/instrumentation/modules/redis.test.js -ioredis-old: - name: ioredis - versions: '>=2 <3.1.3 || >3.1.3 <4' # v3.1.3 is broken in older versions of Node because of https://github.com/luin/ioredis/commit/d5867f7c7f03a770a8c0ca5680fdcbfcaf8488e7 - commands: node test/instrumentation/modules/ioredis.test.js -ioredis-new: - name: ioredis - versions: '^4.0.0' - node: '>=6' - commands: node test/instrumentation/modules/ioredis.test.js pg-old-node: name: pg # We want this version range: diff --git a/test/instrumentation/modules/ioredis/.npmrc b/test/instrumentation/modules/ioredis/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/ioredis/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/ioredis/.tav.yml b/test/instrumentation/modules/ioredis/.tav.yml new file mode 100644 index 0000000000..737bc9c342 --- /dev/null +++ b/test/instrumentation/modules/ioredis/.tav.yml @@ -0,0 +1,9 @@ +ioredis-old: + name: ioredis + versions: '>=2 <3.1.3 || >3.1.3 <4' # v3.1.3 is broken in older versions of Node because of https://github.com/luin/ioredis/commit/d5867f7c7f03a770a8c0ca5680fdcbfcaf8488e7 + commands: node ioredis.test.js +ioredis-new: + name: ioredis + versions: '^4.0.0' + node: '>=6' + commands: node ioredis.test.js diff --git a/test/instrumentation/modules/ioredis.test.js b/test/instrumentation/modules/ioredis/ioredis.test.js similarity index 97% rename from test/instrumentation/modules/ioredis.test.js rename to test/instrumentation/modules/ioredis/ioredis.test.js index 28ec646e57..8fc306f0bc 100644 --- a/test/instrumentation/modules/ioredis.test.js +++ b/test/instrumentation/modules/ioredis/ioredis.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -12,7 +12,7 @@ var agent = require('../../..').start({ var Redis = require('ioredis') var test = require('tape') -var mockClient = require('../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('not nested', function (t) { resetAgent(done(t)) diff --git a/test/instrumentation/modules/ioredis/package.json b/test/instrumentation/modules/ioredis/package.json new file mode 100644 index 0000000000..6faf2c0b11 --- /dev/null +++ b/test/instrumentation/modules/ioredis/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-ioredis", + "version": "1.0.0", + "private": true, + "dependencies": { + "ioredis": "^4.16.0" + } +} diff --git a/test/instrumentation/modules/mysql2/.npmrc b/test/instrumentation/modules/mysql2/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/mysql2/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/mysql2/.tav.yml b/test/instrumentation/modules/mysql2/.tav.yml new file mode 100644 index 0000000000..e062adabc6 --- /dev/null +++ b/test/instrumentation/modules/mysql2/.tav.yml @@ -0,0 +1,13 @@ +mysql2-old: + name: mysql2 + versions: '>=1.0.0 <1.6.0' + commands: + - node mysql.test.js + - node pool-release-1.test.js +mysql2-new: + name: mysql2 + versions: '1.6.0 || 1.6.1 || >=1.6.3 <3' # v1.6.2 is broken: https://github.com/sidorares/node-mysql2/issues/869 + node: '>=6.0.0' + commands: + - node mysql.test.js + - node pool-release-1.test.js diff --git a/test/instrumentation/modules/mysql2/package.json b/test/instrumentation/modules/mysql2/package.json new file mode 100644 index 0000000000..ff5cc41fb8 --- /dev/null +++ b/test/instrumentation/modules/mysql2/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-mysql2", + "version": "1.0.0", + "private": true, + "dependencies": { + "mysql2": "^2.1.0" + } +} diff --git a/test/instrumentation/modules/redis/.npmrc b/test/instrumentation/modules/redis/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/redis/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/redis/.tav.yml b/test/instrumentation/modules/redis/.tav.yml new file mode 100644 index 0000000000..8a53313755 --- /dev/null +++ b/test/instrumentation/modules/redis/.tav.yml @@ -0,0 +1,3 @@ +redis: + versions: '>=2.0.0 <4.0.0' + commands: node redis.test.js diff --git a/test/instrumentation/modules/redis/package.json b/test/instrumentation/modules/redis/package.json new file mode 100644 index 0000000000..4d2e7dc160 --- /dev/null +++ b/test/instrumentation/modules/redis/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-redis", + "version": "1.0.0", + "private": true, + "dependencies": { + "redis": "^3.0.2" + } +} diff --git a/test/instrumentation/modules/redis.test.js b/test/instrumentation/modules/redis/redis.test.js similarity index 93% rename from test/instrumentation/modules/redis.test.js rename to test/instrumentation/modules/redis/redis.test.js index 164e6b97cd..5264097159 100644 --- a/test/instrumentation/modules/redis.test.js +++ b/test/instrumentation/modules/redis/redis.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -11,8 +11,8 @@ var agent = require('../../..').start({ var redis = require('redis') var test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test(function (t) { resetAgent(function (data) { diff --git a/test/test.js b/test/test.js index 7562f8c857..70475fb4da 100644 --- a/test/test.js +++ b/test/test.js @@ -85,6 +85,7 @@ var directories = [ 'test/instrumentation/modules/handlebars', 'test/instrumentation/modules/hapi', 'test/instrumentation/modules/http', + 'test/instrumentation/modules/ioredis', 'test/instrumentation/modules/jade', 'test/instrumentation/modules/koa', 'test/instrumentation/modules/koa-router', @@ -93,6 +94,7 @@ var directories = [ 'test/instrumentation/modules/mysql2', 'test/instrumentation/modules/pg', 'test/instrumentation/modules/pug', + 'test/instrumentation/modules/redis', 'test/instrumentation/modules/restify', 'test/instrumentation/modules/aws-sdk', 'test/instrumentation/run-context', From 5c93aea58224243a8d9eb6512bfe96cd60c8ef81 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 21:00:41 -0700 Subject: [PATCH 07/17] fix require after move --- test/instrumentation/modules/mimic-response/github-179.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/instrumentation/modules/mimic-response/github-179.test.js b/test/instrumentation/modules/mimic-response/github-179.test.js index 5db3bff715..4c8c92bb01 100644 --- a/test/instrumentation/modules/mimic-response/github-179.test.js +++ b/test/instrumentation/modules/mimic-response/github-179.test.js @@ -14,7 +14,7 @@ var PassThrough = require('stream').PassThrough var mimicResponse = require('mimic-response') var test = require('tape') -var echoServer = require('./_echo_server_util').echoServer +var echoServer = require('../http/_echo_server_util').echoServer test('https://github.com/opbeat/opbeat-node/issues/179', function (t) { echoServer(function (cp, port) { From 7186eea5a04db8f268a3086a57f7e6041451feec Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 2 Nov 2021 21:09:45 -0700 Subject: [PATCH 08/17] migrate tav: pg --- .tav.yml | 30 -------------------- test/instrumentation/modules/pg/.npmrc | 1 + test/instrumentation/modules/pg/.tav.yml | 30 ++++++++++++++++++++ test/instrumentation/modules/pg/package.json | 8 ++++++ 4 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 test/instrumentation/modules/pg/.npmrc create mode 100644 test/instrumentation/modules/pg/.tav.yml create mode 100644 test/instrumentation/modules/pg/package.json diff --git a/.tav.yml b/.tav.yml index 46b8a370dd..733b102841 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,33 +1,3 @@ -pg-old-node: - name: pg - # We want this version range: - # versions: '>=4 <9' - # but only the latest MAJOR.MINOR.x to reduce the test matrix. - # - # Maintenance note: This should be updated for newer MAJOR.MINOR releases. - 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' - node: '<14' - peerDependencies: - - bluebird@^3.0.0 - - knex@^0.17.3 - commands: - - node test/instrumentation/modules/pg/pg.test.js - - node test/instrumentation/modules/pg/knex.test.js -pg-new-node: - name: pg - # We want this version range: - # versions: '>=8.0.3 <9' # Prior versions didn't work in Node.js 14 - # but only the latest MAJOR.MINOR.x to reduce the test matrix. - # - # Maintenance note: This should be updated for newer MAJOR.MINOR releases. - 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' - node: '>=14' - peerDependencies: - - bluebird@^3.0.0 - - knex@^0.17.3 - commands: - - node test/instrumentation/modules/pg/pg.test.js - - node test/instrumentation/modules/pg/knex.test.js mongodb-core: versions: '>=1.2.19 <4' commands: node test/instrumentation/modules/mongodb-core.test.js diff --git a/test/instrumentation/modules/pg/.npmrc b/test/instrumentation/modules/pg/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/pg/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/pg/.tav.yml b/test/instrumentation/modules/pg/.tav.yml new file mode 100644 index 0000000000..fa3babe5a3 --- /dev/null +++ b/test/instrumentation/modules/pg/.tav.yml @@ -0,0 +1,30 @@ +pg-old-node: + name: pg + # We want this version range: + # versions: '>=4 <9' + # but only the latest MAJOR.MINOR.x to reduce the test matrix. + # + # Maintenance note: This should be updated for newer MAJOR.MINOR releases. + 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' + node: '<14' + peerDependencies: + - bluebird@^3.0.0 + - knex@^0.17.3 + commands: + - node pg.test.js + - node knex.test.js +pg-new-node: + name: pg + # We want this version range: + # versions: '>=8.0.3 <9' # Prior versions didn't work in Node.js 14 + # but only the latest MAJOR.MINOR.x to reduce the test matrix. + # + # Maintenance note: This should be updated for newer MAJOR.MINOR releases. + 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' + node: '>=14' + peerDependencies: + - bluebird@^3.0.0 + - knex@^0.17.3 + commands: + - node pg.test.js + - node knex.test.js diff --git a/test/instrumentation/modules/pg/package.json b/test/instrumentation/modules/pg/package.json new file mode 100644 index 0000000000..844063ef80 --- /dev/null +++ b/test/instrumentation/modules/pg/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-pg", + "version": "1.0.0", + "private": true, + "dependencies": { + "pg": "^8.7.1" + } +} From 344e0de31cd5833ead8c84ad1ffd985aea7a2bc5 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 3 Nov 2021 19:23:13 -0700 Subject: [PATCH 09/17] restore disableInstrumentations tests using all instrumented modules --- test/config.test.js | 95 ++++++++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 27 deletions(-) diff --git a/test/config.test.js b/test/config.test.js index 264fe5611b..2b99d226f2 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -860,41 +860,82 @@ usePathAsTransactionNameTests.forEach(function (usePathAsTransactionNameTest) { }) test('disableInstrumentations', function (t) { - // The set of "all" modules that have instrumentations and that can be - // require'd, given what is in "dependencies" in package.json. - const allModules = new Set(['http', 'https', 'http2']) + var expressGraphqlVersion = require('express-graphql/package.json').version + var esVersion = safeGetPackageVersion('@elastic/elasticsearch') + const esCanaryVersion = safeGetPackageVersion('@elastic/elasticsearch-canary') - function testADisableInstrumentationsValue (configValue) { - var modulesToDisable = new Set(typeof configValue === 'string' - ? configValue.split(',') - : configValue) + // require('apollo-server-core') is a hard crash on nodes < 12.0.0 + const apolloServerCoreVersion = require('apollo-server-core/package.json').version - var agent = new Agent() - agent.start(Object.assign( - {}, - agentOptsNoopTransport, - { disableInstrumentations: configValue } - )) + var flattenedModules = Instrumentation.modules.reduce((acc, val) => acc.concat(val), []) + var modules = new Set(flattenedModules) + if (isHapiIncompat('hapi')) { + modules.delete('hapi') + } + if (isHapiIncompat('@hapi/hapi')) { + modules.delete('@hapi/hapi') + } + if (semver.lt(process.version, '7.6.0') && semver.gte(expressGraphqlVersion, '0.9.0')) { + modules.delete('express-graphql') + } + if (semver.lt(process.version, '10.0.0') && semver.gte(esVersion, '7.12.0')) { + modules.delete('@elastic/elasticsearch') + } + if (semver.lt(process.version, '10.0.0') && semver.gte(esCanaryVersion, '7.12.0')) { + modules.delete('@elastic/elasticsearch-canary') + } + // As of mongodb@4 only supports node >=v12. + const mongodbVersion = require('../node_modules/mongodb/package.json').version + if (semver.gte(mongodbVersion, '4.0.0') && semver.lt(process.version, '12.0.0')) { + modules.delete('mongodb') + } + + if (semver.gte(apolloServerCoreVersion, '3.0.0') && semver.lt(process.version, '12.0.0')) { + modules.delete('apollo-server-core') + } - var found = new Set() - agent._instrumentation._patchModule = function (exports, name, version, enabled) { - if (!enabled) { - found.add(name) + function testSlice (t, name, selector) { + var selection = selector(modules) + var selectionSet = new Set(typeof selection === 'string' ? selection.split(',') : selection) + + t.test(name + ' -> ' + Array.from(selectionSet).join(','), function (t) { + var agent = new Agent() + agent.start(Object.assign( + {}, + agentOptsNoopTransport, + { disableInstrumentations: selection } + )) + + var found = new Set() + + agent._instrumentation._patchModule = function (exports, name, version, enabled) { + if (!enabled) found.add(name) + return exports } - return exports - } - for (const mod of allModules) { - require(mod) - } - t.deepEqual(modulesToDisable, found, 'disabled all selected modules: ' + JSON.stringify(configValue)) + for (const mod of modules) { + require(mod) + } - agent.destroy() + t.deepEqual(selectionSet, found, 'disabled all selected modules') + + agent.destroy() + t.end() + }) + } + + for (const mod of modules) { + testSlice(t, 'individual modules', () => new Set([mod])) } - testADisableInstrumentationsValue('http2') // single value - testADisableInstrumentationsValue(['http2', 'http']) // array of values - testADisableInstrumentationsValue('https,http2') // comma-sep array of values + testSlice(t, 'multiple modules by array', modules => { + return Array.from(modules).filter((value, index) => index % 2) + }) + + testSlice(t, 'multiple modules by csv string', modules => { + return Array.from(modules).filter((value, index) => !(index % 2)) + }) + t.end() }) From d1aacf2f70b7ed36d3b602aba843f19ccbd08ac3 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 3 Nov 2021 19:24:05 -0700 Subject: [PATCH 10/17] migrate tav: mongodb-core --- .tav.yml | 3 --- test/instrumentation/modules/mongodb-core/.npmrc | 1 + test/instrumentation/modules/mongodb-core/.tav.yml | 3 +++ .../modules/{ => mongodb-core}/mongodb-core.test.js | 4 ++-- test/instrumentation/modules/mongodb-core/package.json | 8 ++++++++ 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 test/instrumentation/modules/mongodb-core/.npmrc create mode 100644 test/instrumentation/modules/mongodb-core/.tav.yml rename test/instrumentation/modules/{ => mongodb-core}/mongodb-core.test.js (98%) create mode 100644 test/instrumentation/modules/mongodb-core/package.json diff --git a/.tav.yml b/.tav.yml index 733b102841..bf7d5c733a 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,6 +1,3 @@ -mongodb-core: - versions: '>=1.2.19 <4' - commands: node test/instrumentation/modules/mongodb-core.test.js mongodb: versions: '>=3.3' commands: node test/instrumentation/modules/mongodb.test.js diff --git a/test/instrumentation/modules/mongodb-core/.npmrc b/test/instrumentation/modules/mongodb-core/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/mongodb-core/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/mongodb-core/.tav.yml b/test/instrumentation/modules/mongodb-core/.tav.yml new file mode 100644 index 0000000000..e4b25a7075 --- /dev/null +++ b/test/instrumentation/modules/mongodb-core/.tav.yml @@ -0,0 +1,3 @@ +mongodb-core: + versions: '>=1.2.19 <4' + commands: node mongodb-core.test.js diff --git a/test/instrumentation/modules/mongodb-core.test.js b/test/instrumentation/modules/mongodb-core/mongodb-core.test.js similarity index 98% rename from test/instrumentation/modules/mongodb-core.test.js rename to test/instrumentation/modules/mongodb-core/mongodb-core.test.js index ee0ccc8e88..7ce4106258 100644 --- a/test/instrumentation/modules/mongodb-core.test.js +++ b/test/instrumentation/modules/mongodb-core/mongodb-core.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -13,7 +13,7 @@ var semver = require('semver') var test = require('tape') var mongodbCoreVersion = require('mongodb-core/package').version -var mockClient = require('../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('instrument simple command', function (t) { // Because a variable number of events to the APM server is possible (see diff --git a/test/instrumentation/modules/mongodb-core/package.json b/test/instrumentation/modules/mongodb-core/package.json new file mode 100644 index 0000000000..8562977e0b --- /dev/null +++ b/test/instrumentation/modules/mongodb-core/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-mongodb-core", + "version": "1.0.0", + "private": true, + "dependencies": { + "mongodb-core": "^3.2.7" + } +} From cb36bcb4ea076996bd19fa64ed473ed92a4dd151 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 3 Nov 2021 19:37:10 -0700 Subject: [PATCH 11/17] tav migrate: bluebird, knex, mongodb --- .tav.yml | 23 ------------------- test/instrumentation/modules/bluebird/.npmrc | 1 + .../instrumentation/modules/bluebird/.tav.yml | 5 ++++ .../modules/bluebird/package.json | 8 +++++++ test/instrumentation/modules/knex/.npmrc | 1 + test/instrumentation/modules/knex/.tav.yml | 15 ++++++++++++ .../instrumentation/modules/knex/package.json | 8 +++++++ test/instrumentation/modules/mongodb/.npmrc | 1 + test/instrumentation/modules/mongodb/.tav.yml | 3 +++ .../modules/{ => mongodb}/mongodb.test.js | 6 ++--- .../modules/mongodb/package.json | 8 +++++++ 11 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 test/instrumentation/modules/bluebird/.npmrc create mode 100644 test/instrumentation/modules/bluebird/.tav.yml create mode 100644 test/instrumentation/modules/bluebird/package.json create mode 100644 test/instrumentation/modules/knex/.npmrc create mode 100644 test/instrumentation/modules/knex/.tav.yml create mode 100644 test/instrumentation/modules/knex/package.json create mode 100644 test/instrumentation/modules/mongodb/.npmrc create mode 100644 test/instrumentation/modules/mongodb/.tav.yml rename test/instrumentation/modules/{ => mongodb}/mongodb.test.js (96%) create mode 100644 test/instrumentation/modules/mongodb/package.json diff --git a/.tav.yml b/.tav.yml index bf7d5c733a..ca2033a296 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,26 +1,3 @@ -mongodb: - versions: '>=3.3' - commands: node test/instrumentation/modules/mongodb.test.js -bluebird: - versions: '>=2 <4' - commands: - - node test/instrumentation/modules/bluebird/bluebird.test.js - - node test/instrumentation/modules/bluebird/cancel.test.js -knex-old: - name: knex - # v0.16.4 accidentally dropped support for Node.js 6 - 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 - commands: node test/instrumentation/modules/pg/knex.test.js -knex-new: - name: knex - node: '>=8.6.0' - versions: '>=0.17 <0.21' - commands: node test/instrumentation/modules/pg/knex.test.js -knex-gt-nodev8: - name: knex - node: '>=10.22.0' - versions: '>=0.21 <0.22' - commands: node test/instrumentation/modules/pg/knex.test.js ws-old: name: ws versions: '>=1 <7' diff --git a/test/instrumentation/modules/bluebird/.npmrc b/test/instrumentation/modules/bluebird/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/bluebird/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/bluebird/.tav.yml b/test/instrumentation/modules/bluebird/.tav.yml new file mode 100644 index 0000000000..09248b4e12 --- /dev/null +++ b/test/instrumentation/modules/bluebird/.tav.yml @@ -0,0 +1,5 @@ +bluebird: + versions: '>=2 <4' + commands: + - node bluebird.test.js + - node cancel.test.js diff --git a/test/instrumentation/modules/bluebird/package.json b/test/instrumentation/modules/bluebird/package.json new file mode 100644 index 0000000000..8e4d4357d0 --- /dev/null +++ b/test/instrumentation/modules/bluebird/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-bluebird", + "version": "1.0.0", + "private": true, + "dependencies": { + "bluebird": "^3.7.2" + } +} diff --git a/test/instrumentation/modules/knex/.npmrc b/test/instrumentation/modules/knex/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/knex/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/knex/.tav.yml b/test/instrumentation/modules/knex/.tav.yml new file mode 100644 index 0000000000..57d80804ff --- /dev/null +++ b/test/instrumentation/modules/knex/.tav.yml @@ -0,0 +1,15 @@ +knex-old: + name: knex + # v0.16.4 accidentally dropped support for Node.js 6 + 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 + commands: node ../pg/knex.test.js +knex-new: + name: knex + node: '>=8.6.0' + versions: '>=0.17 <0.21' + commands: node ../pg/knex.test.js +knex-gt-nodev8: + name: knex + node: '>=10.22.0' + versions: '>=0.21 <0.22' + commands: node ../pg/knex.test.js diff --git a/test/instrumentation/modules/knex/package.json b/test/instrumentation/modules/knex/package.json new file mode 100644 index 0000000000..b7f85b8c4e --- /dev/null +++ b/test/instrumentation/modules/knex/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-knex", + "version": "1.0.0", + "private": true, + "dependencies": { + "knex": "^0.21.2" + } +} diff --git a/test/instrumentation/modules/mongodb/.npmrc b/test/instrumentation/modules/mongodb/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/mongodb/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/mongodb/.tav.yml b/test/instrumentation/modules/mongodb/.tav.yml new file mode 100644 index 0000000000..1d5d7e1d02 --- /dev/null +++ b/test/instrumentation/modules/mongodb/.tav.yml @@ -0,0 +1,3 @@ +mongodb: + versions: '>=3.3' + commands: node mongodb.test.js diff --git a/test/instrumentation/modules/mongodb.test.js b/test/instrumentation/modules/mongodb/mongodb.test.js similarity index 96% rename from test/instrumentation/modules/mongodb.test.js rename to test/instrumentation/modules/mongodb/mongodb.test.js index d62a7a4612..b7758ee9d3 100644 --- a/test/instrumentation/modules/mongodb.test.js +++ b/test/instrumentation/modules/mongodb/mongodb.test.js @@ -1,6 +1,6 @@ 'use strict' -const agent = require('../../..').start({ +const agent = require('../../../..').start({ serviceName: 'test-mongodb', captureExceptions: false, metricsInterval: 0, @@ -9,7 +9,7 @@ const agent = require('../../..').start({ }) // As of mongodb@4 only supports node >=v12. -const mongodbVersion = require('../../../node_modules/mongodb/package.json').version +const mongodbVersion = require('../../../../node_modules/mongodb/package.json').version const semver = require('semver') if (semver.gte(mongodbVersion, '4.0.0') && semver.lt(process.version, '12.0.0')) { console.log(`# SKIP mongodb@${mongodbVersion} does not support node ${process.version}`) @@ -18,7 +18,7 @@ if (semver.gte(mongodbVersion, '4.0.0') && semver.lt(process.version, '12.0.0')) const MongoClient = require('mongodb').MongoClient const test = require('tape') -const mockClient = require('../../_mock_http_client_states') +const mockClient = require('../../../_mock_http_client_states') const host = process.env.MONGODB_HOST || 'localhost' const url = `mongodb://${host}:27017` diff --git a/test/instrumentation/modules/mongodb/package.json b/test/instrumentation/modules/mongodb/package.json new file mode 100644 index 0000000000..151ef75b49 --- /dev/null +++ b/test/instrumentation/modules/mongodb/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-mongodb", + "version": "1.0.0", + "private": true, + "dependencies": { + "mongodb": "^4.1.0" + } +} From aeba1b9507a3e2f82d18d4bfa203ab3d3426edab Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 4 Nov 2021 22:17:28 -0700 Subject: [PATCH 12/17] tav migrate: express, express-graphql, ws, graphql --- .tav.yml | 105 ------------------ .../modules/express-graphql/.npmrc | 1 + .../modules/express-graphql/.tav.yml | 86 ++++++++++++++ .../express-graphql.test.js | 4 +- .../modules/express-graphql/package.json | 8 ++ test/instrumentation/modules/express/.npmrc | 1 + test/instrumentation/modules/express/.tav.yml | 7 ++ .../modules/express/package.json | 8 ++ test/instrumentation/modules/graphql/.npmrc | 1 + test/instrumentation/modules/graphql/.tav.yml | 5 + .../modules/{ => graphql}/graphql.test.js | 4 +- .../modules/graphql/package.json | 8 ++ test/instrumentation/modules/ws/.npmrc | 1 + test/instrumentation/modules/ws/.tav.yml | 9 ++ test/instrumentation/modules/ws/package.json | 8 ++ .../modules/{ => ws}/ws.test.js | 4 +- test/test.js | 4 +- 17 files changed, 152 insertions(+), 112 deletions(-) create mode 100644 test/instrumentation/modules/express-graphql/.npmrc create mode 100644 test/instrumentation/modules/express-graphql/.tav.yml rename test/instrumentation/modules/{ => express-graphql}/express-graphql.test.js (98%) create mode 100644 test/instrumentation/modules/express-graphql/package.json create mode 100644 test/instrumentation/modules/express/.npmrc create mode 100644 test/instrumentation/modules/express/.tav.yml create mode 100644 test/instrumentation/modules/express/package.json create mode 100644 test/instrumentation/modules/graphql/.npmrc create mode 100644 test/instrumentation/modules/graphql/.tav.yml rename test/instrumentation/modules/{ => graphql}/graphql.test.js (98%) create mode 100644 test/instrumentation/modules/graphql/package.json create mode 100644 test/instrumentation/modules/ws/.npmrc create mode 100644 test/instrumentation/modules/ws/.tav.yml create mode 100644 test/instrumentation/modules/ws/package.json rename test/instrumentation/modules/{ => ws}/ws.test.js (93%) diff --git a/.tav.yml b/.tav.yml index ca2033a296..eb316ef687 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,109 +1,4 @@ -ws-old: - name: ws - versions: '>=1 <7' - commands: node test/instrumentation/modules/ws.test.js -ws-new: - name: ws - node: '>=8.6.0' - versions: '>=7 <8' - commands: node test/instrumentation/modules/ws.test.js -graphql: - preinstall: npm uninstall express-graphql - versions: '>=0.7.0 <0.11.0 || >=0.11.1 <16.0.0' - commands: node test/instrumentation/modules/graphql.test.js -express: - versions: '>=4' - commands: - - node test/instrumentation/modules/express/basic.test.js - - node test/instrumentation/modules/express/capture-exceptions-off.test.js - - node test/instrumentation/modules/express/capture-exceptions-on.test.js - - node test/instrumentation/modules/express/set-framework.test.js - -express-graphql-1: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.8.2 - versions: '0.6.1' - commands: node test/instrumentation/modules/express-graphql.test.js - -express-graphql-2: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.9.0 - versions: '>=0.6.2 <0.6.6' - commands: node test/instrumentation/modules/express-graphql.test.js - -express-graphql-3: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.10.0 - versions: '>=0.6.6 <0.6.8' - commands: node test/instrumentation/modules/express-graphql.test.js - -express-graphql-0.6.11_10: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.10.0 - versions: '0.6.11' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.6.11_11: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.11.0 - versions: '0.6.11' - commands: node test/instrumentation/modules/express-graphql.test.js - -express-graphql-0.6.12_10: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.10.0 - versions: '^0.6.12' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.6.12_11: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.11.0 - versions: '^0.6.12' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.6.12_12: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.12.0 - versions: '^0.6.12' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.6.12_13: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.13.0 - versions: '^0.6.12' - commands: node test/instrumentation/modules/express-graphql.test.js - -express-graphql-0.7.1_12: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.12.0 - versions: '>=0.7.1 <0.9.0' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.7.1_13: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^0.13.0 - versions: '>=0.7.1 <0.9.0' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.7.1_14: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^14.0.0 - versions: '>=0.7.1 <0.9.0' - commands: node test/instrumentation/modules/express-graphql.test.js -express-graphql-0.9.0: - name: express-graphql - preinstall: npm uninstall apollo-server-express - peerDependencies: graphql@^14.4.1 - versions: '>=0.9.0 <0.10.0' - node: '>=7.6.0' - commands: node test/instrumentation/modules/express-graphql.test.js apollo-server-express-2_12: name: apollo-server-express diff --git a/test/instrumentation/modules/express-graphql/.npmrc b/test/instrumentation/modules/express-graphql/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/express-graphql/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/express-graphql/.tav.yml b/test/instrumentation/modules/express-graphql/.tav.yml new file mode 100644 index 0000000000..81e4894010 --- /dev/null +++ b/test/instrumentation/modules/express-graphql/.tav.yml @@ -0,0 +1,86 @@ +express-graphql-1: + name: express-graphql + #XXX + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.8.2 + versions: '0.6.1' + commands: node express-graphql.test.js + +express-graphql-2: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.9.0 + versions: '>=0.6.2 <0.6.6' + commands: node express-graphql.test.js + +express-graphql-3: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.10.0 + versions: '>=0.6.6 <0.6.8' + commands: node express-graphql.test.js + +express-graphql-0.6.11_10: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.10.0 + versions: '0.6.11' + commands: node express-graphql.test.js +express-graphql-0.6.11_11: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.11.0 + versions: '0.6.11' + commands: node express-graphql.test.js + +express-graphql-0.6.12_10: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.10.0 + versions: '^0.6.12' + commands: node express-graphql.test.js +express-graphql-0.6.12_11: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.11.0 + versions: '^0.6.12' + commands: node express-graphql.test.js +express-graphql-0.6.12_12: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.12.0 + versions: '^0.6.12' + commands: node express-graphql.test.js +express-graphql-0.6.12_13: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.13.0 + versions: '^0.6.12' + commands: node express-graphql.test.js + +express-graphql-0.7.1_12: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.12.0 + versions: '>=0.7.1 <0.9.0' + commands: node express-graphql.test.js +express-graphql-0.7.1_13: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^0.13.0 + versions: '>=0.7.1 <0.9.0' + commands: node express-graphql.test.js +express-graphql-0.7.1_14: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^14.0.0 + versions: '>=0.7.1 <0.9.0' + commands: node express-graphql.test.js + +express-graphql-0.9.0: + name: express-graphql + #preinstall: npm uninstall apollo-server-express + peerDependencies: graphql@^14.4.1 + versions: '>=0.9.0 <0.10.0' + node: '>=7.6.0' + commands: node express-graphql.test.js diff --git a/test/instrumentation/modules/express-graphql.test.js b/test/instrumentation/modules/express-graphql/express-graphql.test.js similarity index 98% rename from test/instrumentation/modules/express-graphql.test.js rename to test/instrumentation/modules/express-graphql/express-graphql.test.js index 4ddc64eae3..35faf612c9 100644 --- a/test/instrumentation/modules/express-graphql.test.js +++ b/test/instrumentation/modules/express-graphql/express-graphql.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -17,7 +17,7 @@ var querystring = require('querystring') var graphqlHTTP = require('express-graphql') var test = require('tape') -var mockClient = require('../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') const paths = ['/graphql', '/'] diff --git a/test/instrumentation/modules/express-graphql/package.json b/test/instrumentation/modules/express-graphql/package.json new file mode 100644 index 0000000000..0bbabdfc96 --- /dev/null +++ b/test/instrumentation/modules/express-graphql/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-express-graphql", + "version": "1.0.0", + "private": true, + "dependencies": { + "express-graphql": "^0.9.0" + } +} diff --git a/test/instrumentation/modules/express/.npmrc b/test/instrumentation/modules/express/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/express/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/express/.tav.yml b/test/instrumentation/modules/express/.tav.yml new file mode 100644 index 0000000000..fb837029b1 --- /dev/null +++ b/test/instrumentation/modules/express/.tav.yml @@ -0,0 +1,7 @@ +express: + versions: '>=4' + commands: + - node basic.test.js + - node capture-exceptions-off.test.js + - node capture-exceptions-on.test.js + - node set-framework.test.js diff --git a/test/instrumentation/modules/express/package.json b/test/instrumentation/modules/express/package.json new file mode 100644 index 0000000000..2957fa47d8 --- /dev/null +++ b/test/instrumentation/modules/express/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-express", + "version": "1.0.0", + "private": true, + "dependencies": { + "express": "^4.17.1" + } +} diff --git a/test/instrumentation/modules/graphql/.npmrc b/test/instrumentation/modules/graphql/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/graphql/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/graphql/.tav.yml b/test/instrumentation/modules/graphql/.tav.yml new file mode 100644 index 0000000000..5baed5474c --- /dev/null +++ b/test/instrumentation/modules/graphql/.tav.yml @@ -0,0 +1,5 @@ +graphql: + # XXX need this? + #preinstall: npm uninstall express-graphql + versions: '>=0.7.0 <0.11.0 || >=0.11.1 <16.0.0' + commands: node graphql.test.js diff --git a/test/instrumentation/modules/graphql.test.js b/test/instrumentation/modules/graphql/graphql.test.js similarity index 98% rename from test/instrumentation/modules/graphql.test.js rename to test/instrumentation/modules/graphql/graphql.test.js index 4a964df2b1..4b0fdd3e8c 100644 --- a/test/instrumentation/modules/graphql.test.js +++ b/test/instrumentation/modules/graphql/graphql.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -13,7 +13,7 @@ var pkg = require('graphql/package.json') var semver = require('semver') var test = require('tape') -var mockClient = require('../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('graphql.graphql', function (t) { resetAgent(done(t)) diff --git a/test/instrumentation/modules/graphql/package.json b/test/instrumentation/modules/graphql/package.json new file mode 100644 index 0000000000..1b0845604a --- /dev/null +++ b/test/instrumentation/modules/graphql/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-graphql", + "version": "1.0.0", + "private": true, + "dependencies": { + "graphql": "^15.3.0" + } +} diff --git a/test/instrumentation/modules/ws/.npmrc b/test/instrumentation/modules/ws/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/ws/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/ws/.tav.yml b/test/instrumentation/modules/ws/.tav.yml new file mode 100644 index 0000000000..4a5de9d105 --- /dev/null +++ b/test/instrumentation/modules/ws/.tav.yml @@ -0,0 +1,9 @@ +ws-old: + name: ws + versions: '>=1 <7' + commands: node ws.test.js +ws-new: + name: ws + node: '>=8.6.0' + versions: '>=7 <8' + commands: node ws.test.js diff --git a/test/instrumentation/modules/ws/package.json b/test/instrumentation/modules/ws/package.json new file mode 100644 index 0000000000..890cc8a1e6 --- /dev/null +++ b/test/instrumentation/modules/ws/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-ws", + "version": "1.0.0", + "private": true, + "dependencies": { + "ws": "^7.2.1" + } +} diff --git a/test/instrumentation/modules/ws.test.js b/test/instrumentation/modules/ws/ws.test.js similarity index 93% rename from test/instrumentation/modules/ws.test.js rename to test/instrumentation/modules/ws/ws.test.js index ad13f36ee9..c03115014b 100644 --- a/test/instrumentation/modules/ws.test.js +++ b/test/instrumentation/modules/ws/ws.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -11,7 +11,7 @@ var agent = require('../../..').start({ var test = require('tape') var WebSocket = require('ws') -var mockClient = require('../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') var PORT = 12342 diff --git a/test/test.js b/test/test.js index 70475fb4da..89ba4bc0af 100644 --- a/test/test.js +++ b/test/test.js @@ -76,12 +76,14 @@ var directories = [ 'test/instrumentation', 'test/instrumentation/modules', 'test/instrumentation/modules/@elastic', + 'test/instrumentation/modules/aws-sdk', 'test/instrumentation/modules/bluebird', 'test/instrumentation/modules/cassandra-driver', 'test/instrumentation/modules/express', 'test/instrumentation/modules/fastify', 'test/instrumentation/modules/generic-pool', 'test/instrumentation/modules/got', + 'test/instrumentation/modules/graphql', 'test/instrumentation/modules/handlebars', 'test/instrumentation/modules/hapi', 'test/instrumentation/modules/http', @@ -96,7 +98,7 @@ var directories = [ 'test/instrumentation/modules/pug', 'test/instrumentation/modules/redis', 'test/instrumentation/modules/restify', - 'test/instrumentation/modules/aws-sdk', + 'test/instrumentation/modules/ws', 'test/instrumentation/run-context', 'test/integration', 'test/integration/api-schema', From bb1dfc34fc062a8b2a333ae1e261c74513cb6d3f Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 4 Nov 2021 22:18:26 -0700 Subject: [PATCH 13/17] missed this dir --- test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test.js b/test/test.js index 89ba4bc0af..9be45f6e2f 100644 --- a/test/test.js +++ b/test/test.js @@ -80,6 +80,7 @@ var directories = [ 'test/instrumentation/modules/bluebird', 'test/instrumentation/modules/cassandra-driver', 'test/instrumentation/modules/express', + 'test/instrumentation/modules/express-graphql', 'test/instrumentation/modules/fastify', 'test/instrumentation/modules/generic-pool', 'test/instrumentation/modules/got', From 5097b48024d3d48ab246a268d3c383ef4381845a Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 4 Nov 2021 22:46:49 -0700 Subject: [PATCH 14/17] tav migrate: elasticsearch, express-queue, koa-router, apollo-server-express --- .tav.yml | 75 ------------------- .../modules/apollo-server-express/.npmrc | 1 + .../modules/apollo-server-express/.tav.yml | 60 +++++++++++++++ .../apollo-server-express.test.js | 2 +- .../apollo-server-express/package.json | 8 ++ .../modules/elasticsearch/.npmrc | 1 + .../modules/elasticsearch/.tav.yml | 3 + .../{ => elasticsearch}/elasticsearch.test.js | 8 +- .../modules/elasticsearch/package.json | 8 ++ .../modules/express-queue/.npmrc | 1 + .../modules/express-queue/.tav.yml | 3 + .../{ => express-queue}/express-queue.test.js | 6 +- .../modules/express-queue/package.json | 8 ++ .../instrumentation/modules/koa-router/.npmrc | 1 + .../modules/koa-router/.tav.yml | 10 +++ .../modules/koa-router/package.json | 9 +++ 16 files changed, 121 insertions(+), 83 deletions(-) create mode 100644 test/instrumentation/modules/apollo-server-express/.npmrc create mode 100644 test/instrumentation/modules/apollo-server-express/.tav.yml rename test/instrumentation/modules/{ => apollo-server-express}/apollo-server-express.test.js (99%) create mode 100644 test/instrumentation/modules/apollo-server-express/package.json create mode 100644 test/instrumentation/modules/elasticsearch/.npmrc create mode 100644 test/instrumentation/modules/elasticsearch/.tav.yml rename test/instrumentation/modules/{ => elasticsearch}/elasticsearch.test.js (96%) create mode 100644 test/instrumentation/modules/elasticsearch/package.json create mode 100644 test/instrumentation/modules/express-queue/.npmrc create mode 100644 test/instrumentation/modules/express-queue/.tav.yml rename test/instrumentation/modules/{ => express-queue}/express-queue.test.js (93%) create mode 100644 test/instrumentation/modules/express-queue/package.json create mode 100644 test/instrumentation/modules/koa-router/.npmrc create mode 100644 test/instrumentation/modules/koa-router/.tav.yml create mode 100644 test/instrumentation/modules/koa-router/package.json diff --git a/.tav.yml b/.tav.yml index eb316ef687..69e38350f9 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,83 +1,8 @@ -apollo-server-express-2_12: - name: apollo-server-express - preinstall: npm uninstall express-graphql - peerDependencies: graphql@^0.12.0 - # We want this version range: - # versions: '>=2.9.16 <2.2 || >= 2.3.2 <3' - # but only the latest MAJOR.MINOR.x to reduce the test matrix. - # - # Maintenance note: This should be updated for newer MAJOR.MINOR releases. - versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' - node: '>=6' - commands: node test/instrumentation/modules/apollo-server-express.test.js -apollo-server-express-2_13: - name: apollo-server-express - preinstall: npm uninstall express-graphql - peerDependencies: graphql@^0.13.0 - # We want this version range: - # versions: '>=2.9.16 <2.2 || >= 2.3.2 <3' - # but only the latest MAJOR.MINOR.x to reduce the test matrix. - # - # Maintenance note: This should be updated for newer MAJOR.MINOR releases. - versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' - node: '>=6' - commands: node test/instrumentation/modules/apollo-server-express.test.js -apollo-server-express-2_14: - name: apollo-server-express - preinstall: npm uninstall express-graphql - peerDependencies: graphql@^14.0.0 - # We want this version range: - # versions: '>=2.9.16 <2.2 || >= 2.3.2 <3' - # but only the latest MAJOR.MINOR.x to reduce the test matrix. - # - # Maintenance note: This should be updated for newer MAJOR.MINOR releases. - versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' - node: '>=6' - commands: node test/instrumentation/modules/apollo-server-express.test.js -apollo-server-express-2_15: - name: apollo-server-express - preinstall: npm uninstall express-graphql - peerDependencies: graphql@^15.0.0 - # We want this version range (2.12.0 was the first release of - # apollo-server-express after graphql@15 was released): - # versions: '>= 2.12.0 <3' - # but only the latest MAJOR.MINOR.x to reduce the test matrix. - # - # Maintenance note: This should be updated for newer MAJOR.MINOR releases. - versions: '2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' - # Per https://github.com/graphql/graphql-js/releases/tag/v15.0.0 - # graphql v15 supports node v8 as a minimum. - node: '>=8' - commands: node test/instrumentation/modules/apollo-server-express.test.js -apollo-server-express-3_15: - name: apollo-server-express - preinstall: npm uninstall express-graphql - peerDependencies: graphql@^15.0.0 - versions: '^3.0.0' - node: '>=12' - commands: node test/instrumentation/modules/apollo-server-express.test.js -express-queue: - versions: '>=0.0.11' - commands: node test/instrumentation/modules/express-queue.test.js -koa-router: - node: '>=6.0.0' - peerDependencies: koa@2 - versions: '>=5.2.0 <11' - commands: node test/instrumentation/modules/koa-router/old-name.test.js -'@koa/router': - node: '>=8.0.0' - peerDependencies: koa@2 - versions: '>=8 <11' - commands: node test/instrumentation/modules/koa-router/new-name.test.js - -elasticsearch: - versions: '>=8.0.0' - commands: node test/instrumentation/modules/elasticsearch.test.js # @elastic/elasticsearch # - Version 7.7.0 included a change that broke usage with Node.js < 10. diff --git a/test/instrumentation/modules/apollo-server-express/.npmrc b/test/instrumentation/modules/apollo-server-express/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/apollo-server-express/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/apollo-server-express/.tav.yml b/test/instrumentation/modules/apollo-server-express/.tav.yml new file mode 100644 index 0000000000..806155f06b --- /dev/null +++ b/test/instrumentation/modules/apollo-server-express/.tav.yml @@ -0,0 +1,60 @@ +apollo-server-express-2_12: + name: apollo-server-express + #XXX + #preinstall: npm uninstall express-graphql + peerDependencies: graphql@^0.12.0 + # We want this version range: + # versions: '>=2.9.16 <2.2 || >= 2.3.2 <3' + # but only the latest MAJOR.MINOR.x to reduce the test matrix. + # + # Maintenance note: This should be updated for newer MAJOR.MINOR releases. + versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' + node: '>=6' + commands: node apollo-server-express.test.js +apollo-server-express-2_13: + name: apollo-server-express + #preinstall: npm uninstall express-graphql + peerDependencies: graphql@^0.13.0 + # We want this version range: + # versions: '>=2.9.16 <2.2 || >= 2.3.2 <3' + # but only the latest MAJOR.MINOR.x to reduce the test matrix. + # + # Maintenance note: This should be updated for newer MAJOR.MINOR releases. + versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' + node: '>=6' + commands: node apollo-server-express.test.js +apollo-server-express-2_14: + name: apollo-server-express + #preinstall: npm uninstall express-graphql + peerDependencies: graphql@^14.0.0 + # We want this version range: + # versions: '>=2.9.16 <2.2 || >= 2.3.2 <3' + # but only the latest MAJOR.MINOR.x to reduce the test matrix. + # + # Maintenance note: This should be updated for newer MAJOR.MINOR releases. + versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' + node: '>=6' + commands: node apollo-server-express.test.js +apollo-server-express-2_15: + name: apollo-server-express + #preinstall: npm uninstall express-graphql + peerDependencies: graphql@^15.0.0 + # We want this version range (2.12.0 was the first release of + # apollo-server-express after graphql@15 was released): + # versions: '>= 2.12.0 <3' + # but only the latest MAJOR.MINOR.x to reduce the test matrix. + # + # Maintenance note: This should be updated for newer MAJOR.MINOR releases. + versions: '2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3' + # Per https://github.com/graphql/graphql-js/releases/tag/v15.0.0 + # graphql v15 supports node v8 as a minimum. + node: '>=8' + commands: node apollo-server-express.test.js + +apollo-server-express-3_15: + name: apollo-server-express + #preinstall: npm uninstall express-graphql + peerDependencies: graphql@^15.0.0 + versions: '^3.0.0' + node: '>=12' + commands: node apollo-server-express.test.js diff --git a/test/instrumentation/modules/apollo-server-express.test.js b/test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js similarity index 99% rename from test/instrumentation/modules/apollo-server-express.test.js rename to test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js index f810439914..10e18d2f2a 100644 --- a/test/instrumentation/modules/apollo-server-express.test.js +++ b/test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, diff --git a/test/instrumentation/modules/apollo-server-express/package.json b/test/instrumentation/modules/apollo-server-express/package.json new file mode 100644 index 0000000000..338330c966 --- /dev/null +++ b/test/instrumentation/modules/apollo-server-express/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-apollo-server-express", + "version": "1.0.0", + "private": true, + "dependencies": { + "apollo-server-express": "^3.0.0" + } +} diff --git a/test/instrumentation/modules/elasticsearch/.npmrc b/test/instrumentation/modules/elasticsearch/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/elasticsearch/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/elasticsearch/.tav.yml b/test/instrumentation/modules/elasticsearch/.tav.yml new file mode 100644 index 0000000000..8aafd6cf6e --- /dev/null +++ b/test/instrumentation/modules/elasticsearch/.tav.yml @@ -0,0 +1,3 @@ +elasticsearch: + versions: '>=8.0.0' + commands: node elasticsearch.test.js diff --git a/test/instrumentation/modules/elasticsearch.test.js b/test/instrumentation/modules/elasticsearch/elasticsearch.test.js similarity index 96% rename from test/instrumentation/modules/elasticsearch.test.js rename to test/instrumentation/modules/elasticsearch/elasticsearch.test.js index 282f3ee25c..4326107c74 100644 --- a/test/instrumentation/modules/elasticsearch.test.js +++ b/test/instrumentation/modules/elasticsearch/elasticsearch.test.js @@ -1,11 +1,11 @@ 'use strict' -const { pathIsAQuery } = require('../../../lib/instrumentation/elasticsearch-shared') +const { pathIsAQuery } = require('../../../../lib/instrumentation/elasticsearch-shared') process.env.ELASTIC_APM_TEST = true var host = (process.env.ES_HOST || 'localhost') + ':9200' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -19,8 +19,8 @@ var pkg = require('elasticsearch/package.json') var semver = require('semver') var test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test('client.ping with callback', function userLandCode (t) { resetAgent(done(t, 'HEAD', '/')) diff --git a/test/instrumentation/modules/elasticsearch/package.json b/test/instrumentation/modules/elasticsearch/package.json new file mode 100644 index 0000000000..1bbd75ee64 --- /dev/null +++ b/test/instrumentation/modules/elasticsearch/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-elasticsearch", + "version": "1.0.0", + "private": true, + "dependencies": { + "elasticsearch": "^16.5.0" + } +} diff --git a/test/instrumentation/modules/express-queue/.npmrc b/test/instrumentation/modules/express-queue/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/express-queue/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/express-queue/.tav.yml b/test/instrumentation/modules/express-queue/.tav.yml new file mode 100644 index 0000000000..d471443a8f --- /dev/null +++ b/test/instrumentation/modules/express-queue/.tav.yml @@ -0,0 +1,3 @@ +express-queue: + versions: '>=0.0.11' + commands: node express-queue.test.js diff --git a/test/instrumentation/modules/express-queue.test.js b/test/instrumentation/modules/express-queue/express-queue.test.js similarity index 93% rename from test/instrumentation/modules/express-queue.test.js rename to test/instrumentation/modules/express-queue/express-queue.test.js index 980bab8751..1b899f9914 100644 --- a/test/instrumentation/modules/express-queue.test.js +++ b/test/instrumentation/modules/express-queue/express-queue.test.js @@ -1,6 +1,6 @@ 'use strict' -var agent = require('../../..').start({ +var agent = require('../../../..').start({ serviceName: 'test', secretToken: 'test', captureExceptions: false, @@ -14,8 +14,8 @@ var express = require('express') var queue = require('express-queue') var test = require('tape') -var mockClient = require('../../_mock_http_client') -var findObjInArray = require('../../_utils').findObjInArray +var mockClient = require('../../../_mock_http_client') +var findObjInArray = require('../../../_utils').findObjInArray test('express-queue', function (t) { resetAgent(done(t, 'done')) diff --git a/test/instrumentation/modules/express-queue/package.json b/test/instrumentation/modules/express-queue/package.json new file mode 100644 index 0000000000..34eb92b13b --- /dev/null +++ b/test/instrumentation/modules/express-queue/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-express-queue", + "version": "1.0.0", + "private": true, + "dependencies": { + "express-queue": "^0.0.12" + } +} diff --git a/test/instrumentation/modules/koa-router/.npmrc b/test/instrumentation/modules/koa-router/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/koa-router/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/koa-router/.tav.yml b/test/instrumentation/modules/koa-router/.tav.yml new file mode 100644 index 0000000000..0761bd5250 --- /dev/null +++ b/test/instrumentation/modules/koa-router/.tav.yml @@ -0,0 +1,10 @@ +koa-router: + node: '>=6.0.0' + peerDependencies: koa@2 + versions: '>=5.2.0 <11' + commands: node old-name.test.js +'@koa/router': + node: '>=8.0.0' + peerDependencies: koa@2 + versions: '>=8 <11' + commands: node new-name.test.js diff --git a/test/instrumentation/modules/koa-router/package.json b/test/instrumentation/modules/koa-router/package.json new file mode 100644 index 0000000000..e99a536315 --- /dev/null +++ b/test/instrumentation/modules/koa-router/package.json @@ -0,0 +1,9 @@ +{ + "name": "test-koa-router", + "version": "1.0.0", + "private": true, + "dependencies": { + "@koa/router": "^9.0.1", + "koa-router": "^9.0.1" + } +} From 6f3d92ffd30cd5a3be662d8e39a21ad813276814 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 4 Nov 2021 22:47:50 -0700 Subject: [PATCH 15/17] forgot these dirnames --- test/test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test.js b/test/test.js index 9be45f6e2f..5aede50efe 100644 --- a/test/test.js +++ b/test/test.js @@ -76,11 +76,14 @@ var directories = [ 'test/instrumentation', 'test/instrumentation/modules', 'test/instrumentation/modules/@elastic', + 'test/instrumentation/modules/apollo-server-express', 'test/instrumentation/modules/aws-sdk', 'test/instrumentation/modules/bluebird', 'test/instrumentation/modules/cassandra-driver', + 'test/instrumentation/modules/elasticsearch', 'test/instrumentation/modules/express', 'test/instrumentation/modules/express-graphql', + 'test/instrumentation/modules/express-queue', 'test/instrumentation/modules/fastify', 'test/instrumentation/modules/generic-pool', 'test/instrumentation/modules/got', From 1a3478e161c2b63ce9119970fa075104823fc32d Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 8 Nov 2021 21:35:40 -0800 Subject: [PATCH 16/17] tav migrate: hapi, fastify --- .tav.yml | 101 ------------------ test/instrumentation/modules/hapi/.npmrc | 1 + test/instrumentation/modules/hapi/.tav.yml | 57 ++++++++++ .../instrumentation/modules/hapi/package.json | 9 ++ test/instrumentation/modules/restify/.npmrc | 1 + test/instrumentation/modules/restify/.tav.yml | 13 +++ .../modules/restify/package.json | 8 ++ 7 files changed, 89 insertions(+), 101 deletions(-) create mode 100644 test/instrumentation/modules/hapi/.npmrc create mode 100644 test/instrumentation/modules/hapi/.tav.yml create mode 100644 test/instrumentation/modules/hapi/package.json create mode 100644 test/instrumentation/modules/restify/.npmrc create mode 100644 test/instrumentation/modules/restify/.tav.yml create mode 100644 test/instrumentation/modules/restify/package.json diff --git a/.tav.yml b/.tav.yml index 69e38350f9..bcbd49abb8 100644 --- a/.tav.yml +++ b/.tav.yml @@ -1,9 +1,4 @@ - - - - - # @elastic/elasticsearch # - Version 7.7.0 included a change that broke usage with Node.js < 10. # Fixed in 7.7.1: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog-client.html#_7_7_1 @@ -26,63 +21,6 @@ node: '>=12' commands: node test/instrumentation/modules/@elastic/elasticsearch-canary.test.js -# hapi and @hapi/hapi -# - Package name: Starting with v17.9.0 and v18.2.0 the name changed from -# 'hapi' to '@hapi/hapi'. -# - Node version compat: -# - hapi@15: supports node >=v4; breaks on node v14 (usage of `os.tmpDir()`) -# - hapi@16: supports node >=v4 -# - hapi@17, @hapi/hapi@17: supports node >=v8.12.0 (per its README); -# the instrumentation changed significantly for this version -# - hapi@18, @hapi/hapi@18: supports node >=v8.12.0 (per its README) -# - @hapi/hapi@19: supports node >=v12 (judging from commit 50d8d7d) -# - @hapi/hapi@20: appears (from travis template refs) to support node >=v12 -hapi-v9-v15: - name: hapi - versions: '>=9.0.1 <16.0.0' - node: '>=4 <14' - commands: - - node test/instrumentation/modules/hapi/basic-legacy-path.test.js - - node test/instrumentation/modules/hapi/set-framework-hapi.test.js -hapi-v16: - name: hapi - versions: '>=16.0.0 <17.0.0' - node: '>=4' - commands: - - node test/instrumentation/modules/hapi/basic-legacy-path.test.js - - node test/instrumentation/modules/hapi/set-framework-hapi.test.js -hapi-prenodev15: - name: hapi - versions: '>=17.0.0' - node: '>=8.12.0 <15.0.0' - commands: - - node test/instrumentation/modules/hapi/basic-legacy-path.test.js - - node test/instrumentation/modules/hapi/set-framework-hapi.test.js -hapi: - name: hapi - # Work around https://github.com/npm/cli/issues/2267 in npm@7. - # Note: An alternative might be to just not test the "hapi" package with - # node >= 15, given that "hapi" was deprecated before node v16. - preinstall: rm -rf node_modules/hapi - node: '>=15.0.0' - versions: '>=17.0.0' - commands: - - node test/instrumentation/modules/hapi/basic-legacy-path.test.js - - node test/instrumentation/modules/hapi/set-framework-hapi.test.js -'@hapi/hapi-v17-v18': - name: '@hapi/hapi' - versions: '>=17.0.0 <19.0.0' - node: '>=8.12.0' - commands: - - node test/instrumentation/modules/hapi/basic.test.js - - node test/instrumentation/modules/hapi/set-framework-hapihapi.test.js -'@hapi/hapi': - name: '@hapi/hapi' - versions: '>=19.0.0' - node: '>=12' - commands: - - node test/instrumentation/modules/hapi/basic.test.js - - node test/instrumentation/modules/hapi/set-framework-hapihapi.test.js tedious: name: tedious @@ -96,46 +34,7 @@ cassandra-driver: versions: '>=3 <3.1.0 || >3.1.0 <5' commands: node test/instrumentation/modules/cassandra-driver/index.test.js -restify-old: - name: restify - versions: '>=5.2.0 <8.0.0' - commands: - - node test/instrumentation/modules/restify/basic.test.js - - node test/instrumentation/modules/restify/set-framework.test.js -restify-new: - name: restify - node: '>=8.6.0' - versions: '>=8.0.0' - commands: - - 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 fastify@2.4.0 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: - 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 - - node test/instrumentation/modules/fastify/set-framework.test.js finalhandler: versions: '*' diff --git a/test/instrumentation/modules/hapi/.npmrc b/test/instrumentation/modules/hapi/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/hapi/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/hapi/.tav.yml b/test/instrumentation/modules/hapi/.tav.yml new file mode 100644 index 0000000000..d35f868724 --- /dev/null +++ b/test/instrumentation/modules/hapi/.tav.yml @@ -0,0 +1,57 @@ +# hapi and @hapi/hapi +# - Package name: Starting with v17.9.0 and v18.2.0 the name changed from +# 'hapi' to '@hapi/hapi'. +# - Node version compat: +# - hapi@15: supports node >=v4; breaks on node v14 (usage of `os.tmpDir()`) +# - hapi@16: supports node >=v4 +# - hapi@17, @hapi/hapi@17: supports node >=v8.12.0 (per its README); +# the instrumentation changed significantly for this version +# - hapi@18, @hapi/hapi@18: supports node >=v8.12.0 (per its README) +# - @hapi/hapi@19: supports node >=v12 (judging from commit 50d8d7d) +# - @hapi/hapi@20: appears (from travis template refs) to support node >=v12 +hapi-v9-v15: + name: hapi + versions: '>=9.0.1 <16.0.0' + node: '>=4 <14' + commands: + - node basic-legacy-path.test.js + - node set-framework-hapi.test.js +hapi-v16: + name: hapi + versions: '>=16.0.0 <17.0.0' + node: '>=4' + commands: + - node basic-legacy-path.test.js + - node set-framework-hapi.test.js +hapi-prenodev15: + name: hapi + versions: '>=17.0.0' + node: '>=8.12.0 <15.0.0' + commands: + - node basic-legacy-path.test.js + - node set-framework-hapi.test.js +hapi: + name: hapi + # Work around https://github.com/npm/cli/issues/2267 in npm@7. + # Note: An alternative might be to just not test the "hapi" package with + # node >= 15, given that "hapi" was deprecated before node v16. + preinstall: rm -rf node_modules/hapi + node: '>=15.0.0' + versions: '>=17.0.0' + commands: + - node basic-legacy-path.test.js + - node set-framework-hapi.test.js +'@hapi/hapi-v17-v18': + name: '@hapi/hapi' + versions: '>=17.0.0 <19.0.0' + node: '>=8.12.0' + commands: + - node basic.test.js + - node set-framework-hapihapi.test.js +'@hapi/hapi': + name: '@hapi/hapi' + versions: '>=19.0.0' + node: '>=12' + commands: + - node basic.test.js + - node set-framework-hapihapi.test.js diff --git a/test/instrumentation/modules/hapi/package.json b/test/instrumentation/modules/hapi/package.json new file mode 100644 index 0000000000..e2833e7c6b --- /dev/null +++ b/test/instrumentation/modules/hapi/package.json @@ -0,0 +1,9 @@ +{ + "name": "test-hapi", + "version": "1.0.0", + "private": true, + "dependencies": { + "hapi": "^18.1.0", + "@hapi/hapi": "^20.1.2" + } +} diff --git a/test/instrumentation/modules/restify/.npmrc b/test/instrumentation/modules/restify/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/test/instrumentation/modules/restify/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/instrumentation/modules/restify/.tav.yml b/test/instrumentation/modules/restify/.tav.yml new file mode 100644 index 0000000000..d148b4c803 --- /dev/null +++ b/test/instrumentation/modules/restify/.tav.yml @@ -0,0 +1,13 @@ +restify-old: + name: restify + versions: '>=5.2.0 <8.0.0' + commands: + - node basic.test.js + - node set-framework.test.js +restify-new: + name: restify + node: '>=8.6.0' + versions: '>=8.0.0' + commands: + - node basic.test.js + - node set-framework.test.js diff --git a/test/instrumentation/modules/restify/package.json b/test/instrumentation/modules/restify/package.json new file mode 100644 index 0000000000..8ec6128e1d --- /dev/null +++ b/test/instrumentation/modules/restify/package.json @@ -0,0 +1,8 @@ +{ + "name": "test-restify", + "version": "1.0.0", + "private": true, + "dependencies": { + "restify": "^8.5.1" + } +} From deb582e10f083cc64f043b84e894062b8405a152 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 8 Nov 2021 21:36:04 -0800 Subject: [PATCH 17/17] fix import --- .../modules/apollo-server-express/apollo-server-express.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js b/test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js index 10e18d2f2a..745435ec8e 100644 --- a/test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js +++ b/test/instrumentation/modules/apollo-server-express/apollo-server-express.test.js @@ -25,7 +25,7 @@ if (semver.gte(apolloServerExpressVersion, '3.0.0') && semver.lt(process.version var ApolloServer = require('apollo-server-express').ApolloServer var gql = require('apollo-server-express').gql -var mockClient = require('../../_mock_http_client') +var mockClient = require('../../../_mock_http_client') test('POST /graphql', function (t) { resetAgent(done(t, 'hello'))