This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
forked from DataDog/dd-trace-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes and adds esm integration tests for oracledb (DataDog#3580)
* adds esm integration tests for oracledb
- Loading branch information
1 parent
ad3a267
commit c80be9a
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/datadog-plugin-oracledb/test/integration-test/client.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
packages/datadog-plugin-oracledb/test/integration-test/server.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |