Skip to content

Commit 1ded79e

Browse files
committed
Added ESM tests for instrumentations without integration tests
1 parent 69661b4 commit 1ded79e

File tree

33 files changed

+1148
-33
lines changed

33 files changed

+1148
-33
lines changed

.github/workflows/apm-integrations.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ jobs:
200200
api_key: ${{ secrets.DD_API_KEY }}
201201
service: dd-trace-js-tests
202202

203+
crypto:
204+
runs-on: ubuntu-latest
205+
env:
206+
PLUGINS: crypto
207+
steps:
208+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
209+
- uses: ./.github/actions/plugins/test
210+
with:
211+
dd_api_key: ${{ secrets.DD_API_KEY }}
212+
203213
confluentinc-kafka-javascript:
204214
strategy:
205215
matrix:
@@ -267,6 +277,16 @@ jobs:
267277
with:
268278
dd_api_key: ${{ secrets.DD_API_KEY }}
269279

280+
cookie:
281+
runs-on: ubuntu-latest
282+
env:
283+
PLUGINS: cookie
284+
steps:
285+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
286+
- uses: ./.github/actions/plugins/test
287+
with:
288+
dd_api_key: ${{ secrets.DD_API_KEY }}
289+
270290
couchbase:
271291
strategy:
272292
matrix:
@@ -434,6 +454,16 @@ jobs:
434454
with:
435455
dd_api_key: ${{ secrets.DD_API_KEY }}
436456

457+
generic-pool:
458+
runs-on: ubuntu-latest
459+
env:
460+
PLUGINS: generic-pool
461+
steps:
462+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
463+
- uses: ./.github/actions/plugins/test
464+
with:
465+
dd_api_key: ${{ secrets.DD_API_KEY }}
466+
437467
graphql:
438468
runs-on: ubuntu-latest
439469
env:
@@ -454,6 +484,16 @@ jobs:
454484
with:
455485
dd_api_key: ${{ secrets.DD_API_KEY }}
456486

487+
handlebars:
488+
runs-on: ubuntu-latest
489+
env:
490+
PLUGINS: handlebars
491+
steps:
492+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
493+
- uses: ./.github/actions/plugins/test
494+
with:
495+
dd_api_key: ${{ secrets.DD_API_KEY }}
496+
457497
hapi:
458498
runs-on: ubuntu-latest
459499
env:
@@ -577,6 +617,16 @@ jobs:
577617
api_key: ${{ secrets.DD_API_KEY }}
578618
service: dd-trace-js-tests
579619

620+
knex:
621+
runs-on: ubuntu-latest
622+
env:
623+
PLUGINS: knex
624+
steps:
625+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
626+
- uses: ./.github/actions/plugins/test
627+
with:
628+
dd_api_key: ${{ secrets.DD_API_KEY }}
629+
580630
koa:
581631
runs-on: ubuntu-latest
582632
env:
@@ -587,6 +637,16 @@ jobs:
587637
with:
588638
dd_api_key: ${{ secrets.DD_API_KEY }}
589639

640+
ldapjs:
641+
runs-on: 'ubuntu-latest'
642+
env:
643+
PLUGINS: ldapjs
644+
steps:
645+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
646+
- uses: ./.github/actions/plugins/test
647+
with:
648+
dd_api_key: ${{ secrets.DD_API_KEY }}
649+
590650
limitd-client:
591651
runs-on: ubuntu-latest
592652
services:
@@ -607,6 +667,16 @@ jobs:
607667
with:
608668
dd_api_key: ${{ secrets.DD_API_KEY }}
609669

670+
lodash:
671+
runs-on: 'ubuntu-latest'
672+
env:
673+
PLUGINS: lodash
674+
steps:
675+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
676+
- uses: ./.github/actions/plugins/test
677+
with:
678+
dd_api_key: ${{ secrets.DD_API_KEY }}
679+
610680
mariadb:
611681
runs-on: ubuntu-latest
612682
services:
@@ -712,6 +782,16 @@ jobs:
712782
with:
713783
dd_api_key: ${{ secrets.DD_API_KEY }}
714784

785+
multer:
786+
runs-on: ubuntu-latest
787+
env:
788+
PLUGINS: multer
789+
steps:
790+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
791+
- uses: ./.github/actions/plugins/test
792+
with:
793+
dd_api_key: ${{ secrets.DD_API_KEY }}
794+
715795
mysql:
716796
runs-on: ubuntu-latest
717797
services:
@@ -833,6 +913,16 @@ jobs:
833913
api_key: ${{ secrets.DD_API_KEY }}
834914
service: dd-trace-js-tests
835915

916+
node-serialize:
917+
runs-on: ubuntu-latest
918+
env:
919+
PLUGINS: node-serialize
920+
steps:
921+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
922+
- uses: ./.github/actions/plugins/test
923+
with:
924+
dd_api_key: ${{ secrets.DD_API_KEY }}
925+
836926
opensearch:
837927
runs-on: ubuntu-latest
838928
services:
@@ -963,6 +1053,16 @@ jobs:
9631053
with:
9641054
dd_api_key: ${{ secrets.DD_API_KEY }}
9651055

1056+
process:
1057+
runs-on: ubuntu-latest
1058+
env:
1059+
PLUGINS: process
1060+
steps:
1061+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1062+
- uses: ./.github/actions/plugins/test
1063+
with:
1064+
dd_api_key: ${{ secrets.DD_API_KEY }}
1065+
9661066
protobufjs:
9671067
runs-on: ubuntu-latest
9681068
env:
@@ -974,6 +1074,16 @@ jobs:
9741074
with:
9751075
dd_api_key: ${{ secrets.DD_API_KEY }}
9761076

1077+
pug:
1078+
runs-on: ubuntu-latest
1079+
env:
1080+
PLUGINS: pug
1081+
steps:
1082+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1083+
- uses: ./.github/actions/plugins/test
1084+
with:
1085+
dd_api_key: ${{ secrets.DD_API_KEY }}
1086+
9771087
redis:
9781088
runs-on: ubuntu-latest
9791089
services:
@@ -1067,6 +1177,16 @@ jobs:
10671177
with:
10681178
dd_api_key: ${{ secrets.DD_API_KEY }}
10691179

1180+
sequelize:
1181+
runs-on: ubuntu-latest
1182+
env:
1183+
PLUGINS: sequelize
1184+
steps:
1185+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1186+
- uses: ./.github/actions/plugins/test
1187+
with:
1188+
dd_api_key: ${{ secrets.DD_API_KEY }}
1189+
10701190
sharedb:
10711191
runs-on: ubuntu-latest
10721192
env:
@@ -1130,6 +1250,26 @@ jobs:
11301250
with:
11311251
dd_api_key: ${{ secrets.DD_API_KEY }}
11321252

1253+
url:
1254+
runs-on: ubuntu-latest
1255+
env:
1256+
PLUGINS: url
1257+
steps:
1258+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1259+
- uses: ./.github/actions/plugins/test
1260+
with:
1261+
dd_api_key: ${{ secrets.DD_API_KEY }}
1262+
1263+
vm:
1264+
runs-on: ubuntu-latest
1265+
env:
1266+
PLUGINS: vm
1267+
steps:
1268+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1269+
- uses: ./.github/actions/plugins/test
1270+
with:
1271+
dd_api_key: ${{ secrets.DD_API_KEY }}
1272+
11331273
winston:
11341274
runs-on: ubuntu-latest
11351275
env:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict'
2+
3+
const {
4+
sandboxCwd, useSandbox, varySandbox, curl,
5+
FakeAgent, spawnPluginIntegrationTestProc
6+
} = require('../../../../integration-tests/helpers')
7+
const { assert } = require('chai')
8+
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
9+
10+
withVersions('cookie', 'cookie', '>=0.4', version => {
11+
describe('ESM', () => {
12+
let variants, proc, agent
13+
14+
useSandbox([`'cookie@${version}'`, 'express'], false,
15+
['./packages/datadog-plugin-cookie/test/integration-test/*'])
16+
17+
before(function () {
18+
variants = varySandbox('server.mjs', 'cookie')
19+
})
20+
21+
beforeEach(async () => {
22+
agent = await new FakeAgent().start()
23+
})
24+
25+
afterEach(async () => {
26+
proc?.kill()
27+
await agent.stop()
28+
})
29+
30+
for (const variant of varySandbox.VARIANTS) {
31+
it(`is instrumented loaded with ${variant}`, async () => {
32+
proc = await spawnPluginIntegrationTestProc(sandboxCwd(), variants[variant], agent.port)
33+
const response = await curl(proc)
34+
assert.equal(response.headers['x-counter'], '1')
35+
})
36+
}
37+
})
38+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dd-trace/init.js'
2+
import express from 'express'
3+
import cookie from 'cookie'
4+
import dc from 'dc-polyfill'
5+
6+
const cookieParseCh = dc.channel('datadog:cookie:parse:finish')
7+
let counter = 0
8+
cookieParseCh.subscribe(() => {
9+
counter += 1
10+
})
11+
12+
const app = express()
13+
14+
app.get('/', (req, res) => {
15+
cookie.parse('hello=world')
16+
res.setHeader('X-Counter', counter)
17+
res.end('ok')
18+
})
19+
20+
const server = app.listen(0, () => {
21+
const port = server.address().port
22+
process.send({ port })
23+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict'
2+
3+
const {
4+
useSandbox, sandboxCwd, varySandbox, curl,
5+
FakeAgent, spawnPluginIntegrationTestProc
6+
} = require('../../../../integration-tests/helpers')
7+
const { assert } = require('chai')
8+
9+
describe('ESM', () => {
10+
let variants, proc, agent
11+
12+
useSandbox(['crypto', 'express'], false,
13+
['./packages/datadog-plugin-crypto/test/integration-test/*'])
14+
15+
before(function () {
16+
variants = varySandbox('server.mjs', 'node:crypto', 'createHash')
17+
})
18+
19+
beforeEach(async () => {
20+
agent = await new FakeAgent().start()
21+
})
22+
23+
afterEach(async () => {
24+
proc?.kill()
25+
await agent.stop()
26+
})
27+
28+
for (const variant of varySandbox.VARIANTS) {
29+
it(`is instrumented loaded with ${variant}`, async () => {
30+
proc = await spawnPluginIntegrationTestProc(sandboxCwd(), variants[variant], agent.port)
31+
const response = await curl(proc)
32+
assert.equal(response.headers['x-counter'], '1')
33+
})
34+
}
35+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dd-trace/init.js'
2+
import express from 'express'
3+
import { createHash } from 'node:crypto'
4+
import dc from 'dc-polyfill'
5+
6+
const cryptoHashCh = dc.channel('datadog:crypto:hashing:start')
7+
let counter = 0
8+
cryptoHashCh.subscribe(() => {
9+
counter += 1
10+
})
11+
12+
const app = express()
13+
14+
app.get('/', (req, res) => {
15+
createHash('sha256')
16+
res.setHeader('X-Counter', counter)
17+
res.end('ok')
18+
})
19+
20+
const server = app.listen(0, () => {
21+
const port = server.address().port
22+
process.send({ port })
23+
})
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict'
2+
3+
const {
4+
sandboxCwd, useSandbox, varySandbox, curl,
5+
FakeAgent, spawnPluginIntegrationTestProc
6+
} = require('../../../../integration-tests/helpers')
7+
const { assert } = require('chai')
8+
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
9+
10+
withVersions('generic-pool', 'generic-pool', '>=3', version => {
11+
describe('ESM', () => {
12+
let variants, proc, agent
13+
14+
useSandbox([`'generic-pool@${version}'`, 'express'], false,
15+
['./packages/datadog-plugin-generic-pool/test/integration-test/*'])
16+
17+
before(function () {
18+
variants = varySandbox('server.mjs', 'genericPool', undefined, 'generic-pool')
19+
})
20+
21+
beforeEach(async () => {
22+
agent = await new FakeAgent().start()
23+
})
24+
25+
afterEach(async () => {
26+
proc?.kill()
27+
await agent.stop()
28+
})
29+
30+
for (const variant of varySandbox.VARIANTS) {
31+
it(`is instrumented loaded with ${variant}`, async () => {
32+
proc = await spawnPluginIntegrationTestProc(sandboxCwd(), variants[variant], agent.port)
33+
const response = await curl(proc)
34+
assert.equal(response.headers['x-counter'], '1')
35+
})
36+
}
37+
})
38+
})

0 commit comments

Comments
 (0)