Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('esm', () => {
assert.fail('No ai spans found')
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, null, {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, {
NODE_OPTIONS: '--import dd-trace/initialize.mjs'
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'anthropic.request'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, null, {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, {
NODE_OPTIONS: '--import dd-trace/initialize.mjs',
ANTHROPIC_API_KEY: '<not-a-real-key>'
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'aws.request'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined,
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port,
{
AWS_SECRET_ACCESS_KEY: '0000000000/00000000000000000000000000000',
AWS_ACCESS_KEY_ID: '00000000000000000000'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
createSandbox,
checkSpansForServiceName,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { assert } = require('chai')
const { insertVersionDep } = require('../../../dd-trace/test/setup/mocha')

describe('esm', () => {
let agent
let proc
let sandbox
const env = {
NODE_OPTIONS: `--loader=${join(__dirname, '..', '..', '..', '..', 'initialize.mjs')}`
}

before(async function () {
this.timeout(60000)
sandbox = await createSandbox(['axios'], false, [
'./packages/datadog-plugin-axios/test/integration-test/*'])
})

after(async () => {
await sandbox.remove()
})
insertVersionDep(__dirname, 'axios', '*')

beforeEach(async () => {
agent = await new FakeAgent().start()
Expand All @@ -40,7 +37,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'http.request'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(__dirname, 'server.mjs', agent.port, env)

await res
}).timeout(20000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('esm', () => {
})
})

// TODO(BridgeAR): Unify with other helper of the same name.
async function spawnPluginIntegrationTestProc (cwd, command, args, agentPort, stdioHandler, additionalEnvArgs = {}) {
let env = {
NODE_OPTIONS: `--loader=${hookFile}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
createSandbox,
checkSpansForServiceName,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
const { assert } = require('chai')
const { withVersions, insertVersionDep } = require('../../../dd-trace/test/setup/mocha')

describe('esm', () => {
let agent
let proc
let sandbox
const env = {
NODE_OPTIONS: `--loader=${join(__dirname, '..', '..', '..', '..', 'initialize.mjs')}`
}

// test against later versions because server.mjs uses newer package syntax
withVersions('couchbase', 'couchbase', '>=4.0.0', version => {
before(async function () {
this.timeout(60000)
sandbox = await createSandbox([`'couchbase@${version}'`], false, [
'./packages/datadog-plugin-couchbase/test/integration-test/*'])
})

after(async () => {
await sandbox.remove()
})
insertVersionDep(__dirname, 'couchbase', version)

beforeEach(async () => {
agent = await new FakeAgent().start()
Expand All @@ -42,7 +38,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'couchbase.upsert'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(__dirname, 'server.mjs', agent.port, env)
await res
}).timeout(20000)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dd-trace/init.js'
import { connect } from 'couchbase'

const cluster = await connect(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
curlAndAssertMessage,
checkSpansForServiceName,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { withVersions, insertVersionDep } = require('../../../dd-trace/test/setup/mocha')
const { assert } = require('chai')
const { join } = require('path')

describe('esm', () => {
let agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'pubsub.request'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined,
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port,
{ PUBSUB_EMULATOR_HOST: 'localhost:8081' })

await res
Expand Down
24 changes: 10 additions & 14 deletions packages/datadog-plugin-hapi/test/integration-test/client.spec.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
createSandbox,
curlAndAssertMessage,
checkSpansForServiceName,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
const { assert } = require('chai')
const { withVersions, insertVersionDep } = require('../../../dd-trace/test/setup/mocha')

describe('esm', () => {
let agent
let proc
let sandbox
const env = {
NODE_OPTIONS: `--loader=${join(__dirname, '..', '..', '..', '..', 'initialize.mjs')}`
}

withVersions('hapi', '@hapi/hapi', version => {
before(async function () {
this.timeout(60000)
sandbox = await createSandbox([`'@hapi/hapi@${version}'`], false, [
'./packages/datadog-plugin-hapi/test/integration-test/*'])
})

after(async () => {
await sandbox.remove()
})
insertVersionDep(__dirname, '@hapi/hapi', version)

beforeEach(async () => {
agent = await new FakeAgent().start()
Expand All @@ -36,7 +32,7 @@ describe('esm', () => {
})

it('is instrumented', async () => {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(__dirname, 'server.mjs', agent.port, env)

return curlAndAssertMessage(agent, proc, ({ headers, payload }) => {
assert.propertyVal(headers, 'host', `127.0.0.1:${agent.port}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dd-trace/init.js'
import Hapi from '@hapi/hapi'

const server = Hapi.server({ port: 0, host: 'localhost' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('esm integration test', () => {
})

it('is instrumented', async () => {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined, {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, {
VERSION: version
})
proc.url += '/hello'
Expand All @@ -48,7 +48,7 @@ describe('esm integration test', () => {
}).timeout(50000)

it('receives missing route trace', async () => {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined, {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, {
VERSION: version
})
proc.url += '/missing'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
createSandbox,
curlAndAssertMessage,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { assert } = require('chai')

describe('esm', () => {
let agent
let proc
let sandbox

before(async function () {
this.timeout(60000)
sandbox = await createSandbox([], false, [
'./packages/datadog-plugin-http/test/integration-test/*'])
})

after(async () => {
await sandbox.remove()
})
const env = {
NODE_OPTIONS: `--loader=${join(__dirname, '..', '..', '..', '..', 'initialize.mjs')}`
}

beforeEach(async () => {
agent = await new FakeAgent().start()
Expand All @@ -34,7 +28,7 @@ describe('esm', () => {

context('http', () => {
it('is instrumented', async () => {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(__dirname, 'server.mjs', agent.port, env)

return curlAndAssertMessage(agent, proc, ({ headers, payload }) => {
assert.propertyVal(headers, 'host', `127.0.0.1:${agent.port}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dd-trace/init.js'
import http from 'http'

const server = http.createServer(async (req, res) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
createSandbox,
checkSpansForServiceName,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
const { assert } = require('chai')
const { withVersions, insertVersionDep } = require('../../../dd-trace/test/setup/mocha')

describe('esm', () => {
let agent
let proc
let sandbox
withVersions('iovalkey', 'iovalkey', version => {
before(async function () {
this.timeout(60000)
sandbox = await createSandbox([`'iovalkey@${version}'`], false, [
'./packages/datadog-plugin-iovalkey/test/integration-test/*'])
})
const env = {
NODE_OPTIONS: `--loader=${join(__dirname, '..', '..', '..', '..', 'initialize.mjs')}`
}

after(async () => {
await sandbox.remove()
})
withVersions('iovalkey', 'iovalkey', version => {
insertVersionDep(__dirname, 'iovalkey', version)

beforeEach(async () => {
agent = await new FakeAgent().start()
Expand All @@ -40,7 +37,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'valkey.command'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(__dirname, 'server.mjs', agent.port, env)

await res
}).timeout(20000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dd-trace/init.js'
import Valkey from 'iovalkey'

const client = new Valkey({ connectionName: 'test' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
'use strict'

const { join } = require('node:path')

const { assert } = require('chai')

const {
FakeAgent,
createSandbox,
checkSpansForServiceName,
spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
const { assert } = require('chai')
const { withVersions, insertVersionDep } = require('../../../dd-trace/test/setup/mocha')

describe('esm', () => {
let agent
let proc
let sandbox
withVersions('kafkajs', 'kafkajs', version => {
before(async function () {
this.timeout(60000)
sandbox = await createSandbox([`'kafkajs@${version}'`], false, [
'./packages/datadog-plugin-kafkajs/test/integration-test/*'])
})
const env = {
NODE_OPTIONS: `--loader=${join(__dirname, '..', '..', '..', '..', 'initialize.mjs')}`
}

after(async () => {
await sandbox.remove()
})
withVersions('kafkajs', 'kafkajs', version => {
insertVersionDep(__dirname, 'kafkajs', version)

beforeEach(async () => {
agent = await new FakeAgent().start()
Expand All @@ -40,7 +37,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'kafka.produce'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(__dirname, 'server.mjs', agent.port, env)

await res
}).timeout(20000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dd-trace/init.js'
import { Kafka } from 'kafkajs'

const kafka = new Kafka({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'langchain.request'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, null, {
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, {
NODE_OPTIONS: '--import dd-trace/initialize.mjs'
})

Expand Down
Loading
Loading