Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fixes and adds esm integration tests for oracledb (DataDog#3580)
Browse files Browse the repository at this point in the history
* adds esm integration tests for oracledb
  • Loading branch information
khanayan123 authored Sep 13, 2023
1 parent ad3a267 commit c80be9a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict'

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

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

before(async function () {
this.timeout(20000)
sandbox = await createSandbox(['oracledb@^5.0.0'], false, [
`./packages/datadog-plugin-oracledb/test/integration-test/*`])
})

after(async () => {
await sandbox.remove()
})

beforeEach(async () => {
agent = await new FakeAgent().start()
})

afterEach(async () => {
proc && proc.kill()
await agent.stop()
})

context('oracledb', () => {
it('is instrumented', async () => {
const res = agent.assertMessageReceived(({ headers, payload }) => {
assert.propertyVal(headers, 'host', `127.0.0.1:${agent.port}`)
assert.isArray(payload)
assert.strictEqual(checkSpansForServiceName(payload, 'oracle.query'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined, {
LD_LIBRARY_PATH: '/usr/lib/oracle/18.5/client64/lib:'
})

await res
}).timeout(20000)
})
})
21 changes: 21 additions & 0 deletions packages/datadog-plugin-oracledb/test/integration-test/server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dd-trace/init.js'
import oracledb from 'oracledb'

const hostname = 'oracledb'

const config = {
user: 'test',
password: 'Oracle18',
connectString: `${hostname}:1521/xepdb1`
};

const dbQuery = 'select current_timestamp from dual'

let connection;

connection = await oracledb.getConnection(config)
await connection.execute(dbQuery)

if (connection) {
await connection.close()
}

0 comments on commit c80be9a

Please sign in to comment.